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