Skip to content

Commit 0b41f77

Browse files
committed
Implement test_inv()
1 parent c6fd6b6 commit 0b41f77

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

array_api_tests/test_linalg.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from .array_helpers import assert_exactly_equal, ndindex, asarray
2020
from .hypothesis_helpers import (xps, dtypes, shapes, kwargs, matrix_shapes,
2121
square_matrix_shapes, symmetric_matrices,
22-
positive_definite_matrices, MAX_ARRAY_SIZE)
22+
positive_definite_matrices, MAX_ARRAY_SIZE,
23+
invertible_matrices)
2324

2425
from . import _array_module
2526

@@ -169,12 +170,16 @@ def test_eigvalsh(x):
169170

170171
# TODO: Test that res actually corresponds to the eigenvalues of x
171172

172-
@given(
173-
x=xps.arrays(dtype=xps.floating_dtypes(), shape=shapes),
174-
)
173+
@given(x=invertible_matrices())
175174
def test_inv(x):
176-
# res = _array_module.linalg.inv(x)
177-
pass
175+
res = _array_module.linalg.inv(x)
176+
177+
assert res.shape == x.shape, "inv() did not return the correct shape"
178+
assert res.dtype == x.dtype, "inv() did not return the correct dtype"
179+
180+
_test_stacks(_array_module.linalg.inv, x, {}, res)
181+
182+
# TODO: Test that the result is actually the inverse
178183

179184
@given(
180185
x1=xps.arrays(dtype=xps.floating_dtypes(), shape=shapes),

0 commit comments

Comments
 (0)