Skip to content

Commit 720b309

Browse files
committed
Sort the eigenvalues when testing stacks
1 parent ca70fbe commit 720b309

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

array_api_tests/test_linalg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,11 @@ def test_eigh(x):
251251
assert eigenvectors.dtype == x.dtype, "eigh().eigenvectors did not return the correct dtype"
252252
assert eigenvectors.shape == x.shape, "eigh().eigenvectors did not return the correct shape"
253253

254+
# The order of the eigenvectors is not specified, so make sure the same
255+
# eigenvectors are compared against each other.
254256
_test_stacks(lambda x: linalg.eigh(x).eigenvalues, x,
255-
res=eigenvalues, dims=1)
257+
res=eigenvalues, dims=1, assert_equal=lambda a, b:
258+
assert_equal(xp.sort(a), xp.sort(b)))
256259

257260
# There are equivalent ways of representing eigenvectors, and algorithms
258261
# may not give the same eigenvectors on a stack vs. a matrix.

0 commit comments

Comments
 (0)