File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -892,7 +892,8 @@ def reindex_(
892892 "Currently does not support reindexing with object arrays of tuples. "
893893 "These occur when grouping by multi-indexed variables in xarray."
894894 )
895- if fill_value is xrdtypes .NA or isnull (fill_value ):
895+ # Use '==' instead of 'is', as Dask serialization can break identity checks.
896+ if fill_value == xrdtypes .NA or isnull (fill_value ):
896897 new_dtype , fill_value = xrdtypes .maybe_promote (array .dtype )
897898 else :
898899 new_dtype = array .dtype
@@ -1380,7 +1381,8 @@ def _finalize_results(
13801381 if fill_value is None :
13811382 raise ValueError ("Filling is required but fill_value is None." )
13821383 # This allows us to match xarray's type promotion rules
1383- if fill_value is xrdtypes .NA :
1384+ # Use '==' instead of 'is', as Dask serialization can break identity checks.
1385+ if fill_value == xrdtypes .NA :
13841386 new_dtype , fill_value = xrdtypes .maybe_promote (finalized [agg .name ].dtype )
13851387 finalized [agg .name ] = finalized [agg .name ].astype (new_dtype )
13861388
Original file line number Diff line number Diff line change @@ -798,3 +798,16 @@ def test_groupby_preserve_dtype(reduction):
798798 expected = getattr (np , reduction )(ds .test .data , axis = 0 ).dtype
799799
800800 assert actual == expected
801+
802+
803+ @requires_dask
804+ def test_resample_first_last_empty ():
805+ with xr .set_options (use_flox = True ), dask .config .set (scheduler = "processes" ):
806+ arr = xr .DataArray (
807+ np .nan ,
808+ coords = {
809+ "date" : pd .to_datetime (["2025-03-24" , "2025-06-23" ]),
810+ },
811+ dims = ["date" ],
812+ ).chunk (date = (1 , 1 ))
813+ arr .resample (date = "QE" ).last ().compute ()
You can’t perform that action at this time.
0 commit comments