diff --git a/pytests/test_sparsity.py b/pytests/test_sparsity.py index c87bc690..00c7d944 100644 --- a/pytests/test_sparsity.py +++ b/pytests/test_sparsity.py @@ -362,25 +362,27 @@ def test_ISTA_FISTA_multiplerhs(par): ) def test_SPGL1(par): """Invert problem with SPGL1""" - if int(np_version[0]) < 2: - np.random.seed(42) - Aop = MatrixMult(np.random.randn(par["ny"], par["nx"])) - - x = np.zeros(par["nx"]) - x[par["nx"] // 2] = 1 - x[3] = 1 - x[par["nx"] - 4] = -1 - - x0 = ( - np.random.normal(0, 10, par["nx"]) - + par["imag"] * np.random.normal(0, 10, par["nx"]) - if par["x0"] - else None - ) - y = Aop * x - xinv = spgl1(Aop, y, x0=x0, iter_lim=5000)[0] + if int(np_version[0]) >= 2: + return - assert_array_almost_equal(x, xinv, decimal=1) + np.random.seed(42) + Aop = MatrixMult(np.random.randn(par["ny"], par["nx"])) + + x = np.zeros(par["nx"]) + x[par["nx"] // 2] = 1 + x[3] = 1 + x[par["nx"] - 4] = -1 + + x0 = ( + np.random.normal(0, 10, par["nx"]) + + par["imag"] * np.random.normal(0, 10, par["nx"]) + if par["x0"] + else None + ) + y = Aop * x + xinv = spgl1(Aop, y, x0=x0, iter_lim=5000)[0] + + assert_array_almost_equal(x, xinv, decimal=1) @pytest.mark.parametrize("par", [(par1), (par2), (par1j), (par2j)]) @@ -416,6 +418,6 @@ def test_SplitBregman(par): x0=x0 if par["x0"] else None, restart=False, show=False, - **dict(iter_lim=5, damp=1e-3) + **dict(iter_lim=5, damp=1e-3), ) assert (np.linalg.norm(x - xinv) / np.linalg.norm(x)) < 1e-1