Skip to content

Commit 17d93bf

Browse files
committed
Merge branch 'more-linalg2' of github.com:asmeurer/array-api-tests into more-linalg2
2 parents b3fb4ec + 720b309 commit 17d93bf

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

array_api_tests/array_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def allclose(x, y, rel_tol=0.25, abs_tol=1, return_indices=False):
171171
return False
172172
return True
173173

174-
def assert_allclose(x, y, rel_tol=0.25, abs_tol=1):
174+
def assert_allclose(x, y, rel_tol=1, abs_tol=0.):
175175
"""
176176
Test that x and y are approximately equal to each other.
177177

array_api_tests/test_linalg.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,18 @@ 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.
253255
_test_stacks(lambda x: linalg.eigh(x).eigenvalues, x,
254-
res=eigenvalues, dims=1)
255-
_test_stacks(lambda x: linalg.eigh(x).eigenvectors, x,
256-
res=eigenvectors, dims=2)
256+
res=eigenvalues, dims=1, assert_equal=lambda a, b:
257+
assert_equal(xp.sort(a), xp.sort(b)))
258+
259+
# There are equivalent ways of representing eigenvectors, and algorithms
260+
# may not give the same eigenvectors on a stack vs. a matrix.
261+
# TODO: Test that eigenvectors are orthonormal.
262+
263+
# _test_stacks(lambda x: linalg.eigh(x).eigenvectors, x,
264+
# res=eigenvectors, dims=2)
257265

258266
# TODO: Test that res actually corresponds to the eigenvalues and
259267
# eigenvectors of x

0 commit comments

Comments
 (0)