@@ -43,7 +43,7 @@ def _np_grouped_op(group_idx, array, op, axis=-1, size=None, fill_value=None, dt
4343 # The previous version of this if condition
4444 # ((uniques[1:] - uniques[:-1]) == 1).all():
4545 # does not work when group_idx is [1, 2] for e.g.
46- # This happens during binning
46+ # This happens during binning
4747 op .reduceat (array , inv_idx , axis = axis , dtype = dtype , out = out )
4848 else :
4949 out [..., uniques ] = op .reduceat (array , inv_idx , axis = axis , dtype = dtype )
@@ -105,16 +105,14 @@ def nanlen(group_idx, array, *args, **kwargs):
105105def mean (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
106106 if fill_value is None :
107107 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 )
110109 out /= nanlen (group_idx , array , size = size , axis = axis , fill_value = 0 )
111110 return out
112111
113112
114113def nanmean (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
115114 if fill_value is None :
116115 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 )
119117 out /= nanlen (group_idx , array , size = size , axis = axis , fill_value = 0 )
120118 return out
0 commit comments