Skip to content

Commit 940a198

Browse files
authored
Merge pull request #211 from ev-br/asarray_copy_dask
BUG: dask.array: asarray(..., copy=None) copies in dask==2024.12
2 parents ee25aae + ce4e55d commit 940a198

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
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.array(obj, dtype=dtype, copy=True)
144146
return da.from_array(obj)
145147
return obj
146148

dask-skips.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# slow and not implemented in dask
22
array_api_tests/test_linalg.py::test_matrix_power
3+
4+
# hangs on 2024.12
5+
array_api_tests/test_creation_functions.py::test_eye

tests/test_common.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ def test_asarray_copy(library):
204204
b = asarray(a, copy=None)
205205
assert is_lib_func(b)
206206
a[0] = 0.0
207-
if library == 'cupy':
207+
if library in ('cupy', 'dask.array'):
208208
# A copy is required for libraries where the default device is not CPU
209+
# dask changed behaviour of copy=None in 2024.12 to copy;
210+
# this wrapper ensures the same behaviour in older versions too.
211+
# https://github.com/dask/dask/pull/11524/
209212
assert all(b[0] == 1.0)
210213
else:
211214
assert all(b[0] == 0.0)

0 commit comments

Comments
 (0)