Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jul 28, 2024
1 parent fee245f commit 248a5ec
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions numpy_groupies/aggregate_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,21 @@ def _mean(group_idx, a, size, fill_value, dtype=np.dtype(np.float64)):
ret = sums / counts
if not np.isnan(fill_value):
ret[counts == 0] = fill_value
return ret.astype(dtype, copy=False)
if iscomplexobj(a):
return ret
else:
ret.astype(dtype, copy=False)


def _sum_of_squres(group_idx, a, size, fill_value, dtype=np.dtype(np.float64)):
ret = np.bincount(group_idx, weights=a * a, minlength=size)
if fill_value != 0:
counts = np.bincount(group_idx, minlength=size)
ret[counts == 0] = fill_value
return ret.astype(dtype, copy=False)
if iscomplexobj(a):
return ret
else:
ret.astype(dtype, copy=False)


def _var(
Expand All @@ -183,7 +189,10 @@ def _var(
ret = np.sqrt(ret) # this is now std not var
if not np.isnan(fill_value):
ret[counts == 0] = fill_value
return ret.astype(dtype, copy=False)
if iscomplexobj(a):
return ret
else:
ret.astype(dtype, copy=False)


def _std(group_idx, a, size, fill_value, dtype=np.dtype(np.float64), ddof=0):
Expand Down

0 comments on commit 248a5ec

Please sign in to comment.