From c3e5a278b46ac422d0a4045ea663a1571c9fabd9 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 10:17:58 +0100 Subject: [PATCH 1/9] fix: adapted tests for scipy v1.14 --- environment-dev-arm.yml | 2 +- environment-dev.yml | 2 +- environment.yml | 2 +- pyproject.toml | 2 +- pytests/test_solver.py | 8 ++++---- requirements-dev.txt | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/environment-dev-arm.yml b/environment-dev-arm.yml index 466d4c62..2415ddbf 100755 --- a/environment-dev-arm.yml +++ b/environment-dev-arm.yml @@ -8,7 +8,7 @@ dependencies: - python>=3.6.4 - pip - numpy>=1.21.0,<2.0.0 - - scipy>=1.4.0,<=1.13.0 + - scipy>=1.14.0 - pytorch>=1.2.0 - cpuonly - pyfftw diff --git a/environment-dev.yml b/environment-dev.yml index 8f18dc48..103aef0f 100755 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -8,7 +8,7 @@ dependencies: - python>=3.6.4 - pip - numpy>=1.21.0,<2.0.0 - - scipy>=1.4.0,<=1.13.0 + - scipy>=1.14.0 - pytorch>=1.2.0 - cpuonly - pyfftw diff --git a/environment.yml b/environment.yml index ce64365c..43df259a 100755 --- a/environment.yml +++ b/environment.yml @@ -4,4 +4,4 @@ channels: dependencies: - python>=3.6.4 - numpy>=1.21.0,<2.0.0 - - scipy>=1.4.0,<=1.13.0 + - scipy>=1.14.0 diff --git a/pyproject.toml b/pyproject.toml index 7c3f7cc2..86bcb201 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ classifiers = [ ] dependencies = [ "numpy >= 1.21.0 , < 2.0.0", - "scipy >= 1.4.0 , <= 1.13.0", + "scipy >= 1.14.0", ] dynamic = ["version"] diff --git a/pytests/test_solver.py b/pytests/test_solver.py index ba32f79b..dd182544 100644 --- a/pytests/test_solver.py +++ b/pytests/test_solver.py @@ -86,7 +86,7 @@ def test_cg(par): x0 = None y = Aop * x - xinv = cg(Aop, y, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0] + xinv = cg(Aop, y, x0=x0, niter=par["nx"], atol=1e-5, show=True)[0] assert_array_almost_equal(x, xinv, decimal=4) @@ -114,7 +114,7 @@ def test_cg_ndarray(par): x0 = None y = Aop * x - xinv = cg(Aop, y, x0=x0, niter=2 * x.size, tol=1e-5, show=True)[0] + xinv = cg(Aop, y, x0=x0, niter=2 * x.size, atol=1e-5, show=True)[0] assert xinv.shape == x.shape assert_array_almost_equal(x, xinv, decimal=4) @@ -143,7 +143,7 @@ def test_cg_forceflat(par): x0 = None y = Aop * x - xinv = cg(Aop, y, x0=x0, niter=2 * x.size, tol=1e-5, show=True)[0] + xinv = cg(Aop, y, x0=x0, niter=2 * x.size, atol=1e-5, show=True)[0] assert xinv.shape == x.ravel().shape assert_array_almost_equal(x.ravel(), xinv, decimal=4) @@ -169,7 +169,7 @@ def test_cgls(par): x0 = None y = Aop * x - xinv = cgls(Aop, y, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0] + xinv = cgls(Aop, y, x0=x0, niter=par["nx"], atol=1e-5, show=True)[0] assert_array_almost_equal(x, xinv, decimal=4) diff --git a/requirements-dev.txt b/requirements-dev.txt index 6ec1e0bb..49ba9f05 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ numpy>=1.21.0,<2.0.0 -scipy>=1.4.0,<=1.13.0 +scipy>=1.14.0 --extra-index-url https://download.pytorch.org/whl/cpu torch>=1.2.0 numba From 771010f3ba3b44350eb6ef554e4eae34073da137 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 10:26:44 +0100 Subject: [PATCH 2/9] minor: fix again tol --- pytests/test_solver.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pytests/test_solver.py b/pytests/test_solver.py index dd182544..ba32f79b 100644 --- a/pytests/test_solver.py +++ b/pytests/test_solver.py @@ -86,7 +86,7 @@ def test_cg(par): x0 = None y = Aop * x - xinv = cg(Aop, y, x0=x0, niter=par["nx"], atol=1e-5, show=True)[0] + xinv = cg(Aop, y, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0] assert_array_almost_equal(x, xinv, decimal=4) @@ -114,7 +114,7 @@ def test_cg_ndarray(par): x0 = None y = Aop * x - xinv = cg(Aop, y, x0=x0, niter=2 * x.size, atol=1e-5, show=True)[0] + xinv = cg(Aop, y, x0=x0, niter=2 * x.size, tol=1e-5, show=True)[0] assert xinv.shape == x.shape assert_array_almost_equal(x, xinv, decimal=4) @@ -143,7 +143,7 @@ def test_cg_forceflat(par): x0 = None y = Aop * x - xinv = cg(Aop, y, x0=x0, niter=2 * x.size, atol=1e-5, show=True)[0] + xinv = cg(Aop, y, x0=x0, niter=2 * x.size, tol=1e-5, show=True)[0] assert xinv.shape == x.ravel().shape assert_array_almost_equal(x.ravel(), xinv, decimal=4) @@ -169,7 +169,7 @@ def test_cgls(par): x0 = None y = Aop * x - xinv = cgls(Aop, y, x0=x0, niter=par["nx"], atol=1e-5, show=True)[0] + xinv = cgls(Aop, y, x0=x0, niter=par["nx"], tol=1e-5, show=True)[0] assert_array_almost_equal(x, xinv, decimal=4) From 2b8b71a616321645c0a33532b2dc200932c204f5 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 10:36:49 +0100 Subject: [PATCH 3/9] fix: bump minimum scipy to v1.11 --- environment-dev-arm.yml | 2 +- environment-dev.yml | 2 +- pyproject.toml | 2 +- requirements-dev.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/environment-dev-arm.yml b/environment-dev-arm.yml index 2415ddbf..a84f7199 100755 --- a/environment-dev-arm.yml +++ b/environment-dev-arm.yml @@ -8,7 +8,7 @@ dependencies: - python>=3.6.4 - pip - numpy>=1.21.0,<2.0.0 - - scipy>=1.14.0 + - scipy>=1.11.0 - pytorch>=1.2.0 - cpuonly - pyfftw diff --git a/environment-dev.yml b/environment-dev.yml index 103aef0f..5922a184 100755 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -8,7 +8,7 @@ dependencies: - python>=3.6.4 - pip - numpy>=1.21.0,<2.0.0 - - scipy>=1.14.0 + - scipy>=1.11.0 - pytorch>=1.2.0 - cpuonly - pyfftw diff --git a/pyproject.toml b/pyproject.toml index 86bcb201..05604374 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ classifiers = [ ] dependencies = [ "numpy >= 1.21.0 , < 2.0.0", - "scipy >= 1.14.0", + "scipy >= 1.11.0", ] dynamic = ["version"] diff --git a/requirements-dev.txt b/requirements-dev.txt index 49ba9f05..ef8bbc55 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ numpy>=1.21.0,<2.0.0 -scipy>=1.14.0 +scipy>=1.11.0 --extra-index-url https://download.pytorch.org/whl/cpu torch>=1.2.0 numba From 02fa492568faa9ff30ea805d1b60ce31c7c63d2b Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 10:39:39 +0100 Subject: [PATCH 4/9] minor: bump minimum python to 3.9 --- .github/workflows/build.yaml | 2 +- docs/source/installation.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 88aba86f..08e2ec8c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,7 +7,7 @@ jobs: strategy: matrix: platform: [ ubuntu-latest, macos-13 ] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] runs-on: ${{ matrix.platform }} steps: diff --git a/docs/source/installation.rst b/docs/source/installation.rst index a9c2d52a..8de4c0be 100755 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -9,7 +9,7 @@ The PyLops project strives to create a library that is easy to install in any environment and has a very limited number of dependencies. Required dependencies are limited to: -* Python 3.8 or greater +* Python 3.9 or greater * `NumPy `_ * `SciPy `_ From 5ed015a2e2a0dacd29c85bba19dfbef31de5af53 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 10:53:48 +0100 Subject: [PATCH 5/9] build: remove python 3.12 --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 08e2ec8c..a0887beb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,7 +7,7 @@ jobs: strategy: matrix: platform: [ ubuntu-latest, macos-13 ] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11"] runs-on: ${{ matrix.platform }} steps: From 95c62ff9d8faaeaa8ed2a9e4a49d9ea82e7fd76b Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 11:23:24 +0100 Subject: [PATCH 6/9] test: change tol to atol in test_leastsquares --- pytests/test_leastsquares.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pytests/test_leastsquares.py b/pytests/test_leastsquares.py index c0ee9944..84013a27 100755 --- a/pytests/test_leastsquares.py +++ b/pytests/test_leastsquares.py @@ -93,12 +93,12 @@ def test_NormalEquationsInversion(par): # normal equations with regularization xinv = normal_equations_inversion( - Gop, y, [Reg], epsI=1e-5, epsRs=[1e-8], x0=x0, **dict(maxiter=200, tol=1e-10) + Gop, y, [Reg], epsI=1e-5, epsRs=[1e-8], x0=x0, **dict(maxiter=200, atol=1e-10) )[0] assert_array_almost_equal(x, xinv, decimal=3) # normal equations with weight xinv = normal_equations_inversion( - Gop, y, None, Weight=Weigth, epsI=1e-5, x0=x0, **dict(maxiter=200, tol=1e-10) + Gop, y, None, Weight=Weigth, epsI=1e-5, x0=x0, **dict(maxiter=200, atol=1e-10) )[0] assert_array_almost_equal(x, xinv, decimal=3) # normal equations with weight and small regularization @@ -110,7 +110,7 @@ def test_NormalEquationsInversion(par): epsI=1e-5, epsRs=[1e-8], x0=x0, - **dict(maxiter=200, tol=1e-10) + **dict(maxiter=200, atol=1e-10) )[0] assert_array_almost_equal(x, xinv, decimal=3) # normal equations with weight and small normal regularization @@ -123,7 +123,7 @@ def test_NormalEquationsInversion(par): epsI=1e-5, epsNRs=[1e-8], x0=x0, - **dict(maxiter=200, tol=1e-10) + **dict(maxiter=200, atol=1e-10) )[0] assert_array_almost_equal(x, xinv, decimal=3) @@ -192,7 +192,7 @@ def test_WeightedInversion(par): y = Gop * x xne = normal_equations_inversion( - Gop, y, None, Weight=Weigth, **dict(maxiter=5, tol=1e-10) + Gop, y, None, Weight=Weigth, **dict(maxiter=5, atol=1e-10) )[0] xreg = regularized_inversion( Gop, y, None, Weight=Weigth1, **dict(damp=0, iter_lim=5, show=0) From 2a94687e292830a7ef688657c971d940058414a5 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 11:57:22 +0100 Subject: [PATCH 7/9] test: fix dense extraction in scipy sparse --- pytests/test_linearoperator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytests/test_linearoperator.py b/pytests/test_linearoperator.py index e6b4fd58..6673b2b7 100755 --- a/pytests/test_linearoperator.py +++ b/pytests/test_linearoperator.py @@ -122,7 +122,7 @@ def test_sparse(par): D = np.diag(diag) Dop = Diagonal(diag, dtype=par["dtype"]) S = Dop.tosparse() - assert_array_equal(S.A, D) + assert_array_equal(S.toarray(), D) @pytest.mark.parametrize("par", [(par1), (par2), (par1j)]) From ec8258917a286c7c9f3964a44626f2e83ae9cd8c Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 14:10:50 +0100 Subject: [PATCH 8/9] fix: change atol behaviour for cg --- pylops/optimization/cls_leastsquares.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pylops/optimization/cls_leastsquares.py b/pylops/optimization/cls_leastsquares.py index a9e20fec..44e6cec1 100644 --- a/pylops/optimization/cls_leastsquares.py +++ b/pylops/optimization/cls_leastsquares.py @@ -219,7 +219,7 @@ def run( and cupy `data`, respectively) .. note:: - When user does not supply ``atol``, it is set to "legacy". + When user supplies ``tol`` this is set to ``atol``. Returns ------- @@ -238,8 +238,9 @@ def run( if x is not None: self.y_normal = self.y_normal - self.Op_normal.matvec(x) if engine == "scipy" and self.ncp == np: - if "atol" not in kwargs_solver: - kwargs_solver["atol"] = "legacy" + if "tol" in kwargs_solver: + kwargs_solver["atol"] = kwargs_solver["tol"] + kwargs_solver.pop("tol") xinv, istop = sp_cg(self.Op_normal, self.y_normal, **kwargs_solver) elif engine == "pylops" or self.ncp != np: if show: From 3d0b2226a299cdefc33530745d6385e95db4864f Mon Sep 17 00:00:00 2001 From: mrava87 Date: Tue, 2 Jul 2024 23:24:52 +0100 Subject: [PATCH 9/9] build: bump azure pipelines python to 3.9 --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ef5306bb..00db3746 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -26,7 +26,7 @@ jobs: # steps: # - task: UsePythonVersion@0 # inputs: -# versionSpec: '3.7' +# versionSpec: '3.9' # architecture: 'x64' # # - script: | @@ -55,7 +55,7 @@ jobs: steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.8' + versionSpec: '3.9' architecture: 'x64' - script: | @@ -84,7 +84,7 @@ jobs: steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.8' + versionSpec: '3.9' architecture: 'x64' - script: |