From 0226404d9af7784c0f1e1144c983ae7ecd37e2c0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:46:14 +0530 Subject: [PATCH 01/30] Add some relevant files and venvs to ignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index d1c72e2d9..e09527154 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__ *.py[co] *.pyd *.so +.DS_Store # Packages *.egg @@ -32,6 +33,12 @@ cythonize.dat pywt/version.py build.log +# Virtual environments +.env/ +env/ +venv/ +.venv/ + # asv files asv/env asv/html From a05ab895e7eabc5244fcb3a64d8b38e52be8ae70 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:46:50 +0530 Subject: [PATCH 02/30] Clarify + assert correct Python version lower bounds --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 79f24f583..fd1aec91c 100644 --- a/README.rst +++ b/README.rst @@ -65,7 +65,7 @@ For more usage examples see the `demo`_ directory in the source package. Installation ------------ -PyWavelets supports `Python`_ >=3.7, and is only dependent on `NumPy`_ +PyWavelets supports `Python`_ >=3.9, and is only dependent on `NumPy`_ (supported versions are currently ``>= 1.14.6``). To pass all of the tests, `Matplotlib`_ is also required. `SciPy`_ is also an optional dependency. When present, FFT-based continuous wavelet transforms will use FFTs from SciPy From 05805797ad9d5ae546408aaa6d7a1c45608d64ee Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 20 Feb 2024 21:58:12 +0530 Subject: [PATCH 03/30] Add workflow for testing WASM distribution --- .github/workflows/emscripten.yml | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/emscripten.yml diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml new file mode 100644 index 000000000..fd5068fae --- /dev/null +++ b/.github/workflows/emscripten.yml @@ -0,0 +1,60 @@ +name: Test Pyodide build for PyWavelets + +# TODO: uncomment after testing +on: + push: + # branches: + # - master + # - v1.** + pull_request: + # branches: + # - master + # - v1.** + workflow_dispatch: + schedule: + - cron: '0 3 * * *' + +jobs: + build_wasm_emscripten: + runs-on: ubuntu-latest + # Uncomment the following line to test changes on a fork + # if: github.repository == 'PyWavelets/pywt' + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + id: setup-python + uses: actions/setup-python@v2 + with: + python-version: '3.11.2' + + - name: Install prerequisites + run: | + python -m pip install pyodide-build "pydantic<2" + echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV + + - name: Set up Emscripten toolchain + uses: mymindstorm/setup-emscripten@v14 + with: + version: ${{ env.EMSCRIPTEN_VERSION }} + actions-cache-folder: emsdk-cache + + - name: Set up Node.js + uses: actions/setup-node@v4.0.2 + with: + node-version: '18' + + - name: Build PyWavelets + run: | + pyodide build + + - name: Install and test wheel + run: | + pyodide venv .venv-pyodide + source .venv-pyodide/bin/activate + pip install dist/*.whl + pushd demo + pip install matplotlib pytest + python -c "import pywt; print(pywt.__version__)" + pytest --pyargs pywt From a2ed0675b749376a0a8141491e42b4b2ac2c8387 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:53:24 +0530 Subject: [PATCH 04/30] For now, skip tests that use `concurrent.futures` --- pywt/_pytest.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pywt/_pytest.py b/pywt/_pytest.py index cfc9f0590..4f671dd1e 100644 --- a/pywt/_pytest.py +++ b/pywt/_pytest.py @@ -1,6 +1,7 @@ """common test-related code.""" import os import sys +import platform import multiprocessing import numpy as np import pytest @@ -18,16 +19,16 @@ ] try: - if sys.version_info[0] == 2: - import futures - else: - from concurrent import futures + from concurrent import futures max_workers = multiprocessing.cpu_count() futures_available = True -except ImportError: +# Check if running on Emscripten/WASM, and skip tests that require concurrency. +# Relevant issue: https://github.com/pyodide/pyodide/issues/237 +except ImportError or (platform.machine() in ["wasm32", "wasm64"]): futures_available = False futures = None + # check if pymatbridge + MATLAB tests should be run matlab_result_dict_dwt = None matlab_result_dict_cwt = None @@ -57,7 +58,7 @@ matlab_result_dict_dwt = np.load(matlab_data_file_dwt) uses_futures = pytest.mark.skipif( - not futures_available, reason='futures not available') + not futures_available, reason='futures not available, possibly running on Emscripten/WASM.') uses_matlab = pytest.mark.skipif( matlab_missing, reason='pymatbridge and/or Matlab not available') uses_pymatbridge = pytest.mark.skipif( From 198fc92f71986bc06479841dff89a4109b188085 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:16:10 +0530 Subject: [PATCH 05/30] Enable coloured output for GitHub Actions --- .github/workflows/emscripten.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index fd5068fae..896b66091 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -14,6 +14,9 @@ on: schedule: - cron: '0 3 * * *' +env: + FORCE_COLOR: 3 + jobs: build_wasm_emscripten: runs-on: ubuntu-latest From 80ae120073072796fbff7ae0f9eed783155e6703 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:16:35 +0530 Subject: [PATCH 06/30] Use different check for Emscripten Python interpreter --- pywt/_pytest.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pywt/_pytest.py b/pywt/_pytest.py index 4f671dd1e..13512afff 100644 --- a/pywt/_pytest.py +++ b/pywt/_pytest.py @@ -1,7 +1,6 @@ """common test-related code.""" import os import sys -import platform import multiprocessing import numpy as np import pytest @@ -24,7 +23,7 @@ futures_available = True # Check if running on Emscripten/WASM, and skip tests that require concurrency. # Relevant issue: https://github.com/pyodide/pyodide/issues/237 -except ImportError or (platform.machine() in ["wasm32", "wasm64"]): +except ImportError or (sys.platform == "emscripten"): futures_available = False futures = None @@ -58,7 +57,7 @@ matlab_result_dict_dwt = np.load(matlab_data_file_dwt) uses_futures = pytest.mark.skipif( - not futures_available, reason='futures not available, possibly running on Emscripten/WASM.') + not futures_available, reason='futures not available') uses_matlab = pytest.mark.skipif( matlab_missing, reason='pymatbridge and/or Matlab not available') uses_pymatbridge = pytest.mark.skipif( From 7687665a25ba6288d4896820bcac78f936d2cdfa Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:17:10 +0530 Subject: [PATCH 07/30] Rename `ImportError` error message for `batch_processing` module --- demo/batch_processing.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/demo/batch_processing.py b/demo/batch_processing.py index 1f55acc20..ae11a9fc8 100644 --- a/demo/batch_processing.py +++ b/demo/batch_processing.py @@ -24,8 +24,7 @@ from concurrent import futures except ImportError: raise ImportError( - "This demo requires concurrent.futures. It can be installed for " - "for python 2.x via: pip install futures") + "This demo requires concurrent.futures. If you are on WebAssembly, this is not available.") import numpy as np from numpy.testing import assert_array_equal From 9941e055f9fdc1ad6facc6ac4e05a4ead2433aed Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:57:16 +0530 Subject: [PATCH 08/30] Try fixing bad file descriptors via `os.path.abspath` --- pywt/data/_readers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 258230c20..1c52d46c3 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -36,7 +36,7 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'ascent.npz') + fname = os.path.dirname(os.path.abspath(__file__), 'ascent.npz') ascent = np.load(fname)['data'] return ascent @@ -71,7 +71,7 @@ def aero(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'aero.npz') + fname = os.path.dirname(os.path.abspath(__file__), 'aero.npz') aero = np.load(fname)['data'] return aero @@ -117,7 +117,7 @@ def camera(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'camera.npz') + fname = os.path.dirname(os.path.abspath(__file__), 'camera.npz') camera = np.load(fname)['data'] return camera @@ -147,7 +147,7 @@ def ecg(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'ecg.npy') + fname = os.path.dirname(os.path.abspath(__file__), 'ecg.npy') ecg = np.load(fname) return ecg @@ -183,7 +183,7 @@ def nino(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'sst_nino3.npy') + fname = os.path.dirname(os.path.abspath(__file__), 'sst_nino3.npy') sst_csv = np.load(fname) # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years From 7f95d653898362bccdac9520b669f4140b209917 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:08:53 +0530 Subject: [PATCH 09/30] Revisit NumPy-style `IS_WASM` check --- pywt/_pytest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pywt/_pytest.py b/pywt/_pytest.py index 13512afff..0dda2cd90 100644 --- a/pywt/_pytest.py +++ b/pywt/_pytest.py @@ -1,6 +1,7 @@ """common test-related code.""" import os import sys +import platform import multiprocessing import numpy as np import pytest @@ -23,9 +24,14 @@ futures_available = True # Check if running on Emscripten/WASM, and skip tests that require concurrency. # Relevant issue: https://github.com/pyodide/pyodide/issues/237 -except ImportError or (sys.platform == "emscripten"): +except (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"]): futures_available = False futures = None + max_workers = 1 +except ImportError: + futures_available = False + futures = None + max_workers = 1 # check if pymatbridge + MATLAB tests should be run From cd692155bb03a4fff57aab214891072ab59f83b1 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:14:07 +0530 Subject: [PATCH 10/30] Fix `os` module kwargs error Similar to commit 9941e055f9fdc1ad6facc6ac4e05a4ead2433aed, I can revert both later on --- pywt/data/_readers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 1c52d46c3..01dc690ef 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -36,7 +36,7 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'ascent.npz') + fname = os.path.join(os.path.abspath(__file__), 'ascent.npz') ascent = np.load(fname)['data'] return ascent @@ -71,7 +71,7 @@ def aero(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'aero.npz') + fname = os.path.join(os.path.abspath(__file__), 'aero.npz') aero = np.load(fname)['data'] return aero @@ -117,7 +117,7 @@ def camera(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'camera.npz') + fname = os.path.join(os.path.abspath(__file__), 'camera.npz') camera = np.load(fname)['data'] return camera @@ -147,7 +147,7 @@ def ecg(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'ecg.npy') + fname = os.path.join(os.path.abspath(__file__), 'ecg.npy') ecg = np.load(fname) return ecg @@ -183,7 +183,7 @@ def nino(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'sst_nino3.npy') + fname = os.path.join(os.path.abspath(__file__), 'sst_nino3.npy') sst_csv = np.load(fname) # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years From 024989219f38cb9335d51f2259b776cbbc091608 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:24:43 +0530 Subject: [PATCH 11/30] Revert "Fix `os` module kwargs error" This reverts commit cd692155bb03a4fff57aab214891072ab59f83b1. --- pywt/data/_readers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 01dc690ef..1c52d46c3 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -36,7 +36,7 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.abspath(__file__), 'ascent.npz') + fname = os.path.dirname(os.path.abspath(__file__), 'ascent.npz') ascent = np.load(fname)['data'] return ascent @@ -71,7 +71,7 @@ def aero(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.abspath(__file__), 'aero.npz') + fname = os.path.dirname(os.path.abspath(__file__), 'aero.npz') aero = np.load(fname)['data'] return aero @@ -117,7 +117,7 @@ def camera(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.abspath(__file__), 'camera.npz') + fname = os.path.dirname(os.path.abspath(__file__), 'camera.npz') camera = np.load(fname)['data'] return camera @@ -147,7 +147,7 @@ def ecg(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.abspath(__file__), 'ecg.npy') + fname = os.path.dirname(os.path.abspath(__file__), 'ecg.npy') ecg = np.load(fname) return ecg @@ -183,7 +183,7 @@ def nino(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.abspath(__file__), 'sst_nino3.npy') + fname = os.path.dirname(os.path.abspath(__file__), 'sst_nino3.npy') sst_csv = np.load(fname) # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years From f20d0887e5ff7ad5ec96799362153985ad5b027f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:24:47 +0530 Subject: [PATCH 12/30] Revert "Try fixing bad file descriptors via `os.path.abspath`" This reverts commit 9941e055f9fdc1ad6facc6ac4e05a4ead2433aed. --- pywt/data/_readers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 1c52d46c3..258230c20 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -36,7 +36,7 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'ascent.npz') + fname = os.path.join(os.path.dirname(__file__), 'ascent.npz') ascent = np.load(fname)['data'] return ascent @@ -71,7 +71,7 @@ def aero(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'aero.npz') + fname = os.path.join(os.path.dirname(__file__), 'aero.npz') aero = np.load(fname)['data'] return aero @@ -117,7 +117,7 @@ def camera(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'camera.npz') + fname = os.path.join(os.path.dirname(__file__), 'camera.npz') camera = np.load(fname)['data'] return camera @@ -147,7 +147,7 @@ def ecg(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'ecg.npy') + fname = os.path.join(os.path.dirname(__file__), 'ecg.npy') ecg = np.load(fname) return ecg @@ -183,7 +183,7 @@ def nino(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.dirname(os.path.abspath(__file__), 'sst_nino3.npy') + fname = os.path.join(os.path.dirname(__file__), 'sst_nino3.npy') sst_csv = np.load(fname) # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years From 90d13d01be884a44be808841072c502d94b7603c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 22:56:34 +0530 Subject: [PATCH 13/30] Hope to fix a few `mra_roundtrip` data tests --- pywt/tests/test_mra.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pywt/tests/test_mra.py b/pywt/tests/test_mra.py index 055ac1fa7..af8bdd31d 100644 --- a/pywt/tests/test_mra.py +++ b/pywt/tests/test_mra.py @@ -6,6 +6,7 @@ import pywt from pywt import data +from pywt._pytest import uses_futures # tolerances used in accuracy comparisons tol_single = 1e-6 @@ -17,6 +18,7 @@ # 1d mra tests #### +@uses_futures @pytest.mark.parametrize('wavelet', ['db2', 'sym4', 'coif5']) @pytest.mark.parametrize('transform', ['dwt', 'swt']) @pytest.mark.parametrize('mode', pywt.Modes.modes) From 15b6eae0fd28db034d8d999324933d7715b095c2 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:10:37 +0530 Subject: [PATCH 14/30] Try loading data files via conversion to abspath --- pywt/data/_readers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 258230c20..931cfd0eb 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -36,7 +36,8 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'ascent.npz') + fname = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'ascent.npz') + fname = os.path.abspath(fname) ascent = np.load(fname)['data'] return ascent @@ -72,6 +73,7 @@ def aero(): """ fname = os.path.join(os.path.dirname(__file__), 'aero.npz') + fname = os.path.abspath(fname) aero = np.load(fname)['data'] return aero @@ -118,6 +120,7 @@ def camera(): """ fname = os.path.join(os.path.dirname(__file__), 'camera.npz') + fname = os.path.abspath(fname) camera = np.load(fname)['data'] return camera @@ -148,6 +151,7 @@ def ecg(): >>> plt.show() # doctest: +SKIP """ fname = os.path.join(os.path.dirname(__file__), 'ecg.npy') + fname = os.path.abspath(fname) ecg = np.load(fname) return ecg @@ -184,6 +188,7 @@ def nino(): >>> plt.show() # doctest: +SKIP """ fname = os.path.join(os.path.dirname(__file__), 'sst_nino3.npy') + fname = os.path.abspath(fname) sst_csv = np.load(fname) # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years From bc67ce7a34db264908c0bffcc1912e32bb8276ea Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:20:38 +0530 Subject: [PATCH 15/30] Some more path-abspath trickery --- pywt/data/_readers.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 931cfd0eb..0e0f7faaf 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -36,8 +36,7 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'ascent.npz') - fname = os.path.abspath(fname) + fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ascent.npz') ascent = np.load(fname)['data'] return ascent @@ -72,8 +71,7 @@ def aero(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'aero.npz') - fname = os.path.abspath(fname) + fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'aero.npz') aero = np.load(fname)['data'] return aero @@ -119,8 +117,7 @@ def camera(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'camera.npz') - fname = os.path.abspath(fname) + fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'camera.npz') camera = np.load(fname)['data'] return camera @@ -150,8 +147,7 @@ def ecg(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'ecg.npy') - fname = os.path.abspath(fname) + fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ecg.npy') ecg = np.load(fname) return ecg @@ -187,8 +183,7 @@ def nino(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(__file__), 'sst_nino3.npy') - fname = os.path.abspath(fname) + fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sst_nino3.npy') sst_csv = np.load(fname) # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years From 3b743b5dfd78aa890497dc860d14b4605a799d26 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 21 Feb 2024 20:26:50 +0100 Subject: [PATCH 16/30] TST: fix test condition for Pyodide --- pywt/_pytest.py | 7 ++++++- pywt/tests/test_concurrent.py | 12 +++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pywt/_pytest.py b/pywt/_pytest.py index 0dda2cd90..678cb4b31 100644 --- a/pywt/_pytest.py +++ b/pywt/_pytest.py @@ -24,6 +24,7 @@ futures_available = True # Check if running on Emscripten/WASM, and skip tests that require concurrency. # Relevant issue: https://github.com/pyodide/pyodide/issues/237 +# FIXME: you can't do `except a_bool` except (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"]): futures_available = False futures = None @@ -34,6 +35,9 @@ max_workers = 1 +IS_WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"]) + + # check if pymatbridge + MATLAB tests should be run matlab_result_dict_dwt = None matlab_result_dict_cwt = None @@ -63,7 +67,8 @@ matlab_result_dict_dwt = np.load(matlab_data_file_dwt) uses_futures = pytest.mark.skipif( - not futures_available, reason='futures not available') + True, reason='futures not available') + #not futures_available, reason='futures not available') uses_matlab = pytest.mark.skipif( matlab_missing, reason='pymatbridge and/or Matlab not available') uses_pymatbridge = pytest.mark.skipif( diff --git a/pywt/tests/test_concurrent.py b/pywt/tests/test_concurrent.py index 041171fd8..bdc719598 100644 --- a/pywt/tests/test_concurrent.py +++ b/pywt/tests/test_concurrent.py @@ -8,9 +8,11 @@ import warnings import numpy as np from functools import partial + +import pytest from numpy.testing import assert_array_equal, assert_allclose -from pywt._pytest import uses_futures, futures, max_workers +from pywt._pytest import IS_WASM, futures, max_workers import pywt @@ -32,7 +34,7 @@ def _assert_all_coeffs_equal(coefs1, coefs2): return True -@uses_futures +@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") def test_concurrent_swt(): # tests error-free concurrent operation (see gh-288) # swt on 1D data calls the Cython swt @@ -53,7 +55,7 @@ def test_concurrent_swt(): _assert_all_coeffs_equal(expected_result, results[-1]) -@uses_futures +@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") def test_concurrent_wavedec(): # wavedec on 1D data calls the Cython dwt_single # other cases call dwt_axis @@ -70,7 +72,7 @@ def test_concurrent_wavedec(): _assert_all_coeffs_equal(expected_result, results[-1]) -@uses_futures +@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") def test_concurrent_dwt(): # dwt on 1D data calls the Cython dwt_single # other cases call dwt_axis @@ -87,7 +89,7 @@ def test_concurrent_dwt(): _assert_all_coeffs_equal([expected_result, ], [results[-1], ]) -@uses_futures +@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") def test_concurrent_cwt(): atol = rtol = 1e-14 time, sst = pywt.data.nino() From f2d8a9caca7fe6bd55b3ac5209b7884c3da144e2 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 21 Feb 2024 21:43:53 +0100 Subject: [PATCH 17/30] TST: ensure file handles get closed --- pywt/data/_readers.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 0e0f7faaf..aefb4d01c 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -37,7 +37,9 @@ def ascent(): """ fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ascent.npz') - ascent = np.load(fname)['data'] + with open(fname, 'rb') as f: + ascent = np.load(f)['data'] + return ascent @@ -72,7 +74,9 @@ def aero(): """ fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'aero.npz') - aero = np.load(fname)['data'] + with open(fname, 'rb') as f: + aero = np.load(f)['data'] + return aero @@ -118,7 +122,9 @@ def camera(): """ fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'camera.npz') - camera = np.load(fname)['data'] + with open(fname, 'rb') as f: + camera = np.load(f)['data'] + return camera @@ -148,7 +154,9 @@ def ecg(): >>> plt.show() # doctest: +SKIP """ fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ecg.npy') - ecg = np.load(fname) + with open(fname, 'rb') as f: + ecg = np.load(f) + return ecg @@ -184,7 +192,9 @@ def nino(): >>> plt.show() # doctest: +SKIP """ fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sst_nino3.npy') - sst_csv = np.load(fname) + with open(fname, 'rb') as f: + sst_csv = np.load(f) + # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years n = int(np.floor(sst_csv.shape[0]/12.)*12.) From d5008f7352dd8726cb338d1f88eecb98d8be0655 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 21 Feb 2024 22:09:38 +0100 Subject: [PATCH 18/30] use importlib.resources instead of `__file__` --- pywt/data/_readers.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index aefb4d01c..6879ca256 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -1,3 +1,4 @@ +import importlib import os import numpy as np @@ -36,8 +37,8 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ascent.npz') - with open(fname, 'rb') as f: + _datadir = importlib.resources.files('pywt.data') + with importlib.resources.as_file(_datadir.joinpath('ascent.npz')) as f: ascent = np.load(f)['data'] return ascent @@ -73,8 +74,8 @@ def aero(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'aero.npz') - with open(fname, 'rb') as f: + _datadir = importlib.resources.files('pywt.data') + with importlib.resources.as_file(_datadir.joinpath('aero.npz')) as f: aero = np.load(f)['data'] return aero @@ -121,8 +122,8 @@ def camera(): >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'camera.npz') - with open(fname, 'rb') as f: + _datadir = importlib.resources.files('pywt.data') + with importlib.resources.as_file(_datadir.joinpath('camera.npz')) as f: camera = np.load(f)['data'] return camera @@ -153,8 +154,8 @@ def ecg(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ecg.npy') - with open(fname, 'rb') as f: + _datadir = importlib.resources.files('pywt.data') + with importlib.resources.as_file(_datadir.joinpath('ecg.npy')) as f: ecg = np.load(f) return ecg @@ -191,8 +192,8 @@ def nino(): [] >>> plt.show() # doctest: +SKIP """ - fname = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sst_nino3.npy') - with open(fname, 'rb') as f: + _datadir = importlib.resources.files('pywt.data') + with importlib.resources.as_file(_datadir.joinpath('sst_nino3.npy')) as f: sst_csv = np.load(f) # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) From a4ab51e968a138c6b8d63fde4cbfda87067a2abb Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 21 Feb 2024 22:34:25 +0100 Subject: [PATCH 19/30] try caching data loading --- pywt/data/_readers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 6879ca256..40244ab46 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -1,9 +1,11 @@ +import functools import importlib import os import numpy as np +@functools.cache def ascent(): """ Get an 8-bit grayscale bit-depth, 512 x 512 derived image for @@ -44,6 +46,7 @@ def ascent(): return ascent +@functools.cache def aero(): """ Get an 8-bit grayscale bit-depth, 512 x 512 derived image for @@ -81,6 +84,7 @@ def aero(): return aero +@functools.cache def camera(): """ Get an 8-bit grayscale bit-depth, 512 x 512 derived image for @@ -129,6 +133,7 @@ def camera(): return camera +@functools.cache def ecg(): """ Get 1024 points of an ECG timeseries. @@ -161,6 +166,7 @@ def ecg(): return ecg +@functools.cache def nino(): """ This data contains the averaged monthly sea surface temperature in degrees From f69782e966b6fa1523b81e14e6c6aaaec5216653 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 13:39:49 +0530 Subject: [PATCH 20/30] Git-ignore pytest cache directory tree --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e09527154..1bd984aa3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__ *.pyd *.so .DS_Store +.pytest_cache/ # Packages *.egg From 2e0e490871ce4e8b276ded902b5f7e7e65629fa0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 13:45:54 +0530 Subject: [PATCH 21/30] Remove incorrect boolean statement provided to `except` clause --- pywt/_pytest.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pywt/_pytest.py b/pywt/_pytest.py index 678cb4b31..c34664eee 100644 --- a/pywt/_pytest.py +++ b/pywt/_pytest.py @@ -22,19 +22,13 @@ from concurrent import futures max_workers = multiprocessing.cpu_count() futures_available = True -# Check if running on Emscripten/WASM, and skip tests that require concurrency. -# Relevant issue: https://github.com/pyodide/pyodide/issues/237 -# FIXME: you can't do `except a_bool` -except (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"]): - futures_available = False - futures = None - max_workers = 1 except ImportError: futures_available = False futures = None max_workers = 1 - +# Check if running on Emscripten/WASM, and skip tests that require concurrency. +# Relevant issue: https://github.com/pyodide/pyodide/issues/237 IS_WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"]) @@ -68,7 +62,7 @@ uses_futures = pytest.mark.skipif( True, reason='futures not available') - #not futures_available, reason='futures not available') + # not futures_available, reason='futures not available') uses_matlab = pytest.mark.skipif( matlab_missing, reason='pymatbridge and/or Matlab not available') uses_pymatbridge = pytest.mark.skipif( From ef078b0ea32c7d20df68a06d3126b424bcfc6e02 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:38:36 +0530 Subject: [PATCH 22/30] Rewrite `.npy` file paths as `.npz` archives --- pywt/data/_readers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index 40244ab46..b6f378986 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -160,8 +160,8 @@ def ecg(): >>> plt.show() # doctest: +SKIP """ _datadir = importlib.resources.files('pywt.data') - with importlib.resources.as_file(_datadir.joinpath('ecg.npy')) as f: - ecg = np.load(f) + with importlib.resources.as_file(_datadir.joinpath('ecg.npz')) as f: + ecg = np.load(f)['data'] return ecg @@ -199,8 +199,8 @@ def nino(): >>> plt.show() # doctest: +SKIP """ _datadir = importlib.resources.files('pywt.data') - with importlib.resources.as_file(_datadir.joinpath('sst_nino3.npy')) as f: - sst_csv = np.load(f) + with importlib.resources.as_file(_datadir.joinpath('sst_nino3.npz')) as f: + sst_csv = np.load(f)['data'] # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) # take only full years From 7633198470a54bec147da45c947e35b6241f4553 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:39:17 +0530 Subject: [PATCH 23/30] Convert ecg to NumPy compressed archive --- pywt/data/{ecg.npy => ecg.npz} | Bin 4176 -> 4358 bytes 1 file changed, 0 insertions(+), 0 deletions(-) rename pywt/data/{ecg.npy => ecg.npz} (93%) diff --git a/pywt/data/ecg.npy b/pywt/data/ecg.npz similarity index 93% rename from pywt/data/ecg.npy rename to pywt/data/ecg.npz index 119916b039439aef044ae8a4ab1b0d9cb1de3a2a..ac3961a2da271468d7a34a626a2736f12a3230fb 100644 GIT binary patch delta 196 zcmcbh(5B=Z;LXgU%K!n23J$*wzz8B?P6+U3WdrdUfzS*{?*cmq E040bd#{d8T delta 21 ccmZoux}d;0*)P;LAd->6ZKAW=#+{4;089!7ssI20 From b031e4a317e114d3dfc70b15581973129e3e2836 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:39:32 +0530 Subject: [PATCH 24/30] Convert sst_nino3 to NumPy compressed archive --- pywt/data/{sst_nino3.npy => sst_nino3.npz} | Bin 64128 -> 64262 bytes 1 file changed, 0 insertions(+), 0 deletions(-) rename pywt/data/{sst_nino3.npy => sst_nino3.npz} (99%) diff --git a/pywt/data/sst_nino3.npy b/pywt/data/sst_nino3.npz similarity index 99% rename from pywt/data/sst_nino3.npy rename to pywt/data/sst_nino3.npz index 822d2021b6bd1766d852c018414e54981003187e..60d1d5856ed91fba82c8eb8c0e75d45b01b06785 100644 GIT binary patch delta 145 zcmZqp%G~yi*($)BnMIcY0u&icE2@?MLjeba2t!I@Nupj}K_w%D07Jtsh$ Date: Thu, 22 Feb 2024 16:45:16 +0530 Subject: [PATCH 25/30] Properly skip tests for WASM and wherever threading isn't available --- pywt/_pytest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywt/_pytest.py b/pywt/_pytest.py index c34664eee..7685bea71 100644 --- a/pywt/_pytest.py +++ b/pywt/_pytest.py @@ -61,7 +61,7 @@ matlab_result_dict_dwt = np.load(matlab_data_file_dwt) uses_futures = pytest.mark.skipif( - True, reason='futures not available') + not futures_available or IS_WASM, reason='futures not available') # not futures_available, reason='futures not available') uses_matlab = pytest.mark.skipif( matlab_missing, reason='pymatbridge and/or Matlab not available') From fa3a852e6b61b65a7cdf5bd12c41ac9fad919111 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:52:59 +0530 Subject: [PATCH 26/30] Clean up conditions to be met to skip tests --- pywt/_pytest.py | 3 ++- pywt/tests/test_concurrent.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pywt/_pytest.py b/pywt/_pytest.py index 7685bea71..af4d60cf8 100644 --- a/pywt/_pytest.py +++ b/pywt/_pytest.py @@ -61,7 +61,8 @@ matlab_result_dict_dwt = np.load(matlab_data_file_dwt) uses_futures = pytest.mark.skipif( - not futures_available or IS_WASM, reason='futures not available') + not futures_available or IS_WASM, + reason='futures is not available, or running via Pyodide/WASM.') # not futures_available, reason='futures not available') uses_matlab = pytest.mark.skipif( matlab_missing, reason='pymatbridge and/or Matlab not available') diff --git a/pywt/tests/test_concurrent.py b/pywt/tests/test_concurrent.py index bdc719598..529b245a7 100644 --- a/pywt/tests/test_concurrent.py +++ b/pywt/tests/test_concurrent.py @@ -12,7 +12,7 @@ import pytest from numpy.testing import assert_array_equal, assert_allclose -from pywt._pytest import IS_WASM, futures, max_workers +from pywt._pytest import uses_futures, futures, max_workers import pywt @@ -34,7 +34,7 @@ def _assert_all_coeffs_equal(coefs1, coefs2): return True -@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") +@uses_futures def test_concurrent_swt(): # tests error-free concurrent operation (see gh-288) # swt on 1D data calls the Cython swt @@ -55,7 +55,7 @@ def test_concurrent_swt(): _assert_all_coeffs_equal(expected_result, results[-1]) -@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") +@uses_futures def test_concurrent_wavedec(): # wavedec on 1D data calls the Cython dwt_single # other cases call dwt_axis @@ -72,7 +72,7 @@ def test_concurrent_wavedec(): _assert_all_coeffs_equal(expected_result, results[-1]) -@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") +@uses_futures def test_concurrent_dwt(): # dwt on 1D data calls the Cython dwt_single # other cases call dwt_axis @@ -89,7 +89,7 @@ def test_concurrent_dwt(): _assert_all_coeffs_equal([expected_result, ], [results[-1], ]) -@pytest.mark.skipif(IS_WASM, reason="no futures support in Pyodide") +@uses_futures def test_concurrent_cwt(): atol = rtol = 1e-14 time, sst = pywt.data.nino() From 0343b6db6094eca605fec2a97a217f1e2acf6fe3 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:59:33 +0530 Subject: [PATCH 27/30] Use better job name to reflect Pyodide build --- .github/workflows/emscripten.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 896b66091..b0c47ea18 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -19,6 +19,7 @@ env: jobs: build_wasm_emscripten: + name: Build PyWavelets for Pyodide runs-on: ubuntu-latest # Uncomment the following line to test changes on a fork # if: github.repository == 'PyWavelets/pywt' From dedac169fef4d0a8a1dfe017d69179684aff50ae Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:04:57 +0530 Subject: [PATCH 28/30] Remove workflow run contexts, i.e., run on pushes and PRs --- .github/workflows/emscripten.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index b0c47ea18..fcc906b37 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -1,18 +1,14 @@ name: Test Pyodide build for PyWavelets -# TODO: uncomment after testing on: push: - # branches: - # - master - # - v1.** + branches: + - master + - v1.** pull_request: - # branches: - # - master - # - v1.** - workflow_dispatch: - schedule: - - cron: '0 3 * * *' + branches: + - master + - v1.** env: FORCE_COLOR: 3 From 7315b43187cd10dc7a712da947ca7e13337c9a2b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:41:05 +0530 Subject: [PATCH 29/30] import `importlib.resources`, mark `/pywt/data/` as constant --- pywt/data/_readers.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pywt/data/_readers.py b/pywt/data/_readers.py index b6f378986..10105a691 100644 --- a/pywt/data/_readers.py +++ b/pywt/data/_readers.py @@ -1,10 +1,13 @@ import functools -import importlib +import importlib.resources import os import numpy as np +_DATADIR = importlib.resources.files('pywt.data') + + @functools.cache def ascent(): """ @@ -39,8 +42,7 @@ def ascent(): >>> plt.show() # doctest: +SKIP """ - _datadir = importlib.resources.files('pywt.data') - with importlib.resources.as_file(_datadir.joinpath('ascent.npz')) as f: + with importlib.resources.as_file(_DATADIR.joinpath('ascent.npz')) as f: ascent = np.load(f)['data'] return ascent @@ -77,8 +79,7 @@ def aero(): >>> plt.show() # doctest: +SKIP """ - _datadir = importlib.resources.files('pywt.data') - with importlib.resources.as_file(_datadir.joinpath('aero.npz')) as f: + with importlib.resources.as_file(_DATADIR.joinpath('aero.npz')) as f: aero = np.load(f)['data'] return aero @@ -126,8 +127,7 @@ def camera(): >>> plt.show() # doctest: +SKIP """ - _datadir = importlib.resources.files('pywt.data') - with importlib.resources.as_file(_datadir.joinpath('camera.npz')) as f: + with importlib.resources.as_file(_DATADIR.joinpath('camera.npz')) as f: camera = np.load(f)['data'] return camera @@ -159,8 +159,7 @@ def ecg(): [] >>> plt.show() # doctest: +SKIP """ - _datadir = importlib.resources.files('pywt.data') - with importlib.resources.as_file(_datadir.joinpath('ecg.npz')) as f: + with importlib.resources.as_file(_DATADIR.joinpath('ecg.npz')) as f: ecg = np.load(f)['data'] return ecg @@ -198,8 +197,7 @@ def nino(): [] >>> plt.show() # doctest: +SKIP """ - _datadir = importlib.resources.files('pywt.data') - with importlib.resources.as_file(_datadir.joinpath('sst_nino3.npz')) as f: + with importlib.resources.as_file(_DATADIR.joinpath('sst_nino3.npz')) as f: sst_csv = np.load(f)['data'] # sst_csv = pd.read_csv("http://www.cpc.ncep.noaa.gov/data/indices/ersst4.nino.mth.81-10.ascii", sep=' ', skipinitialspace=True) From 4a962c9e78e0f581c777b79734e9592d973ba918 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 22 Feb 2024 19:41:48 +0530 Subject: [PATCH 30/30] Remove unneeded `@uses_futures` decorator --- pywt/tests/test_mra.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pywt/tests/test_mra.py b/pywt/tests/test_mra.py index af8bdd31d..055ac1fa7 100644 --- a/pywt/tests/test_mra.py +++ b/pywt/tests/test_mra.py @@ -6,7 +6,6 @@ import pywt from pywt import data -from pywt._pytest import uses_futures # tolerances used in accuracy comparisons tol_single = 1e-6 @@ -18,7 +17,6 @@ # 1d mra tests #### -@uses_futures @pytest.mark.parametrize('wavelet', ['db2', 'sym4', 'coif5']) @pytest.mark.parametrize('transform', ['dwt', 'swt']) @pytest.mark.parametrize('mode', pywt.Modes.modes)