22
33import numpy as np
44
5+ from .xrutils import isnull
6+
57
68def _np_grouped_op (group_idx , array , op , axis = - 1 , size = None , fill_value = None , dtype = None , out = None ):
79 """
@@ -36,7 +38,7 @@ def _np_grouped_op(group_idx, array, op, axis=-1, size=None, fill_value=None, dt
3638
3739
3840def _nan_grouped_op (group_idx , array , func , fillna , * args , ** kwargs ):
39- result = func (group_idx , np .where (np . isnan (array ), fillna , array ), * args , ** kwargs )
41+ result = func (group_idx , np .where (isnull (array ), fillna , array ), * args , ** kwargs )
4042 # np.nanmax([np.nan, np.nan]) = np.nan
4143 # To recover this behaviour, we need to search for the fillna value
4244 # (either np.inf or -np.inf), and replace with NaN
@@ -74,7 +76,7 @@ def sum_of_squares(group_idx, array, *, axis=-1, size=None, fill_value=None, dty
7476def nansum_of_squares (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
7577 return sum_of_squares (
7678 group_idx ,
77- np .where (np . isnan (array ), 0 , array ),
79+ np .where (isnull (array ), 0 , array ),
7880 size = size ,
7981 fill_value = fill_value ,
8082 axis = axis ,
@@ -83,7 +85,7 @@ def nansum_of_squares(group_idx, array, *, axis=-1, size=None, fill_value=None,
8385
8486
8587def nanlen (group_idx , array , * args , ** kwargs ):
86- return sum (group_idx , (~ np . isnan (array )).astype (int ), * args , ** kwargs )
88+ return sum (group_idx , (~ isnull (array )).astype (int ), * args , ** kwargs )
8789
8890
8991def mean (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
0 commit comments