Skip to content

Commit

Permalink
Merge pull request #234 from lithomas1/dask-astype-copy
Browse files Browse the repository at this point in the history
BUG: astype(..., copy=True) doesn't copy on dask
  • Loading branch information
ev-br authored Jan 16, 2025
2 parents 5ef0e18 + 691c27b commit adbb6ef
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion array_api_compat/dask/array/_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,22 @@

isdtype = get_xp(np)(_aliases.isdtype)
unstack = get_xp(da)(_aliases.unstack)
astype = _aliases.astype

def astype(
x: Array,
dtype: Dtype,
/,
*,
copy: bool = True,
device: Device | None = None
) -> Array:
# TODO: respect device keyword?
if not copy and dtype == x.dtype:
return x
# dask astype doesn't respect copy=True,
# so call copy manually afterwards
x = x.astype(dtype)
return x.copy() if copy else x

# Common aliases

Expand Down

0 comments on commit adbb6ef

Please sign in to comment.