From 1bf1ae8b2196123fa040dc6f29a511b6c98d295a Mon Sep 17 00:00:00 2001 From: nimasarajpoor Date: Thu, 24 Aug 2023 22:10:11 -0400 Subject: [PATCH 1/3] Empty commit From 5b79efbfe7821f7c3a9c3d9acbe7ef9fee3fb8fd Mon Sep 17 00:00:00 2001 From: nimasarajpoor Date: Thu, 24 Aug 2023 22:29:59 -0400 Subject: [PATCH 2/3] add test function to test precision for identical subsequences --- tests/test_precision.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_precision.py b/tests/test_precision.py index c87985092..c1ce8fa07 100644 --- a/tests/test_precision.py +++ b/tests/test_precision.py @@ -198,3 +198,28 @@ def test_distance_symmetry_property_in_gpu(): ref = 0.0 npt.assert_almost_equal(comp, ref, decimal=15) + + +def test_stump_identical_subsequence_self_join_rare_cases_1(): + # This test function is designed to capture the errors that migtht be raised + # due the imprecision in the calculation of pearson values in the edge case + # where two subsequences are identical. + m = 3 + zone = int(np.ceil(m / 4)) + + seed_values = [27343, 84451] + for seed in seed_values: + np.random.seed(seed) + + identical = np.random.rand(8) + T_A = np.random.rand(20) + T_A[1 : 1 + identical.shape[0]] = identical + T_A[11 : 11 + identical.shape[0]] = identical + + ref_mp = naive.stump(T_A, m, exclusion_zone=zone, row_wise=True) + comp_mp = stumpy.stump(T_A, m, ignore_trivial=True) + naive.replace_inf(ref_mp) + naive.replace_inf(comp_mp) + npt.assert_almost_equal( + ref_mp[:, 0], comp_mp[:, 0], decimal=config.STUMPY_TEST_PRECISION + ) # ignore indices From 1eb878d98b16343b8254182f6768ed5d3865ec11 Mon Sep 17 00:00:00 2001 From: nimasarajpoor Date: Thu, 24 Aug 2023 22:38:58 -0400 Subject: [PATCH 3/3] add new test function for identical subsequences with different scales --- tests/test_precision.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_precision.py b/tests/test_precision.py index c1ce8fa07..6487302b5 100644 --- a/tests/test_precision.py +++ b/tests/test_precision.py @@ -223,3 +223,25 @@ def test_stump_identical_subsequence_self_join_rare_cases_1(): npt.assert_almost_equal( ref_mp[:, 0], comp_mp[:, 0], decimal=config.STUMPY_TEST_PRECISION ) # ignore indices + + +def test_stump_identical_subsequence_self_join_rare_cases_2(): + m = 3 + zone = int(np.ceil(m / 4)) + + seed_values = [27343, 84451] + for seed in seed_values: + np.random.seed(seed) + + identical = np.random.rand(8) + T_A = np.random.rand(20) + T_A[1 : 1 + identical.shape[0]] = identical * 0.001 + T_A[11 : 11 + identical.shape[0]] = identical * 1000 + + ref_mp = naive.stump(T_A, m, exclusion_zone=zone, row_wise=True) + comp_mp = stumpy.stump(T_A, m, ignore_trivial=True) + naive.replace_inf(ref_mp) + naive.replace_inf(comp_mp) + npt.assert_almost_equal( + ref_mp[:, 0], comp_mp[:, 0], decimal=config.STUMPY_TEST_PRECISION + ) # ignore indices