From 1ff3cbc3a4e63339c6f16cd2f84b49d6c3ccbbe3 Mon Sep 17 00:00:00 2001 From: Karthik Date: Mon, 9 Nov 2026 22:24:04 -0500 Subject: [PATCH 1/2] Migrate aampdist snippet comparisons to assert_allclose --- tests/test_aampdist_snippets.py | 60 ++++++++++----------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/tests/test_aampdist_snippets.py b/tests/test_aampdist_snippets.py index 20e9bf3a9..bc748ca3a 100644 --- a/tests/test_aampdist_snippets.py +++ b/tests/test_aampdist_snippets.py @@ -3,7 +3,7 @@ import numpy.testing as npt import pytest -from stumpy import config, rng +from stumpy import rng from stumpy.aampdist_snippets import _get_all_aampdist_profiles, aampdist_snippets test_data = [rng.RNG.uniform(-1000, 1000, size=64).astype(np.float64)] @@ -19,9 +19,7 @@ def test_get_all_aampdist_profiles(T, m): ref_profiles = naive.get_all_aampdist_profiles(T, m) cmp_profiles = _get_all_aampdist_profiles(T, m) - npt.assert_almost_equal( - ref_profiles, cmp_profiles, decimal=config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=1.5e-07) @pytest.mark.parametrize("T", test_data) @@ -31,9 +29,7 @@ def test_get_all_aampdist_profiles_s(T, m, s): ref_profiles = naive.get_all_aampdist_profiles(T, m, s=s) cmp_profiles = _get_all_aampdist_profiles(T, m, s=s) - npt.assert_almost_equal( - ref_profiles, cmp_profiles, decimal=config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=1.5e-07) @pytest.mark.parametrize("T", test_data) @@ -72,19 +68,15 @@ def test_aampdist_snippets(T, m, k): npt.assert_allclose( cmp_aampdist_snippets, ref_aampdist_snippets, - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, - ) - npt.assert_allclose( - cmp_indices, ref_indices, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + atol=1.5e-07, ) + npt.assert_allclose(cmp_indices, ref_indices, atol=1.5e-07) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_profiles, ref_profiles, atol=1.5e-07 # ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=1.5e-07) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_areas, ref_areas, atol=1.5e-07 # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -116,22 +108,14 @@ def test_aampdist_snippets_percentage(T, m, k, percentage): cmp_regimes, ) = aampdist_snippets(T, m, k, percentage=percentage) - npt.assert_allclose( - cmp_aampdist_snippets, - ref_aampdist_snippets, - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, - ) - npt.assert_allclose( - cmp_indices, ref_indices, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_aampdist_snippets, ref_aampdist_snippets, atol=1.5e-07) + npt.assert_allclose(cmp_indices, ref_indices, atol=1.5e-07) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_profiles, ref_profiles, atol=1.5e-07 # ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=1.5e-07) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_areas, ref_areas, atol=1.5e-07 # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -163,21 +147,13 @@ def test_aampdist_snippets_s(T, m, k, s): cmp_regimes, ) = aampdist_snippets(T, m, k, s=s) - npt.assert_allclose( - cmp_aampdist_snippets, - ref_aampdist_snippets, - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, - ) - npt.assert_allclose( - cmp_indices, ref_indices, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_aampdist_snippets, ref_aampdist_snippets, atol=1.5e-07) + npt.assert_allclose(cmp_indices, ref_indices, atol=1.5e-07) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_profiles, ref_profiles, atol=1.5e-07 # ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=1.5e-07) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_areas, ref_areas, atol=1.5e-07 # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) From 7d5558cc41b29d6ad11e490720bc348be4a2e9b2 Mon Sep 17 00:00:00 2001 From: Karthik Date: Fri, 13 Nov 2026 18:07:58 -0500 Subject: [PATCH 2/2] Preserve configured precision in snippet comparisons --- tests/test_aampdist_snippets.py | 60 +++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/tests/test_aampdist_snippets.py b/tests/test_aampdist_snippets.py index bc748ca3a..7b8dd7790 100644 --- a/tests/test_aampdist_snippets.py +++ b/tests/test_aampdist_snippets.py @@ -3,7 +3,7 @@ import numpy.testing as npt import pytest -from stumpy import rng +from stumpy import config, rng from stumpy.aampdist_snippets import _get_all_aampdist_profiles, aampdist_snippets test_data = [rng.RNG.uniform(-1000, 1000, size=64).astype(np.float64)] @@ -19,7 +19,9 @@ def test_get_all_aampdist_profiles(T, m): ref_profiles = naive.get_all_aampdist_profiles(T, m) cmp_profiles = _get_all_aampdist_profiles(T, m) - npt.assert_allclose(cmp_profiles, ref_profiles, atol=1.5e-07) + npt.assert_allclose( + cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) @pytest.mark.parametrize("T", test_data) @@ -29,7 +31,9 @@ def test_get_all_aampdist_profiles_s(T, m, s): ref_profiles = naive.get_all_aampdist_profiles(T, m, s=s) cmp_profiles = _get_all_aampdist_profiles(T, m, s=s) - npt.assert_allclose(cmp_profiles, ref_profiles, atol=1.5e-07) + npt.assert_allclose( + cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) @pytest.mark.parametrize("T", test_data) @@ -68,15 +72,19 @@ def test_aampdist_snippets(T, m, k): npt.assert_allclose( cmp_aampdist_snippets, ref_aampdist_snippets, - atol=1.5e-07, + atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + ) + npt.assert_allclose( + cmp_indices, ref_indices, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION ) - npt.assert_allclose(cmp_indices, ref_indices, atol=1.5e-07) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5e-07 + # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION # ) - npt.assert_allclose(cmp_fractions, ref_fractions, atol=1.5e-07) + npt.assert_allclose( + cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5e-07 + # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -108,14 +116,22 @@ def test_aampdist_snippets_percentage(T, m, k, percentage): cmp_regimes, ) = aampdist_snippets(T, m, k, percentage=percentage) - npt.assert_allclose(cmp_aampdist_snippets, ref_aampdist_snippets, atol=1.5e-07) - npt.assert_allclose(cmp_indices, ref_indices, atol=1.5e-07) + npt.assert_allclose( + cmp_aampdist_snippets, + ref_aampdist_snippets, + atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + ) + npt.assert_allclose( + cmp_indices, ref_indices, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5e-07 + # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION # ) - npt.assert_allclose(cmp_fractions, ref_fractions, atol=1.5e-07) + npt.assert_allclose( + cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5e-07 + # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -147,13 +163,21 @@ def test_aampdist_snippets_s(T, m, k, s): cmp_regimes, ) = aampdist_snippets(T, m, k, s=s) - npt.assert_allclose(cmp_aampdist_snippets, ref_aampdist_snippets, atol=1.5e-07) - npt.assert_allclose(cmp_indices, ref_indices, atol=1.5e-07) + npt.assert_allclose( + cmp_aampdist_snippets, + ref_aampdist_snippets, + atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + ) + npt.assert_allclose( + cmp_indices, ref_indices, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5e-07 + # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION # ) - npt.assert_allclose(cmp_fractions, ref_fractions, atol=1.5e-07) + npt.assert_allclose( + cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5e-07 + # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07)