Skip to content

Commit

Permalink
BUG: dask: fix asarray(..., copy=None) for array-likes: they copy
Browse files Browse the repository at this point in the history
As of dask >= 2024.12, da.from_array() always copies, while before it did not.
Thus copy too, to make array_api_compat.dask.array version-independent.
  • Loading branch information
ev-br committed Dec 5, 2024
1 parent f24c102 commit fda4ab0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion array_api_compat/dask/array/_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def asarray(
return da.array(obj, dtype=dtype)
else:
if not isinstance(obj, da.Array) or dtype is not None and obj.dtype != dtype:
obj = np.asarray(obj, dtype=dtype)
# copy=True to be uniform across dask < 2024.12 and >= 2024.12
# see https://github.com/dask/dask/pull/11524/
obj = np.asarray(obj, dtype=dtype, copy=True)
return da.from_array(obj)
return obj

Expand Down

0 comments on commit fda4ab0

Please sign in to comment.