Skip to content

Commit 398f1b6

Browse files
committed
Backward compatibility dask
1 parent bde40e4 commit 398f1b6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

xarray/core/duck_array_ops.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,14 @@ def datetime_to_numeric(array, offset=None, datetime_unit=None, dtype=float):
431431
# Compute timedelta object.
432432
# For np.datetime64, this can silently yield garbage due to overflow.
433433
# One option is to enforce 1970-01-01 as the universal offset.
434-
array = array - offset
434+
435+
# This map_blocks call is for backwards compatibility.
436+
# dask == 2021.04.1 does not support subtracting object arrays
437+
# which is required for cftime
438+
if is_duck_dask_array(array):
439+
array = array.map_blocks(lambda a, b: a - b, offset)
440+
else:
441+
array = array - offset
435442

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

0 commit comments

Comments
 (0)