@@ -182,7 +182,7 @@ def find_group_cohorts(labels, chunks, merge=True, method="cohorts"):
182
182
# We always drop NaN; np.unique also considers every NaN to be different so
183
183
# it's really important we get rid of them.
184
184
raveled = labels .ravel ()
185
- unique_labels = np .unique (raveled [~ np . isnan (raveled )])
185
+ unique_labels = np .unique (raveled [~ isnull (raveled )])
186
186
# these are chunks where a label is present
187
187
label_chunks = {lab : tuple (np .unique (which_chunk [raveled == lab ])) for lab in unique_labels }
188
188
# These invert the label_chunks mapping so we know which labels occur together.
@@ -363,7 +363,7 @@ def reindex_(
363
363
raise ValueError ("Filling is required. fill_value cannot be None." )
364
364
indexer [axis ] = idx == - 1
365
365
# This allows us to match xarray's type promotion rules
366
- if fill_value is xrdtypes .NA or np . isnan (fill_value ):
366
+ if fill_value is xrdtypes .NA or isnull (fill_value ):
367
367
new_dtype , fill_value = xrdtypes .maybe_promote (reindexed .dtype )
368
368
reindexed = reindexed .astype (new_dtype , copy = False )
369
369
reindexed [tuple (indexer )] = fill_value
@@ -425,7 +425,7 @@ def factorize_(
425
425
else :
426
426
sorter = None
427
427
idx = np .searchsorted (expect , groupvar .ravel (), sorter = sorter )
428
- mask = np . isnan (groupvar .ravel ())
428
+ mask = isnull (groupvar .ravel ())
429
429
# TODO: optimize?
430
430
idx [mask ] = - 1
431
431
if not sort :
@@ -501,7 +501,7 @@ def chunk_argreduce(
501
501
engine = engine ,
502
502
sort = sort ,
503
503
)
504
- if not np . isnan (results ["groups" ]).all ():
504
+ if not isnull (results ["groups" ]).all ():
505
505
# will not work for empty groups...
506
506
# glorious
507
507
idx = np .broadcast_to (idx , array .shape )
@@ -833,7 +833,7 @@ def _grouped_combine(
833
833
# reindexing is unnecessary
834
834
# I bet we can minimize the amount of reindexing for mD reductions too, but it's complicated
835
835
unique_groups = np .unique (tuple (flatten (deepmap (listify_groups , x_chunk ))))
836
- unique_groups = unique_groups [~ np . isnan (unique_groups )]
836
+ unique_groups = unique_groups [~ isnull (unique_groups )]
837
837
if len (unique_groups ) == 0 :
838
838
unique_groups = [np .nan ]
839
839
0 commit comments