Skip to content

Commit 4520ce9

Browse files
authored
Handle numpy missing the array api function astype (#8315)
1 parent dafd726 commit 4520ce9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

xarray/core/duck_array_ops.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ def cumulative_trapezoid(y, x, axis):
184184
def astype(data, dtype, **kwargs):
185185
if hasattr(data, "__array_namespace__"):
186186
xp = get_array_namespace(data)
187+
if xp == np:
188+
# numpy currently doesn't have a astype:
189+
return data.astype(dtype, **kwargs)
187190
return xp.astype(data, dtype, **kwargs)
188191
return data.astype(dtype, **kwargs)
189192

0 commit comments

Comments
 (0)