Skip to content

Commit 5648c0f

Browse files
committed
use duck_array_ops.astype
1 parent b304aa0 commit 5648c0f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xarray/coding/variables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def encode(self, variable: Variable, name: T_Name = None):
241241
if isinstance(units, str) and "since" in units:
242242
encoded_dtype = encoding.pop("dtype")
243243
if encoded_dtype is not None and encoded_dtype != data.dtype:
244-
data = np.asarray(data, dtype=encoded_dtype)
244+
data = duck_array_ops.astype(encoded_dtype)
245245

246246
if fv_exists:
247247
# Ensure _FillValue is cast to same dtype as data's

0 commit comments

Comments
 (0)