Skip to content

Commit 5b79efb

Browse files
committed
add test function to test precision for identical subsequences
1 parent 1bf1ae8 commit 5b79efb

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_precision.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,28 @@ def test_distance_symmetry_property_in_gpu():
198198
ref = 0.0
199199

200200
npt.assert_almost_equal(comp, ref, decimal=15)
201+
202+
203+
def test_stump_identical_subsequence_self_join_rare_cases_1():
204+
# This test function is designed to capture the errors that migtht be raised
205+
# due the imprecision in the calculation of pearson values in the edge case
206+
# where two subsequences are identical.
207+
m = 3
208+
zone = int(np.ceil(m / 4))
209+
210+
seed_values = [27343, 84451]
211+
for seed in seed_values:
212+
np.random.seed(seed)
213+
214+
identical = np.random.rand(8)
215+
T_A = np.random.rand(20)
216+
T_A[1 : 1 + identical.shape[0]] = identical
217+
T_A[11 : 11 + identical.shape[0]] = identical
218+
219+
ref_mp = naive.stump(T_A, m, exclusion_zone=zone, row_wise=True)
220+
comp_mp = stumpy.stump(T_A, m, ignore_trivial=True)
221+
naive.replace_inf(ref_mp)
222+
naive.replace_inf(comp_mp)
223+
npt.assert_almost_equal(
224+
ref_mp[:, 0], comp_mp[:, 0], decimal=config.STUMPY_TEST_PRECISION
225+
) # ignore indices

0 commit comments

Comments
 (0)