diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index ee2d88c0..df8fede8 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -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 diff --git a/dask-skips.txt b/dask-skips.txt index 63a09e4b..f4c0c282 100644 --- a/dask-skips.txt +++ b/dask-skips.txt @@ -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 diff --git a/tests/test_common.py b/tests/test_common.py index e1cfa9eb..6bf55618 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -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)