From ed9ac77c06cc6a77148b2c2ab7f6dc0ae3d85acb Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Thu, 21 May 2026 11:15:29 -0400 Subject: [PATCH 1/6] Use pytest override flag for warning filters in ampere job. Add test warnings that should (and should not) error in CI. --- .github/workflows/workflow.yml | 11 ++++++++++- src/aspire/utils/units.py | 9 +++++++++ tests/test_utils.py | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index a1159460fc..ac7618c29d 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -268,8 +268,17 @@ jobs: ASPIREDIR=${{ env.WORK_DIR }} python -c \ "import aspire; print(aspire.config['cache']['cache_dir']); import aspire.downloader; aspire.downloader.emdb_2660()" - name: Run + env: + PYTEST_CI_FILTERWARNINGS: |- + error + ignore::UserWarning:tests.* run: | - ASPIREDIR=${{ env.WORK_DIR }} PYTHONWARNINGS=error python -m pytest --durations=50 --cov=aspire --cov-report=xml + ASPIREDIR=${{ env.WORK_DIR }} python -m pytest \ + -c tox.ini \ + -o "filterwarnings=${PYTEST_CI_FILTERWARNINGS}" \ + --durations=50 \ + --cov=aspire \ + --cov-report=xml - name: Upload Coverage to CodeCov uses: codecov/codecov-action@v4 with: diff --git a/src/aspire/utils/units.py b/src/aspire/utils/units.py index fd40864795..a930a640ef 100644 --- a/src/aspire/utils/units.py +++ b/src/aspire/utils/units.py @@ -30,6 +30,11 @@ def voltage_to_wavelength(voltage): :param voltage: float, The electron voltage in kV. :return: float, The electron wavelength in angstroms. """ + import warnings + + warnings.warn( + "temporary deprecation warning check", DeprecationWarning, stacklevel=1 + ) # We use de Broglie's relativistic formula for wavelength given by: # wavelength = h / np.sqrt(2 * m * q * V * (1 + q * V / (2 * m * c**2))), # where @@ -53,6 +58,10 @@ def wavelength_to_voltage(wavelength): :param wavelength: float, The electron wavelength in angstroms. :return: float, The electron voltage in kV. """ + # Added to test CI warnings filter + import warnings + + warnings.warn("temporary user warning check", UserWarning, stacklevel=1) a = float(12.264259661581491) b = float(0.9784755917869367) diff --git a/tests/test_utils.py b/tests/test_utils.py index 345afc1aa8..e5825a22ae 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -232,6 +232,9 @@ def test_gaussian_3d(indexing): G_y = np.sum(G, axis=(x, z)) / np.sum(G) G_z = np.sum(G, axis=(x, y)) / np.sum(G) + # Added to check CI config. Should fail on Dep warning + m = np.minimum(G_x, G_y, G_z) + # Corresponding 1d gaussians peak_x = 1 / np.sqrt(2 * np.pi * sigma[0] ** 2) peak_y = 1 / np.sqrt(2 * np.pi * sigma[1] ** 2) @@ -297,6 +300,9 @@ def test_check_pixel_size(): with pytest.raises(ValueError, match="must be a scalar"): check_pixel_size(px_sizes_diff, px_sizes_same) + # Expected UserWarning should not error in CI + assert not check_pixel_size(1.2, 1.3) + def test_gaussian_scalar_param(): L = 100 From fd3ebbc2b0514598bcf09f70a626fb8ea44e56d0 Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Thu, 21 May 2026 11:20:22 -0400 Subject: [PATCH 2/6] tox --- tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index e5825a22ae..3075037e49 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -233,7 +233,7 @@ def test_gaussian_3d(indexing): G_z = np.sum(G, axis=(x, y)) / np.sum(G) # Added to check CI config. Should fail on Dep warning - m = np.minimum(G_x, G_y, G_z) + _ = np.minimum(G_x, G_y, G_z) # Corresponding 1d gaussians peak_x = 1 / np.sqrt(2 * np.pi * sigma[0] ** 2) From 1be7385e218a1d061235a4c81ee5e9b5cd1b2d55 Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Thu, 21 May 2026 11:42:12 -0400 Subject: [PATCH 3/6] remove dep warning --- src/aspire/utils/units.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/aspire/utils/units.py b/src/aspire/utils/units.py index a930a640ef..43b33e2d04 100644 --- a/src/aspire/utils/units.py +++ b/src/aspire/utils/units.py @@ -30,11 +30,6 @@ def voltage_to_wavelength(voltage): :param voltage: float, The electron voltage in kV. :return: float, The electron wavelength in angstroms. """ - import warnings - - warnings.warn( - "temporary deprecation warning check", DeprecationWarning, stacklevel=1 - ) # We use de Broglie's relativistic formula for wavelength given by: # wavelength = h / np.sqrt(2 * m * q * V * (1 + q * V / (2 * m * c**2))), # where From d4c6a33cb384a385de803036b90e364df3e7dfdb Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Thu, 21 May 2026 13:55:11 -0400 Subject: [PATCH 4/6] check known numpy deprecation warning triggers error --- tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 3075037e49..dd5ca4a0d2 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -233,7 +233,7 @@ def test_gaussian_3d(indexing): G_z = np.sum(G, axis=(x, y)) / np.sum(G) # Added to check CI config. Should fail on Dep warning - _ = np.minimum(G_x, G_y, G_z) + np.row_stack(([1, 2], [3, 4])) # Corresponding 1d gaussians peak_x = 1 / np.sqrt(2 * np.pi * sigma[0] ** 2) From 4ed0386710b57cf65fd8164ec20f6ce3389eb343 Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Tue, 26 May 2026 10:29:50 -0400 Subject: [PATCH 5/6] remove specifying config file --- .github/workflows/workflow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index ac7618c29d..fa9e2635d3 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -274,7 +274,6 @@ jobs: ignore::UserWarning:tests.* run: | ASPIREDIR=${{ env.WORK_DIR }} python -m pytest \ - -c tox.ini \ -o "filterwarnings=${PYTEST_CI_FILTERWARNINGS}" \ --durations=50 \ --cov=aspire \ From 092c512f87ba222eb32a96574195f7427dd29f0e Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Tue, 26 May 2026 15:42:28 -0400 Subject: [PATCH 6/6] remove test warnings --- src/aspire/utils/units.py | 4 ---- tests/test_utils.py | 6 ------ 2 files changed, 10 deletions(-) diff --git a/src/aspire/utils/units.py b/src/aspire/utils/units.py index 43b33e2d04..fd40864795 100644 --- a/src/aspire/utils/units.py +++ b/src/aspire/utils/units.py @@ -53,10 +53,6 @@ def wavelength_to_voltage(wavelength): :param wavelength: float, The electron wavelength in angstroms. :return: float, The electron voltage in kV. """ - # Added to test CI warnings filter - import warnings - - warnings.warn("temporary user warning check", UserWarning, stacklevel=1) a = float(12.264259661581491) b = float(0.9784755917869367) diff --git a/tests/test_utils.py b/tests/test_utils.py index dd5ca4a0d2..345afc1aa8 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -232,9 +232,6 @@ def test_gaussian_3d(indexing): G_y = np.sum(G, axis=(x, z)) / np.sum(G) G_z = np.sum(G, axis=(x, y)) / np.sum(G) - # Added to check CI config. Should fail on Dep warning - np.row_stack(([1, 2], [3, 4])) - # Corresponding 1d gaussians peak_x = 1 / np.sqrt(2 * np.pi * sigma[0] ** 2) peak_y = 1 / np.sqrt(2 * np.pi * sigma[1] ** 2) @@ -300,9 +297,6 @@ def test_check_pixel_size(): with pytest.raises(ValueError, match="must be a scalar"): check_pixel_size(px_sizes_diff, px_sizes_same) - # Expected UserWarning should not error in CI - assert not check_pixel_size(1.2, 1.3) - def test_gaussian_scalar_param(): L = 100