Skip to content

Commit

Permalink
Merge pull request scipy#20098 from lucascolley/xp-pytest
Browse files Browse the repository at this point in the history
MAINT: minor array API skip improvements
  • Loading branch information
tylerjereddy authored Feb 17, 2024
2 parents 1db4966 + 02a8f43 commit 24ecfe9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/source/dev/api-dev/array_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ The following is an example using the markers::
b = xp.asarray([0, 2, 5])
toto(a, b)
...
@pytest.mark.skip_if_array_api('numpy.array_api', 'cupy',
@pytest.mark.skip_if_array_api('array_api_strict', 'cupy',
reasons=['skip reason 1',
'skip reason 2',])
@pytest.mark.usefixtures("skip_if_array_api")
Expand Down
20 changes: 10 additions & 10 deletions scipy/cluster/tests/test_vq.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def test_whiten_not_finite(self, xp):
[0.45067590, 0.45464607]])
assert_raises(ValueError, whiten, obs)

@pytest.mark.xfail(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
@pytest.mark.skipif(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
def test_whiten_not_finite_matrix(self, xp):
for bad_value in np.nan, np.inf, -np.inf:
obs = matrix([[0.98744510, bad_value],
Expand All @@ -141,8 +141,8 @@ def test_py_vq(self, xp):
xp_assert_equal(label1, xp.asarray(LABEL1, dtype=xp.int64),
check_dtype=False)

@pytest.mark.xfail(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
@pytest.mark.skipif(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
def test_py_vq_matrix(self, xp):
initc = np.concatenate([[X[0]], [X[1]], [X[2]]])
# label1.dtype varies between int32 and int64 over platforms
Expand All @@ -156,8 +156,8 @@ def test_vq(self, xp):
assert_array_equal(label1, LABEL1)
_, _ = vq(xp.asarray(X), xp.asarray(initc))

@pytest.mark.xfail(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
@pytest.mark.skipif(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
def test_vq_matrix(self, xp):
initc = np.concatenate([[X[0]], [X[1]], [X[2]]])
label1, _ = _vq.vq(matrix(X), matrix(initc))
Expand Down Expand Up @@ -254,8 +254,8 @@ def test_kmeans_simple(self, xp):
code1 = kmeans(xp.asarray(X), xp.asarray(initc), iter=1)[0]
xp_assert_close(code1, xp.asarray(CODET2))

@pytest.mark.xfail(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
@pytest.mark.skipif(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
def test_kmeans_simple_matrix(self, xp):
np.random.seed(54321)
initc = np.concatenate([[X[0]], [X[1]], [X[2]]])
Expand Down Expand Up @@ -289,8 +289,8 @@ def test_kmeans2_simple(self, xp):
xp_assert_close(code1, xp.asarray(CODET1))
xp_assert_close(code2, xp.asarray(CODET2))

@pytest.mark.xfail(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
@pytest.mark.skipif(SCIPY_ARRAY_API,
reason='`np.matrix` unsupported in array API mode')
def test_kmeans2_simple_matrix(self, xp):
np.random.seed(12345678)
initc = xp.asarray(np.concatenate([[X[0]], [X[1]], [X[2]]]))
Expand Down

0 comments on commit 24ecfe9

Please sign in to comment.