Skip to content

Commit

Permalink
Backward compatibility dask
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed May 20, 2022
1 parent bde40e4 commit 398f1b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion xarray/core/duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,14 @@ def datetime_to_numeric(array, offset=None, datetime_unit=None, dtype=float):
# Compute timedelta object.
# For np.datetime64, this can silently yield garbage due to overflow.
# One option is to enforce 1970-01-01 as the universal offset.
array = array - offset

# This map_blocks call is for backwards compatibility.
# dask == 2021.04.1 does not support subtracting object arrays
# which is required for cftime
if is_duck_dask_array(array):
array = array.map_blocks(lambda a, b: a - b, offset)
else:
array = array - offset

# Scalar is converted to 0d-array
if not hasattr(array, "dtype"):
Expand Down

0 comments on commit 398f1b6

Please sign in to comment.