Skip to content

Commit

Permalink
use duck_array_ops.astype
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuehlbauer committed May 9, 2023
1 parent b304aa0 commit 584b46e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xarray/coding/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def encode(self, variable: Variable, name: T_Name = None):
if isinstance(units, str) and "since" in units:
encoded_dtype = encoding.pop("dtype")
if encoded_dtype is not None and encoded_dtype != data.dtype:
data = np.asarray(data, dtype=encoded_dtype)
data = duck_array_ops.astype(data, encoded_dtype)

if fv_exists:
# Ensure _FillValue is cast to same dtype as data's
Expand Down

0 comments on commit 584b46e

Please sign in to comment.