Skip to content

Commit fda4ab0

Browse files
committed
BUG: dask: fix asarray(..., copy=None) for array-likes: they copy
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.
1 parent f24c102 commit fda4ab0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

array_api_compat/dask/array/_aliases.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def asarray(
140140
return da.array(obj, dtype=dtype)
141141
else:
142142
if not isinstance(obj, da.Array) or dtype is not None and obj.dtype != dtype:
143-
obj = np.asarray(obj, dtype=dtype)
143+
# copy=True to be uniform across dask < 2024.12 and >= 2024.12
144+
# see https://github.com/dask/dask/pull/11524/
145+
obj = np.asarray(obj, dtype=dtype, copy=True)
144146
return da.from_array(obj)
145147
return obj
146148

0 commit comments

Comments
 (0)