aboutsummaryrefslogtreecommitdiff
path: root/test/test_solvers.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_solvers.py')
-rw-r--r--test/test_solvers.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/test/test_solvers.py b/test/test_solvers.py
index a7c175f..b049cca 100644
--- a/test/test_solvers.py
+++ b/test/test_solvers.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Contains routines to test the solvers module"""
+import pytest
import numpy as np
from numpy.typing import NDArray
@@ -27,11 +28,10 @@ def test_pivot_3() -> None:
def test_lindep_3() -> None:
"""Tests a linearly dependent system wit three variables."""
- aa = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]])
- bb = np.array([1.0, 2.0, 3.0])
- xx_expected = None
- xx_gauss = solvers.gaussian_eliminate(aa, bb)
- assert xx_expected == xx_gauss
+ with pytest.raises(ValueError):
+ aa = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]])
+ bb = np.array([1.0, 2.0, 3.0])
+ xx_gauss = solvers.gaussian_eliminate(aa, bb)
def test_lu_factorization() -> None:
@@ -45,7 +45,6 @@ def test_forward_substitution() -> None:
bb = np.array([3.0, 2.0, 1.0])
xx_result = solvers.forward_substitution(ll, bb)
xx_expected = np.array([3 / 2, 7.0 / 4.0, -6])
- print(xx_result)
assert np.allclose(xx_expected, xx_result)
def test_back_substitution() -> None:
@@ -53,5 +52,4 @@ def test_back_substitution() -> None:
bb = np.array([1.0, 2.0, 3.0])
xx_result = solvers.back_substitution(uu, bb)
xx_expected = np.array([-6, 7.0 / 4.0, 3.0 / 2.0])
- print(xx_result)
assert np.allclose(xx_expected, xx_result)