Skip to content

Commit f178e28

Browse files
committed
green
1 parent ad6bf56 commit f178e28

File tree

6 files changed

+166
-35
lines changed

6 files changed

+166
-35
lines changed

.github/workflows/array-api-tests-dask.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ jobs:
88
with:
99
package-name: dask
1010
extra-requires: numpy
11+
pytest-extra-args: --disable-deadline

array_api_compat/common/_aliases.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ def _asarray(
329329
if (hasattr(xp, "ndarray") and isinstance(obj, xp.ndarray)) or hasattr(obj, "__array__"):
330330
if dtype is not None and obj.dtype != dtype:
331331
copy = True
332-
if copy in COPY_TRUE:
332+
# Dask arrays are immutable, so copy doesn't do anything
333+
if copy in COPY_TRUE and namespace != "dask":
333334
return xp.array(obj, copy=True, dtype=dtype)
334335
return obj
335336

array_api_compat/dask/_aliases.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
# Common aliases
3939
arange = get_xp(da)(_aliases.arange)
40+
eye = get_xp(da)(_aliases.eye)
4041

4142
from functools import partial
4243
asarray = partial(_aliases._asarray, namespace='dask')
@@ -66,8 +67,6 @@
6667
matrix_transpose = get_xp(da)(_aliases.matrix_transpose)
6768
vecdot = get_xp(da)(_aliases.vecdot)
6869

69-
70-
7170
from dask.array import (
7271
# Element wise aliases
7372
arccos as acos,
@@ -83,6 +82,5 @@
8382
power as pow,
8483
# Other
8584
concatenate as concat,
86-
8785
)
8886

array_api_compat/dask/linalg.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from dask.array.linalg import *
2+
from dask.array.linalg import __all__ as linalg_all
3+
4+
from ..common import _linalg
5+
from .._internal import get_xp
6+
from ._aliases import (matmul, matrix_transpose, tensordot, vecdot)
7+
8+
import dask.array as da
9+
10+
cross = get_xp(da)(_linalg.cross)
11+
outer = get_xp(da)(_linalg.outer)
12+
EighResult = _linalg.EighResult
13+
QRResult = _linalg.QRResult
14+
SlogdetResult = _linalg.SlogdetResult
15+
SVDResult = _linalg.SVDResult
16+
eigh = get_xp(da)(_linalg.eigh)
17+
qr = get_xp(da)(_linalg.qr)
18+
slogdet = get_xp(da)(_linalg.slogdet)
19+
svd = get_xp(da)(_linalg.svd)
20+
cholesky = get_xp(da)(_linalg.cholesky)
21+
matrix_rank = get_xp(da)(_linalg.matrix_rank)
22+
pinv = get_xp(da)(_linalg.pinv)
23+
matrix_norm = get_xp(da)(_linalg.matrix_norm)
24+
svdvals = get_xp(da)(_linalg.svdvals)
25+
vector_norm = get_xp(da)(_linalg.vector_norm)
26+
diagonal = get_xp(da)(_linalg.diagonal)
27+
trace = get_xp(da)(_linalg.trace)
28+
29+
__all__ = linalg_all + _linalg.__all__
30+
31+
del get_xp
32+
del da
33+
del linalg_all
34+
del _linalg

dask-skips.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# FFT isn't conformant
2+
array_api_tests/test_fft.py
3+
4+
# Errors with dask, also makes Dask go OOM
5+
array_api_tests/test_creation_functions.py::test_arange

dask-xfails.txt

Lines changed: 123 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,139 @@
1+
# This fails in dask
2+
# import dask.array as da
3+
# a = da.array([1]).reshape((1,1))
4+
# key = (0, slice(None, None, -1))
5+
# a[key] = da.array([1])
6+
7+
# Failing hypothesis test case
8+
#x=dask.array<zeros_like, shape=(0, 2), dtype=bool, chunksize=(0, 2), chunktype=numpy.ndarray>
9+
#| Draw 1 (key): (slice(None, None, None), slice(None, None, None))
10+
#| Draw 2 (value): dask.array<zeros_like, shape=(0, 2), dtype=bool, chunksize=(0, 2), chunktype=numpy.ndarray>
11+
12+
# TODO: this also skips test_setitem_masking unnecessarily
13+
array_api_tests/test_array_object.py::test_setitem
14+
15+
# Various indexing errors
16+
array_api_tests/test_array_object.py::test_getitem_masking
17+
18+
19+
# asarray(copy=False) is not yet implemented
20+
# copied from numpy xfails, TODO: should this pass with dask?
21+
array_api_tests/test_creation_functions.py::test_asarray_arrays
22+
23+
# zero division error, and typeerror: tuple indices must be integers or slices not tuple
24+
array_api_tests/test_creation_functions.py::test_eye
25+
126
# finfo(float32).eps returns float32 but should return float
227
array_api_tests/test_data_type_functions.py::test_finfo[float32]
328

429
# No sorting in dask
530
array_api_tests/test_has_names.py::test_has_names[sorting-argsort]
631
array_api_tests/test_has_names.py::test_has_names[sorting-sort]
32+
array_api_tests/test_sorting_functions.py::test_argsort
33+
array_api_tests/test_sorting_functions.py::test_sort
34+
array_api_tests/test_signatures.py::test_func_signature[argsort]
35+
array_api_tests/test_signatures.py::test_func_signature[sort]
736

837
# Array methods and attributes not already on np.ndarray cannot be wrapped
938
array_api_tests/test_has_names.py::test_has_names[array_method-__array_namespace__]
1039
array_api_tests/test_has_names.py::test_has_names[array_method-to_device]
1140
array_api_tests/test_has_names.py::test_has_names[array_attribute-device]
1241
array_api_tests/test_has_names.py::test_has_names[array_attribute-mT]
1342

14-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x1, x2)] - AssertionError: out[0]=0, but should be (x1 + x2[0])=65536 [__add__()]
15-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_and[__and__(x1, x2)] - hypothesis.errors.Flaky: Hypothesis test_bitwise_and(ctx=BinaryParamContext(<__and__(x1, x2)>), data=data(...)) produces unreliable results: Falsified on the ...
16-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__rshift__(x1, x2)] - hypothesis.errors.Flaky: Hypothesis test_bitwise_right_shift(ctx=BinaryParamContext(<__rshift__(x1, x2)>), data=data(...)) produces unreliable results: Falsif...
17-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_xor[bitwise_xor(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 994.44ms, which exceeds the deadline of 800.00ms
18-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_xor[__xor__(x1, x2)] - ValueError: Inferred dtype from function 'xor' was 'uint64' but got 'int16', which can't be cast using casting='same_kind'
19-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_ceil - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
20-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_divide[divide(x1, x2)] - hypothesis.errors.Flaky: Hypothesis test_divide(ctx=BinaryParamContext(<divide(x1, x2)>), data=data(...)) produces unreliable results: Falsified on the first ...
21-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_floor - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
22-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[floor_divide(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 1015.43ms, which exceeds the deadline of 800.00ms
23-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 900.99ms, which exceeds the deadline of 800.00ms
24-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater[greater(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 1106.49ms, which exceeds the deadline of 800.00ms
25-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x1, x2)] - hypothesis.errors.Flaky: Hypothesis test_greater(ctx=BinaryParamContext(<__gt__(x1, x2)>), data=data(...)) produces unreliable results: Falsified on the first...
26-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[greater_equal(x1, x2)] - hypothesis.errors.Flaky: Hypothesis test_greater_equal(ctx=BinaryParamContext(<greater_equal(x1, x2)>), data=data(...)) produces unreliable results: Falsified...
27-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x1, x2)] - hypothesis.errors.Flaky: Hypothesis test_greater_equal(ctx=BinaryParamContext(<__ge__(x1, x2)>), data=data(...)) produces unreliable results: Falsified on the...
28-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less[less(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 961.84ms, which exceeds the deadline of 800.00ms
29-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 980.68ms, which exceeds the deadline of 800.00ms
30-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[less_equal(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 1043.47ms, which exceeds the deadline of 800.00ms
31-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 1011.76ms, which exceeds the deadline of 800.00ms
32-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[multiply(x1, x2)] - AssertionError: out[0]=0, but should be (x1 * x2[0])=256 [multiply()]
33-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x1, x2)] - AssertionError: out[0]=2, but should be (x1 * x2[0])=258 [__mul__()]
34-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[subtract(x1, x2)] - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
35-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x1, x2)] - hypothesis.errors.DeadlineExceeded: Test took 1034.64ms, which exceeds the deadline of 800.00ms
36-
#FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_trunc - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
37-
38-
#FAILED array_api_tests/test_searching_functions.py::test_nonzero_zerodim_error - Failed: DID NOT RAISE <class 'Exception'>
43+
# dask doesn't return int when input is already int for ceil/floor/trunc
44+
# Use $ to denote end of regex so we don't xfail other tests accidentally
45+
array_api_tests/test_operators_and_elementwise_functions.py::test_ceil
46+
# TODO: this xfails more than it should ... (e.g. test_floor_divide works)
47+
array_api_tests/test_operators_and_elementwise_functions.py::test_floor
48+
array_api_tests/test_operators_and_elementwise_functions.py::test_trunc
49+
50+
# Dask doesn't raise an error for this test
51+
array_api_tests/test_searching_functions.py::test_nonzero_zerodim_error
3952

4053
# Fails because shape is NaN since we don't materialize it yet
41-
#FAILED array_api_tests/test_searching_functions.py::test_nonzero - AssertionError: prod(out[0].shape)=nan, but should be prod(out[0].shape)=nan
42-
#FAILED array_api_tests/test_set_functions.py::test_unique_all - AssertionError: out.indices.shape=(nan,), but should be out.values.shape=(nan,)
43-
#FAILED array_api_tests/test_set_functions.py::test_unique_counts - AssertionError: out.counts.shape=(nan,), but should be out.values.shape=(nan,)
54+
array_api_tests/test_searching_functions.py::test_nonzero
55+
array_api_tests/test_set_functions.py::test_unique_all
56+
array_api_tests/test_set_functions.py::test_unique_counts
57+
58+
# Different error but same cause as above, we're just trying to do ndindex on nan shape
59+
array_api_tests/test_set_functions.py::test_unique_inverse
60+
array_api_tests/test_set_functions.py::test_unique_values
61+
62+
# Linalg failures (signature failures/missing methods)
63+
array_api_tests/test_has_names.py::test_has_names[linalg-cross]
64+
array_api_tests/test_has_names.py::test_has_names[linalg-det]
65+
array_api_tests/test_has_names.py::test_has_names[linalg-diagonal]
66+
array_api_tests/test_has_names.py::test_has_names[linalg-eigh]
67+
array_api_tests/test_has_names.py::test_has_names[linalg-eigvalsh]
68+
array_api_tests/test_has_names.py::test_has_names[linalg-matmul]
69+
array_api_tests/test_has_names.py::test_has_names[linalg-matrix_norm]
70+
array_api_tests/test_has_names.py::test_has_names[linalg-matrix_power]
71+
array_api_tests/test_has_names.py::test_has_names[linalg-matrix_rank]
72+
array_api_tests/test_has_names.py::test_has_names[linalg-matrix_transpose]
73+
array_api_tests/test_has_names.py::test_has_names[linalg-outer]
74+
array_api_tests/test_has_names.py::test_has_names[linalg-pinv]
75+
array_api_tests/test_has_names.py::test_has_names[linalg-slogdet]
76+
array_api_tests/test_has_names.py::test_has_names[linalg-svdvals]
77+
array_api_tests/test_has_names.py::test_has_names[linalg-tensordot]
78+
array_api_tests/test_has_names.py::test_has_names[linalg-trace]
79+
array_api_tests/test_has_names.py::test_has_names[linalg-vecdot]
80+
array_api_tests/test_has_names.py::test_has_names[linalg-vector_norm]
81+
array_api_tests/test_has_names.py::test_has_names[creation-from_dlpack]
82+
array_api_tests/test_has_names.py::test_has_names[array_method-__dlpack__]
83+
array_api_tests/test_has_names.py::test_has_names[array_method-__dlpack_device__]
84+
array_api_tests/test_linalg.py::test_cross
85+
array_api_tests/test_linalg.py::test_det
86+
array_api_tests/test_linalg.py::test_diagonal
87+
array_api_tests/test_linalg.py::test_eigvalsh
88+
array_api_tests/test_linalg.py::test_matrix_norm
89+
array_api_tests/test_linalg.py::test_matrix_rank
90+
array_api_tests/test_linalg.py::test_outer
91+
array_api_tests/test_linalg.py::test_pinv
92+
array_api_tests/test_linalg.py::test_slogdet
93+
array_api_tests/test_linalg.py::test_svdvals
94+
array_api_tests/test_linalg.py::test_tensordot
95+
array_api_tests/test_linalg.py::test_trace
96+
array_api_tests/test_linalg.py::test_cholesky
97+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.cholesky]
98+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.cross]
99+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.det]
100+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.diagonal]
101+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.eigh]
102+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.eigvalsh]
103+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.matmul]
104+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.matrix_norm]
105+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.matrix_power]
106+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.matrix_rank]
107+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.matrix_transpose]
108+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.outer]
109+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.pinv]
110+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.qr]
111+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.slogdet]
112+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.svd]
113+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.svdvals]
114+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.tensordot]
115+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.trace]
116+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.vecdot]
117+
array_api_tests/test_signatures.py::test_extension_func_signature[linalg.vector_norm]
118+
# errors
119+
array_api_tests/test_linalg.py::test_matrix_power
120+
array_api_tests/test_linalg.py::test_qr
121+
array_api_tests/test_linalg.py::test_solve
122+
array_api_tests/test_linalg.py::test_svd
123+
124+
# Missing dlpack stuff
125+
array_api_tests/test_signatures.py::test_func_signature[from_dlpack]
126+
array_api_tests/test_signatures.py::test_array_method_signature[__array_namespace__]
127+
array_api_tests/test_signatures.py::test_array_method_signature[__dlpack__]
128+
array_api_tests/test_signatures.py::test_array_method_signature[__dlpack_device__]
129+
array_api_tests/test_signatures.py::test_array_method_signature[to_device]
130+
131+
# Some cases unsupported by dask
132+
array_api_tests/test_manipulation_functions.py::test_roll
133+
134+
# Dtype doesn't match (output is float32 but should be float64)
135+
array_api_tests/test_statistical_functions.py::test_prod
136+
array_api_tests/test_statistical_functions.py::test_sum
44137

45-
# Needs investigation
46-
#FAILED array_api_tests/test_set_functions.py::test_unique_inverse - TypeError: 'float' object cannot be interpreted as an integer
47-
#FAILED array_api_tests/test_set_functions.py::test_unique_values - TypeError: 'float' object cannot be interpreted as an integer
138+
# No mT on dask array
139+
array_api_tests/meta/test_hypothesis_helpers.py::test_symmetric_matrices

0 commit comments

Comments
 (0)