@@ -158,12 +158,12 @@ def _get_fill_value(dtype, fill_value):
158
158
return np .nan
159
159
# This is madness, but npg checks that fill_value is compatible
160
160
# with array dtype even if the fill_value is never used.
161
- elif (
162
- np .issubdtype (dtype , np .integer )
163
- or np .issubdtype (dtype , np .timedelta64 )
164
- or np .issubdtype (dtype , np .datetime64 )
165
- ):
161
+ elif np .issubdtype (dtype , np .integer ):
166
162
return dtypes .get_neg_infinity (dtype , min_for_int = True )
163
+ elif np .issubdtype (dtype , np .timedelta64 ):
164
+ return np .timedelta64 ("NaT" )
165
+ elif np .issubdtype (dtype , np .datetime64 ):
166
+ return np .datetime64 ("NaT" )
167
167
else :
168
168
return None
169
169
return fill_value
@@ -435,9 +435,9 @@ def _std_finalize(sumsq, sum_, count, ddof=0):
435
435
436
436
437
437
min_ = Aggregation ("min" , chunk = "min" , combine = "min" , fill_value = dtypes .INF )
438
- nanmin = Aggregation ("nanmin" , chunk = "nanmin" , combine = "nanmin" , fill_value = np . nan )
438
+ nanmin = Aggregation ("nanmin" , chunk = "nanmin" , combine = "nanmin" , fill_value = dtypes . NA )
439
439
max_ = Aggregation ("max" , chunk = "max" , combine = "max" , fill_value = dtypes .NINF )
440
- nanmax = Aggregation ("nanmax" , chunk = "nanmax" , combine = "nanmax" , fill_value = np . nan )
440
+ nanmax = Aggregation ("nanmax" , chunk = "nanmax" , combine = "nanmax" , fill_value = dtypes . NA )
441
441
442
442
443
443
def argreduce_preprocess (array , axis ):
@@ -741,15 +741,15 @@ def scan_binary_op(left_state: ScanState, right_state: ScanState, *, agg: Scan)
741
741
binary_op = None ,
742
742
reduction = "nanlast" ,
743
743
scan = "ffill" ,
744
- identity = np . nan ,
744
+ identity = dtypes . NA ,
745
745
mode = "concat_then_scan" ,
746
746
)
747
747
bfill = Scan (
748
748
"bfill" ,
749
749
binary_op = None ,
750
750
reduction = "nanlast" ,
751
751
scan = "ffill" ,
752
- identity = np . nan ,
752
+ identity = dtypes . NA ,
753
753
mode = "concat_then_scan" ,
754
754
preprocess = reverse ,
755
755
finalize = reverse ,
0 commit comments