Skip to content

Commit

Permalink
more tests for coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcapriot committed Oct 10, 2024
1 parent 4efc207 commit 9350dba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pymatsolver/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class Base(ABC):
Extra keyword arguments. If there are any left here a warning will be raised.
"""

__numpy_ufunc__ = True
__array_ufunc__ = None

def __init__(
self, A, is_symmetric=None, is_positive_definite=False, is_hermitian=None, check_accuracy=False, check_rtol=1e-6, check_atol=0, accuracy_tol=None, **kwargs
):
Expand Down
17 changes: 16 additions & 1 deletion tests/test_Basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def test_basic_solve():
npt.assert_equal(Ainv @ rhs2d, rhs2d)
npt.assert_equal(Ainv @ rhs3d, rhs3d)

npt.assert_equal(rhs @ Ainv, rhs)
npt.assert_equal(rhs.T * Ainv, rhs)


# use Diagonal solver as a concrete instance of the Base to test for some errors

Expand Down Expand Up @@ -86,4 +89,16 @@ def test_errors_and_warnings():
IdentitySolver(np.full((4, 4), 1), check_rtol=0.0)

with pytest.raises(ValueError, match="check_atol must.*"):
IdentitySolver(np.full((4, 4), 1), check_atol=-1.0)
IdentitySolver(np.full((4, 4), 1), check_atol=-1.0)

with pytest.raises(ValueError, match="Expected a vector of length.*"):
Ainv = IdentitySolver(np.eye(4, 4))
Ainv @ np.ones(3)

with pytest.raises(ValueError, match="Second to last dimension should be.*"):
Ainv = IdentitySolver(np.eye(4, 4))
Ainv @ np.ones((3, 2))

with pytest.warns(FutureWarning, match="In Future pymatsolver v0.4.0, passing a vector.*"):
Ainv = IdentitySolver(np.eye(4, 4))
Ainv @ np.ones((4, 1))

0 comments on commit 9350dba

Please sign in to comment.