Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test function to test precision for identical subsequences
  • Loading branch information
NimaSarajpoor committed Aug 25, 2023
commit 5b79efbfe7821f7c3a9c3d9acbe7ef9fee3fb8fd
25 changes: 25 additions & 0 deletions tests/test_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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