nodes: 0, module; 1, function_definition; 2, function_name:grouped_mean; 3, parameters; 4, block; 5, identifier:arr; 6, identifier:spike_clusters; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, assert_statement; 11, assert_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, assert_statement; 16, expression_statement; 17, comment:# Compute the sum with possible repetitions.; 18, expression_statement; 19, return_statement; 20, comment:"""Compute the mean of a spike-dependent quantity for every cluster.
  
      The two arguments should be 1D array with `n_spikes` elements.
  
      The output is a 1D array with `n_clusters` elements. The clusters are
      sorted in increasing order.
  
      """; 21, assignment; 22, assignment; 23, comparison_operator:arr.ndim == 1; 24, comparison_operator:arr.shape[0] == len(spike_clusters); 25, assignment; 26, assignment; 27, assignment; 28, comparison_operator:len(spike_counts) == len(cluster_ids); 29, assignment; 30, call; 31, binary_operator:t / spike_counts; 32, identifier:arr; 33, call; 34, identifier:spike_clusters; 35, call; 36, attribute; 37, integer:1; 38, subscript; 39, call; 40, identifier:cluster_ids; 41, call; 42, identifier:spike_clusters_rel; 43, call; 44, identifier:spike_counts; 45, call; 46, call; 47, call; 48, identifier:t; 49, call; 50, attribute; 51, argument_list; 52, identifier:t; 53, identifier:spike_counts; 54, attribute; 55, argument_list; 56, attribute; 57, argument_list; 58, identifier:arr; 59, identifier:ndim; 60, attribute; 61, integer:0; 62, identifier:len; 63, argument_list; 64, identifier:_unique; 65, argument_list; 66, identifier:_index_of; 67, argument_list; 68, attribute; 69, argument_list; 70, identifier:len; 71, argument_list; 72, identifier:len; 73, argument_list; 74, attribute; 75, argument_list; 76, attribute; 77, identifier:at; 78, identifier:t; 79, identifier:spike_clusters_rel; 80, identifier:arr; 81, identifier:np; 82, identifier:asarray; 83, identifier:arr; 84, identifier:np; 85, identifier:asarray; 86, identifier:spike_clusters; 87, identifier:arr; 88, identifier:shape; 89, identifier:spike_clusters; 90, identifier:spike_clusters; 91, identifier:spike_clusters; 92, identifier:cluster_ids; 93, identifier:np; 94, identifier:bincount; 95, identifier:spike_clusters_rel; 96, identifier:spike_counts; 97, identifier:cluster_ids; 98, identifier:np; 99, identifier:zeros; 100, call; 101, identifier:np; 102, identifier:add; 103, identifier:len; 104, argument_list; 105, identifier:cluster_ids
code: def grouped_mean(arr, spike_clusters):
      """Compute the mean of a spike-dependent quantity for every cluster.
  
      The two arguments should be 1D array with `n_spikes` elements.
  
      The output is a 1D array with `n_clusters` elements. The clusters are
      sorted in increasing order.
  
      """
      arr = np.asarray(arr)
      spike_clusters = np.asarray(spike_clusters)
      assert arr.ndim == 1
      assert arr.shape[0] == len(spike_clusters)
      cluster_ids = _unique(spike_clusters)
      spike_clusters_rel = _index_of(spike_clusters, cluster_ids)
      spike_counts = np.bincount(spike_clusters_rel)
      assert len(spike_counts) == len(cluster_ids)
      t = np.zeros(len(cluster_ids))
      # Compute the sum with possible repetitions.
      np.add.at(t, spike_clusters_rel, arr)
      return t / spike_counts