2
2
3
3
import numpy as np
4
4
5
+ from .xrutils import isnull
6
+
5
7
6
8
def _np_grouped_op (group_idx , array , op , axis = - 1 , size = None , fill_value = None , dtype = None , out = None ):
7
9
"""
@@ -36,7 +38,7 @@ def _np_grouped_op(group_idx, array, op, axis=-1, size=None, fill_value=None, dt
36
38
37
39
38
40
def _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 )
40
42
# np.nanmax([np.nan, np.nan]) = np.nan
41
43
# To recover this behaviour, we need to search for the fillna value
42
44
# (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
74
76
def nansum_of_squares (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
75
77
return sum_of_squares (
76
78
group_idx ,
77
- np .where (np . isnan (array ), 0 , array ),
79
+ np .where (isnull (array ), 0 , array ),
78
80
size = size ,
79
81
fill_value = fill_value ,
80
82
axis = axis ,
@@ -83,7 +85,7 @@ def nansum_of_squares(group_idx, array, *, axis=-1, size=None, fill_value=None,
83
85
84
86
85
87
def 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 )
87
89
88
90
89
91
def mean (group_idx , array , * , axis = - 1 , size = None , fill_value = None , dtype = None ):
0 commit comments