From 7f6f52c07d842c3ad68828181121216cf435367c Mon Sep 17 00:00:00 2001 From: Karthik Date: Thu, 19 Nov 2026 16:31:42 -0500 Subject: [PATCH] Use an absolute tolerance for configured test comparisons --- stumpy/config.py | 3 +- tests/test_aamp.py | 10 ++-- tests/test_aampdist_snippets.py | 48 ++++++----------- tests/test_aamped.py | 4 +- tests/test_aampi.py | 28 ++++------ tests/test_gpu_aamp.py | 12 ++--- tests/test_gpu_stump.py | 12 ++--- tests/test_maamp.py | 6 +-- tests/test_maamped.py | 2 +- tests/test_mstump.py | 18 ++----- tests/test_mstumped.py | 2 +- tests/test_precision.py | 16 +++--- tests/test_scraamp.py | 2 +- tests/test_scrump.py | 4 +- tests/test_snippets.py | 96 +++++++++------------------------ tests/test_stump.py | 10 ++-- tests/test_stumped.py | 4 +- tests/test_stumpi.py | 28 ++++------ 18 files changed, 107 insertions(+), 198 deletions(-) diff --git a/stumpy/config.py b/stumpy/config.py index f4378fbe6..eb4319f5c 100644 --- a/stumpy/config.py +++ b/stumpy/config.py @@ -13,7 +13,7 @@ "STUMPY_DENOM_THRESHOLD": 1e-14, "STUMPY_STDDEV_THRESHOLD": 1e-7, "STUMPY_P_NORM_THRESHOLD": 1e-14, - "STUMPY_TEST_PRECISION": 5, + "STUMPY_TEST_PRECISION": 1.5e-07, "STUMPY_MAX_P_NORM_DISTANCE": np.finfo(np.float64).max, "STUMPY_MAX_DISTANCE": np.sqrt(np.finfo(np.float64).max), "STUMPY_EXCL_ZONE_DENOM": 4, @@ -34,6 +34,7 @@ STUMPY_DENOM_THRESHOLD = _STUMPY_DEFAULTS["STUMPY_DENOM_THRESHOLD"] STUMPY_STDDEV_THRESHOLD = _STUMPY_DEFAULTS["STUMPY_STDDEV_THRESHOLD"] STUMPY_P_NORM_THRESHOLD = _STUMPY_DEFAULTS["STUMPY_P_NORM_THRESHOLD"] +# Absolute tolerance for floating-point comparisons in the test suite. STUMPY_TEST_PRECISION = _STUMPY_DEFAULTS["STUMPY_TEST_PRECISION"] STUMPY_MAX_P_NORM_DISTANCE = _STUMPY_DEFAULTS["STUMPY_MAX_P_NORM_DISTANCE"] STUMPY_MAX_DISTANCE = _STUMPY_DEFAULTS["STUMPY_MAX_DISTANCE"] diff --git a/tests/test_aamp.py b/tests/test_aamp.py index 30762c853..ba0c7f07e 100644 --- a/tests/test_aamp.py +++ b/tests/test_aamp.py @@ -160,7 +160,7 @@ def test_aamp_identical_subsequence_self_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices cmp_mp = aamp(pd.Series(T_A), m, ignore_trivial=True) @@ -168,7 +168,7 @@ def test_aamp_identical_subsequence_self_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices @@ -186,7 +186,7 @@ def test_aamp_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices cmp_mp = aamp(pd.Series(T_A), m, pd.Series(T_B), ignore_trivial=False) @@ -194,7 +194,7 @@ def test_aamp_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # Swap inputs @@ -205,7 +205,7 @@ def test_aamp_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices diff --git a/tests/test_aampdist_snippets.py b/tests/test_aampdist_snippets.py index 7b8dd7790..107f53c37 100644 --- a/tests/test_aampdist_snippets.py +++ b/tests/test_aampdist_snippets.py @@ -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_allclose( - cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) @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_allclose( - cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T", test_data) @@ -72,19 +68,17 @@ 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=config.STUMPY_TEST_PRECISION, ) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION # ) npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION ) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -119,19 +113,15 @@ def test_aampdist_snippets_percentage(T, m, k, 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 + atol=config.STUMPY_TEST_PRECISION, ) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION # ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -166,18 +156,14 @@ def test_aampdist_snippets_s(T, m, k, 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 + atol=config.STUMPY_TEST_PRECISION, ) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose( - # cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION # ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose( - # cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION # ) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) diff --git a/tests/test_aamped.py b/tests/test_aamped.py index 4890dbd0c..e3e5ae55f 100644 --- a/tests/test_aamped.py +++ b/tests/test_aamped.py @@ -323,7 +323,7 @@ def test_aamped_identical_subsequence_self_join(dask_cluster): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices @@ -348,7 +348,7 @@ def test_aamped_identical_subsequence_A_B_join(dask_cluster): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices diff --git a/tests/test_aampi.py b/tests/test_aampi.py index 2b6e96fad..28dfdfded 100644 --- a/tests/test_aampi.py +++ b/tests/test_aampi.py @@ -834,7 +834,7 @@ def test_aampi_identical_subsequence_self_join(): npt.assert_allclose( cmp_P.astype(np.float64), ref_P.astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) @@ -857,7 +857,7 @@ def test_aampi_identical_subsequence_self_join(): npt.assert_allclose( cmp_P.astype(np.float64), ref_P.astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) @@ -889,11 +889,9 @@ def test_aampi_identical_subsequence_self_join_egress(): naive.replace_inf(ref_left_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) - npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): @@ -916,12 +914,10 @@ def test_aampi_identical_subsequence_self_join_egress(): naive.replace_inf(cmp_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION ) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) @@ -950,11 +946,9 @@ def test_aampi_identical_subsequence_self_join_egress(): naive.replace_inf(ref_left_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) - npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): @@ -977,12 +971,10 @@ def test_aampi_identical_subsequence_self_join_egress(): naive.replace_inf(cmp_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION ) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) diff --git a/tests/test_gpu_aamp.py b/tests/test_gpu_aamp.py index 7adfca221..d43cf1ebb 100644 --- a/tests/test_gpu_aamp.py +++ b/tests/test_gpu_aamp.py @@ -279,13 +279,13 @@ def test_gpu_aamp_identical_subsequence_self_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # cmp_mp = gpu_aamp(pd.Series(T_A), m, ignore_trivial=True) # naive.replace_inf(cmp_mp) # npt.assert_allclose( - # cmp_mp[:, 0], ref_mp[:, 0], atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_mp[:, 0], ref_mp[:, 0], atol=config.STUMPY_TEST_PRECISION # ) # ignore indices @@ -305,13 +305,13 @@ def test_gpu_aamp_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # cmp_mp = gpu_aamp(pd.Series(T_A), m, pd.Series(T_B), ignore_trivial=False) # naive.replace_inf(cmp_mp) # npt.assert_allclose( - # cmp_mp[:, 0], ref_mp[:, 0], atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_mp[:, 0], ref_mp[:, 0], atol=config.STUMPY_TEST_PRECISION # ) # ignore indices # Swap inputs @@ -322,13 +322,13 @@ def test_gpu_aamp_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # cmp_mp = gpu_aamp(pd.Series(T_B), m, pd.Series(T_A), ignore_trivial=False) # naive.replace_inf(cmp_mp) # npt.assert_allclose( - # cmp_mp[:, 0], ref_mp[:, 0], atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_mp[:, 0], ref_mp[:, 0], atol=config.STUMPY_TEST_PRECISION # ) # ignore indices diff --git a/tests/test_gpu_stump.py b/tests/test_gpu_stump.py index eec2a0cc5..7494933ee 100644 --- a/tests/test_gpu_stump.py +++ b/tests/test_gpu_stump.py @@ -276,13 +276,13 @@ def test_gpu_stump_identical_subsequence_self_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # cmp_mp = gpu_stump(pd.Series(T_A), m, ignore_trivial=True) # naive.replace_inf(cmp_mp) # npt.assert_allclose( - # cmp_mp[:, 0], ref_mp[:, 0], atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_mp[:, 0], ref_mp[:, 0], atol=config.STUMPY_TEST_PRECISION # ) # ignore indices @@ -302,13 +302,13 @@ def test_gpu_stump_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # cmp_mp = gpu_stump(pd.Series(T_B), m, pd.Series(T_A), ignore_trivial=False) # naive.replace_inf(cmp_mp) # npt.assert_allclose( - # cmp_mp[:, 0], ref_mp[:, 0], atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_mp[:, 0], ref_mp[:, 0], atol=config.STUMPY_TEST_PRECISION # ) # ignore indices # Swap inputs @@ -319,13 +319,13 @@ def test_gpu_stump_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # cmp_mp = gpu_stump(pd.Series(T_A), m, pd.Series(T_B), ignore_trivial=False) # naive.replace_inf(cmp_mp) # npt.assert_allclose( - # cmp_mp[:, 0], ref_mp[:, 0], atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + # cmp_mp[:, 0], ref_mp[:, 0], atol=config.STUMPY_TEST_PRECISION # ) # ignore indices diff --git a/tests/test_maamp.py b/tests/test_maamp.py index c91589266..4634da93d 100644 --- a/tests/test_maamp.py +++ b/tests/test_maamp.py @@ -41,7 +41,7 @@ def test_multi_mass_absolute_seeded(): Q, T, m, T_subseq_isfinite[:, trivial_idx], T_subseq_isfinite ) - npt.assert_allclose(cmp, ref, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp, ref, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T, m", test_data) @@ -58,7 +58,7 @@ def test_multi_mass_absolute(T, m): Q, _T, m, T_subseq_isfinite[:, trivial_idx], T_subseq_isfinite, p=p ) - npt.assert_allclose(cmp, ref, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp, ref, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T, m", test_data) @@ -303,7 +303,7 @@ def test_identical_subsequence_self_join(): cmp_P, cmp_I = maamp(T, m) npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION ) # ignore indices diff --git a/tests/test_maamped.py b/tests/test_maamped.py index c19b772d3..4927bb019 100644 --- a/tests/test_maamped.py +++ b/tests/test_maamped.py @@ -146,7 +146,7 @@ def test_maamped_identical_subsequence_self_join(dask_cluster): cmp_P, cmp_I = maamped(dask_client, T, m) npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION ) # ignore indices diff --git a/tests/test_mstump.py b/tests/test_mstump.py index dae67c313..be5311502 100644 --- a/tests/test_mstump.py +++ b/tests/test_mstump.py @@ -67,9 +67,7 @@ def test_multi_mass_seeded(): query_idx=trivial_idx, ) - npt.assert_allclose( - cmp_result, ref_result, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_result, ref_result, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T, m", test_data) @@ -98,9 +96,7 @@ def test_multi_mass(T, m): query_idx=trivial_idx, ) - npt.assert_allclose( - cmp_result, ref_result, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_result, ref_result, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T, m", test_data) @@ -374,7 +370,7 @@ def test_identical_subsequence_self_join(): cmp_P, cmp_I = mstump(T, m) npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION ) # ignore indices @@ -458,9 +454,7 @@ def test_multi_mass_with_isconstant(): Q_subseq_isconstant=Q_subseq_isconstant, ) - npt.assert_allclose( - cmp_result, ref_result, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_result, ref_result, atol=config.STUMPY_TEST_PRECISION) # case 2: Q is a multi-subseq of T T = rng.RNG.uniform(-1000, 1000, size=[d, n]) @@ -499,9 +493,7 @@ def test_multi_mass_with_isconstant(): query_idx=query_idx, ) - npt.assert_allclose( - cmp_result, ref_result, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_result, ref_result, atol=config.STUMPY_TEST_PRECISION) def test_multi_distance_profile_with_isconstant_case1(): diff --git a/tests/test_mstumped.py b/tests/test_mstumped.py index 6cf655d0c..26ab6ef6a 100644 --- a/tests/test_mstumped.py +++ b/tests/test_mstumped.py @@ -148,7 +148,7 @@ def test_mstumped_identical_subsequence_self_join(dask_cluster): cmp_P, cmp_I = mstumped(dask_client, T, m) npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION ) # ignore indices diff --git a/tests/test_precision.py b/tests/test_precision.py index 4a973b263..88f9139e7 100644 --- a/tests/test_precision.py +++ b/tests/test_precision.py @@ -55,7 +55,7 @@ def test_mpdist_snippets_s(): ) = snippets(T, m, k, s=s) npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION ) @@ -164,20 +164,16 @@ def test_snippets(seed, m, k, s): ) = snippets(T, m, k, s=s, mpdist_T_subseq_isconstant=isconstant_custom_func) npt.assert_allclose( - cmp_snippets, ref_snippets, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_snippets, ref_snippets, atol=config.STUMPY_TEST_PRECISION ) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) npt.assert_allclose( - cmp_indices, ref_indices, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION ) npt.assert_allclose( - cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION ) + npt.assert_allclose(cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) diff --git a/tests/test_scraamp.py b/tests/test_scraamp.py index a3ae33a5c..dd4e538e6 100644 --- a/tests/test_scraamp.py +++ b/tests/test_scraamp.py @@ -607,7 +607,7 @@ def test_scraamp_identical_subsequence_self_join(percentages): naive.replace_inf(ref_P) naive.replace_inf(cmp_P) - npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(ref_I, comp_I) # npt.assert_almost_equal(ref_left_I, comp_left_I) # npt.assert_almost_equal(ref_right_I, comp_right_I) diff --git a/tests/test_scrump.py b/tests/test_scrump.py index 3df8244ac..03c94aa0f 100644 --- a/tests/test_scrump.py +++ b/tests/test_scrump.py @@ -660,9 +660,7 @@ def test_scrump_identical_subsequence_self_join(percentages): naive.replace_inf(ref_P) naive.replace_inf(cmp_P) - npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) # npt.assert_allclose(cmp_right_I, ref_right_I, atol=1.5e-07) diff --git a/tests/test_snippets.py b/tests/test_snippets.py index 34a3c7ce7..b6bc7b83a 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -21,9 +21,7 @@ def test_get_all_mpdist_profiles(T, m): ref_profiles = naive.get_all_mpdist_profiles(T, m) cmp_profiles = _get_all_profiles(T, m) - npt.assert_allclose( - cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T", test_data) @@ -33,9 +31,7 @@ def test_get_all_mpdist_profiles_percentage(T, m, percentage): ref_profiles = naive.get_all_mpdist_profiles(T, m, percentage=percentage) cmp_profiles = _get_all_profiles(T, m, percentage=percentage) - npt.assert_allclose( - cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T", test_data) @@ -45,9 +41,7 @@ def test_get_all_mpdist_profiles_s(T, m, s): ref_profiles = naive.get_all_mpdist_profiles(T, m, s=s) cmp_profiles = _get_all_profiles(T, m, s=s) - npt.assert_allclose( - cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T", test_data) @@ -63,9 +57,7 @@ def test_get_all_mpdist_profiles_with_isconstant(T, m): T, m, mpdist_T_subseq_isconstant=isconstant_custom_func ) - npt.assert_allclose( - cmp_profiles, ref_profiles, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) @pytest.mark.parametrize("T", test_data) @@ -98,21 +90,11 @@ def test_mpdist_snippets(T, m, k): cmp_regimes, ) = snippets(T, m, k) - npt.assert_allclose( - cmp_snippets, ref_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.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_snippets, ref_snippets, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -149,21 +131,11 @@ def test_mpdist_snippets_percentage(T, m, k, percentage): cmp_regimes, ) = snippets(T, m, k, percentage=percentage) - npt.assert_allclose( - cmp_snippets, ref_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.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_snippets, ref_snippets, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -200,21 +172,11 @@ def test_mpdist_snippets_s(T, m, k, s): cmp_regimes, ) = snippets(T, m, k, s=s) - npt.assert_allclose( - cmp_snippets, ref_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.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_snippets, ref_snippets, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) @@ -256,19 +218,9 @@ def test_mpdist_snippets_s_with_isconstant(T, m, k, s): cmp_regimes, ) = snippets(T, m, k, s=s, mpdist_T_subseq_isconstant=isconstant_custom_func) - npt.assert_allclose( - cmp_snippets, ref_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.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_fractions, ref_fractions, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) - npt.assert_allclose( - cmp_areas, ref_areas, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_snippets, ref_snippets, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_indices, ref_indices, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_profiles, ref_profiles, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_fractions, ref_fractions, atol=config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_areas, ref_areas, atol=config.STUMPY_TEST_PRECISION) npt.assert_allclose(cmp_regimes, ref_regimes, atol=1.5e-07) diff --git a/tests/test_stump.py b/tests/test_stump.py index 6a1521bf2..2a41b4220 100644 --- a/tests/test_stump.py +++ b/tests/test_stump.py @@ -176,7 +176,7 @@ def test_stump_identical_subsequence_self_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices cmp_mp = stump(pd.Series(T_A), m, ignore_trivial=True) @@ -184,7 +184,7 @@ def test_stump_identical_subsequence_self_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices @@ -202,7 +202,7 @@ def test_stump_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices cmp_mp = stump(pd.Series(T_A), m, pd.Series(T_B), ignore_trivial=False) @@ -210,7 +210,7 @@ def test_stump_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices # Swap inputs @@ -221,7 +221,7 @@ def test_stump_identical_subsequence_A_B_join(): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices diff --git a/tests/test_stumped.py b/tests/test_stumped.py index 13707a940..9520d9e72 100644 --- a/tests/test_stumped.py +++ b/tests/test_stumped.py @@ -337,7 +337,7 @@ def test_stumped_identical_subsequence_self_join(dask_cluster): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices @@ -362,7 +362,7 @@ def test_stumped_identical_subsequence_A_B_join(dask_cluster): npt.assert_allclose( cmp_mp[:, 0].astype(np.float64), ref_mp[:, 0].astype(np.float64), - atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + atol=config.STUMPY_TEST_PRECISION, ) # ignore indices diff --git a/tests/test_stumpi.py b/tests/test_stumpi.py index 00d1c5180..302046980 100644 --- a/tests/test_stumpi.py +++ b/tests/test_stumpi.py @@ -700,7 +700,7 @@ def test_stumpi_identical_subsequence_self_join(): naive.replace_inf(ref_P) naive.replace_inf(cmp_P) - npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) with rng.fix_state(): @@ -719,7 +719,7 @@ def test_stumpi_identical_subsequence_self_join(): naive.replace_inf(cmp_P) - npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) @@ -750,11 +750,9 @@ def test_stumpi_identical_subsequence_self_join_egress(): naive.replace_inf(cmp_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) - npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): @@ -777,12 +775,10 @@ def test_stumpi_identical_subsequence_self_join_egress(): naive.replace_inf(cmp_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION ) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) @@ -810,11 +806,9 @@ def test_stumpi_identical_subsequence_self_join_egress(): naive.replace_inf(cmp_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) - npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): @@ -837,12 +831,10 @@ def test_stumpi_identical_subsequence_self_join_egress(): naive.replace_inf(cmp_P) naive.replace_inf(cmp_left_P) - npt.assert_allclose( - cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION - ) + npt.assert_allclose(cmp_P, ref_P, atol=config.STUMPY_TEST_PRECISION) # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) npt.assert_allclose( - cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + cmp_left_P, ref_left_P, atol=config.STUMPY_TEST_PRECISION ) # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07)