Skip to content

Commit e51f25f

Browse files
committed
Implement test_eigenvalsh
1 parent 9b893ca commit e51f25f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

array_api_tests/test_linalg.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,19 @@ def test_eigh(x):
159159
# eigenvectors of x
160160

161161
@given(
162-
x=xps.arrays(dtype=xps.floating_dtypes(), shape=shapes),
162+
x=symmetric_matrices(finite=True),
163163
)
164164
def test_eigvalsh(x):
165-
# res = _array_module.linalg.eigvalsh(x)
166-
pass
165+
res = _array_module.linalg.eigvalsh(x)
166+
167+
assert res.dtype == x.dtype, "eigvalsh() did not return the correct dtype"
168+
assert res.shape == x.shape[:-1], "eigvalsh() did not return the correct shape"
169+
170+
_test_stacks(_array_module.linalg.eigvalsh, x, {}, res, dims=1)
171+
172+
# TODO: Should we test that the result is the same as eigh(x).eigenvalues?
173+
174+
# TODO: Test that res actually corresponds to the eigenvalues of x
167175

168176
@given(
169177
x=xps.arrays(dtype=xps.floating_dtypes(), shape=shapes),

0 commit comments

Comments
 (0)