Skip to content

Commit

Permalink
minor: revert test_solver
Browse files Browse the repository at this point in the history
  • Loading branch information
mrava87 committed Jun 16, 2024
1 parent c57bf1d commit 27f510d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
)
def test_cg(par):
"""CG with MPIBlockDiag"""
np.random.seed(42)
A = np.ones((par["ny"], par["nx"])) + par[
"imag"] * np.ones((par["ny"], par["nx"]))
Aop = MatrixMult(np.conj(A.T) @ A, dtype=par['dtype'])
Expand Down Expand Up @@ -127,7 +126,7 @@ def test_cg(par):
x0 = None
y1 = BDiag * x_global
xinv1 = pylops.cg(BDiag, y1, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0]
assert_allclose(xinv_array, xinv1, rtol=1e-12)
assert_allclose(xinv_array, xinv1, rtol=1e-14)


@pytest.mark.mpi(min_size=2)
Expand All @@ -136,7 +135,6 @@ def test_cg(par):
)
def test_cgls(par):
"""CGLS with MPIBlockDiag"""
np.random.seed(42)
A = np.ones((par["ny"], par["nx"])) + par[
"imag"] * np.ones((par["ny"], par["nx"]))
Aop = MatrixMult(np.conj(A.T) @ A + 1e-5 * np.eye(par["nx"], dtype=par['dtype']),
Expand Down Expand Up @@ -175,7 +173,7 @@ def test_cgls(par):
x0 = None
y1 = BDiag * x_global
xinv1 = pylops.cgls(BDiag, y1, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0]
assert_allclose(xinv_array, xinv1, rtol=1e-12)
assert_allclose(xinv_array, xinv1, rtol=1e-14)


@pytest.mark.mpi(min_size=2)
Expand All @@ -184,7 +182,6 @@ def test_cgls(par):
)
def test_cgls_broadcastdata(par):
"""CGLS with broadcasted data vector"""
np.random.seed(42)
A = (rank + 1) * np.ones((par["ny"], par["nx"])) + (rank + 2) * par[
"imag"
] * np.ones((par["ny"], par["nx"]))
Expand Down Expand Up @@ -222,7 +219,7 @@ def test_cgls_broadcastdata(par):
x0 = None
y1 = Hstack @ x_global
xinv1 = pylops.cgls(Hstack, y1, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0]
assert_allclose(xinv_array, xinv1, rtol=1e-12)
assert_allclose(xinv_array, xinv1, rtol=1e-14)


@pytest.mark.mpi(min_size=2)
Expand All @@ -231,7 +228,6 @@ def test_cgls_broadcastdata(par):
)
def test_cgls_broadcastmodel(par):
"""CGLS with broadcasted model vector"""
np.random.seed(42)
A = np.ones((par["ny"], par["nx"])) + par[
"imag"] * np.ones((par["ny"], par["nx"]))
Aop = MatrixMult(np.conj(A.T) @ A + 1e-5 * np.eye(par["nx"], dtype=par['dtype']),
Expand Down Expand Up @@ -272,7 +268,7 @@ def test_cgls_broadcastmodel(par):
x0 = None
y1 = Vstack @ x_global
xinv1 = pylops.cgls(Vstack, y1, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0]
assert_allclose(xinv_array, xinv1, rtol=1e-12)
assert_allclose(xinv_array, xinv1, rtol=1e-14)


@pytest.mark.mpi(min_size=2)
Expand All @@ -281,7 +277,6 @@ def test_cgls_broadcastmodel(par):
)
def test_cg_stacked(par):
"""CG with MPIStackedBlockDiag"""
np.random.seed(42)
A = np.ones((par["ny"], par["nx"])) + par[
"imag"] * np.ones((par["ny"], par["nx"]))
Aop = MatrixMult(np.conj(A.T) @ A + 1e-5 * np.eye(par["nx"], dtype=par['dtype']),
Expand Down Expand Up @@ -336,7 +331,7 @@ def test_cg_stacked(par):
x0 = None
y1 = StackedBDiag * x_global
xinv1 = pylops.cg(StackedBDiag, y1, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0]
assert_allclose(xinv_array, xinv1, rtol=1e-12)
assert_allclose(xinv_array, xinv1, rtol=1e-14)


@pytest.mark.mpi(min_size=2)
Expand All @@ -345,7 +340,6 @@ def test_cg_stacked(par):
)
def test_cgls_stacked(par):
"""CGLS with MPIStackedBlockDiag"""
np.random.seed(42)
A = np.ones((par["ny"], par["nx"])) + par[
"imag"] * np.ones((par["ny"], par["nx"]))
Aop = MatrixMult(np.conj(A.T) @ A + 1e-5 * np.eye(par["nx"], dtype=par['dtype']),
Expand Down Expand Up @@ -402,4 +396,4 @@ def test_cgls_stacked(par):
x0 = None
y1 = StackedBDiag * x_global
xinv1 = pylops.cgls(StackedBDiag, y1, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0]
assert_allclose(xinv_array, xinv1, rtol=1e-12)
assert_allclose(xinv_array, xinv1, rtol=1e-14)

0 comments on commit 27f510d

Please sign in to comment.