Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: dask.array: asarray(..., copy=None) copies in dask==2024.12 #211

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.array(obj, dtype=dtype, copy=True)
return da.from_array(obj)
return obj

Expand Down
3 changes: 3 additions & 0 deletions dask-skips.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# slow and not implemented in dask
array_api_tests/test_linalg.py::test_matrix_power

# hangs on 2024.12
array_api_tests/test_creation_functions.py::test_eye
5 changes: 4 additions & 1 deletion tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ def test_asarray_copy(library):
b = asarray(a, copy=None)
assert is_lib_func(b)
a[0] = 0.0
if library == 'cupy':
if library in ('cupy', 'dask.array'):
# A copy is required for libraries where the default device is not CPU
# dask changed behaviour of copy=None in 2024.12 to copy;
# this wrapper ensures the same behaviour in older versions too.
# https://github.com/dask/dask/pull/11524/
assert all(b[0] == 1.0)
else:
assert all(b[0] == 0.0)
Loading