Skip to content

Commit f439259

Browse files
committed
Sort the results in eigvalsh before comparing
1 parent 17d93bf commit f439259

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

array_api_tests/test_linalg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ def test_eigh(x):
250250
assert eigenvectors.dtype == x.dtype, "eigh().eigenvectors did not return the correct dtype"
251251
assert eigenvectors.shape == x.shape, "eigh().eigenvectors did not return the correct shape"
252252

253-
# The order of the eigenvectors is not specified, so make sure the same
254-
# eigenvectors are compared against each other.
253+
# The order of the eigenvalues is not specified, so make sure the same
254+
# eigenvalues are compared against each other.
255255
_test_stacks(lambda x: linalg.eigh(x).eigenvalues, x,
256256
res=eigenvalues, dims=1, assert_equal=lambda a, b:
257257
assert_equal(xp.sort(a), xp.sort(b)))
@@ -274,7 +274,10 @@ def test_eigvalsh(x):
274274
assert res.dtype == x.dtype, "eigvalsh() did not return the correct dtype"
275275
assert res.shape == x.shape[:-1], "eigvalsh() did not return the correct shape"
276276

277-
_test_stacks(linalg.eigvalsh, x, res=res, dims=1)
277+
# The order of the eigenvalues is not specified, so make sure the same
278+
# eigenvalues are compared against each other.
279+
_test_stacks(linalg.eigvalsh, x, res=res, dims=1, assert_equal=lambda a,
280+
b: assert_equal(xp.sort(a), xp.sort(b)))
278281

279282
# TODO: Should we test that the result is the same as eigh(x).eigenvalues?
280283

0 commit comments

Comments
 (0)