|
23 | 23 |
|
24 | 24 | from scipy.conftest import array_api_compatible
|
25 | 25 | skip_xp_backends = pytest.mark.skip_xp_backends
|
| 26 | +xfail_xp_backends = pytest.mark.xfail_xp_backends |
26 | 27 | pytestmark = [array_api_compatible, pytest.mark.usefixtures("skip_xp_backends"),
|
27 | 28 | skip_xp_backends(cpu_only=True, exceptions=['cupy', 'jax.numpy'],)]
|
28 | 29 |
|
@@ -364,10 +365,9 @@ def test_label_output_dtype(xp):
|
364 | 365 | assert output.dtype == t
|
365 | 366 |
|
366 | 367 |
|
| 368 | +@xfail_xp_backends('dask.array', reason='Dask does not raise') |
| 369 | +@xfail_xp_backends('jax.numpy', reason='JAX does not raise') |
367 | 370 | def test_label_output_wrong_size(xp):
|
368 |
| - if is_jax(xp): |
369 |
| - pytest.xfail("JAX does not raise") |
370 |
| - |
371 | 371 | data = xp.ones([5])
|
372 | 372 | for t in types:
|
373 | 373 | dtype = getattr(xp, t)
|
@@ -568,7 +568,7 @@ def test_value_indices03(xp):
|
568 | 568 | assert list(vi.keys()) == list(trueKeys)
|
569 | 569 | for k in [int(x) for x in trueKeys]:
|
570 | 570 | trueNdx = xp.nonzero(a == k, **nnz_kwd)
|
571 |
| - assert len(vi[k]) == len(trueNdx) |
| 571 | + assert vi[k].shape[0] == trueNdx.shape[0] |
572 | 572 | for vik, true_vik in zip(vi[k], trueNdx):
|
573 | 573 | xp_assert_equal(vik, true_vik)
|
574 | 574 |
|
@@ -771,6 +771,7 @@ def test_minimum03(xp):
|
771 | 771 | assert_almost_equal(output, xp.asarray(2.0), check_0d=False)
|
772 | 772 |
|
773 | 773 |
|
| 774 | +@skip_xp_backends('dask.array', reason="no argsort in Dask") |
774 | 775 | def test_minimum04(xp):
|
775 | 776 | labels = xp.asarray([[1, 2], [2, 3]])
|
776 | 777 | for type in types:
|
@@ -810,6 +811,7 @@ def test_maximum03(xp):
|
810 | 811 | assert_almost_equal(output, xp.asarray(4.0), check_0d=False)
|
811 | 812 |
|
812 | 813 |
|
| 814 | +@skip_xp_backends('dask.array', reason="no argsort in Dask") |
813 | 815 | def test_maximum04(xp):
|
814 | 816 | labels = xp.asarray([[1, 2], [2, 3]])
|
815 | 817 | for type in types:
|
@@ -1058,6 +1060,7 @@ def test_minimum_position06(xp):
|
1058 | 1060 | assert output == (0, 1)
|
1059 | 1061 |
|
1060 | 1062 |
|
| 1063 | +@skip_xp_backends('dask.array', reason="no argsort in Dask") |
1061 | 1064 | def test_minimum_position07(xp):
|
1062 | 1065 | labels = xp.asarray([1, 2, 3, 4])
|
1063 | 1066 | for type in types:
|
@@ -1123,6 +1126,7 @@ def test_maximum_position05(xp):
|
1123 | 1126 | assert output == (0, 0)
|
1124 | 1127 |
|
1125 | 1128 |
|
| 1129 | +@skip_xp_backends('dask.array', reason="no argsort in Dask") |
1126 | 1130 | def test_maximum_position06(xp):
|
1127 | 1131 | labels = xp.asarray([1, 2, 0, 4])
|
1128 | 1132 | for type in types:
|
@@ -1187,6 +1191,7 @@ def test_extrema02(xp):
|
1187 | 1191 | assert output1 == (output2, output3, output4, output5)
|
1188 | 1192 |
|
1189 | 1193 |
|
| 1194 | +@skip_xp_backends('dask.array', reason="no argsort in Dask") |
1190 | 1195 | def test_extrema03(xp):
|
1191 | 1196 | labels = xp.asarray([[1, 2], [2, 3]])
|
1192 | 1197 | for type in types:
|
@@ -1215,6 +1220,7 @@ def test_extrema03(xp):
|
1215 | 1220 | assert output1[3] == output5
|
1216 | 1221 |
|
1217 | 1222 |
|
| 1223 | +@skip_xp_backends('dask.array', reason="no argsort in Dask") |
1218 | 1224 | def test_extrema04(xp):
|
1219 | 1225 | labels = xp.asarray([1, 2, 0, 4])
|
1220 | 1226 | for type in types:
|
@@ -1588,7 +1594,8 @@ def test_watershed_ift08(self, xp):
|
1588 | 1594 | @skip_xp_backends("cupy", reason="no watershed_ift on CuPy" )
|
1589 | 1595 | def test_watershed_ift09(self, xp):
|
1590 | 1596 | # Test large cost. See gh-19575
|
1591 |
| - data = xp.asarray([[xp.iinfo(xp.uint16).max, 0], |
| 1597 | + xp_test = array_namespace(xp.empty(0)) # dask.array needs iinfo |
| 1598 | + data = xp.asarray([[xp_test.iinfo(xp.uint16).max, 0], |
1592 | 1599 | [0, 0]], dtype=xp.uint16)
|
1593 | 1600 | markers = xp.asarray([[1, 0],
|
1594 | 1601 | [0, 0]], dtype=xp.int8)
|
|
0 commit comments