@@ -43,7 +43,7 @@ def _np_grouped_op(group_idx, array, op, axis=-1, size=None, fill_value=None, dt
43
43
# The previous version of this if condition
44
44
# ((uniques[1:] - uniques[:-1]) == 1).all():
45
45
# does not work when group_idx is [1, 2] for e.g.
46
- # This happens during binning
46
+ # This happens during binning
47
47
op .reduceat (array , inv_idx , axis = axis , dtype = dtype , out = out )
48
48
else :
49
49
out [..., uniques ] = op .reduceat (array , inv_idx , axis = axis , dtype = dtype )
@@ -105,16 +105,14 @@ def nanlen(group_idx, array, *args, **kwargs):
105
105
def mean (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
106
106
if fill_value is None :
107
107
fill_value = 0
108
- out = np .full (array .shape [:- 1 ] + (size ,), fill_value = fill_value , dtype = dtype )
109
- sum (group_idx , array , axis = axis , size = size , dtype = dtype , out = out )
108
+ out = sum (group_idx , array , axis = axis , size = size , dtype = dtype , fill_value = fill_value )
110
109
out /= nanlen (group_idx , array , size = size , axis = axis , fill_value = 0 )
111
110
return out
112
111
113
112
114
113
def nanmean (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
115
114
if fill_value is None :
116
115
fill_value = 0
117
- out = np .full (array .shape [:- 1 ] + (size ,), fill_value = fill_value , dtype = dtype )
118
- nansum (group_idx , array , size = size , axis = axis , dtype = dtype , out = out )
116
+ out = nansum (group_idx , array , size = size , axis = axis , dtype = dtype , fill_value = fill_value )
119
117
out /= nanlen (group_idx , array , size = size , axis = axis , fill_value = 0 )
120
118
return out
0 commit comments