From e4b173d56e7b97ab248ea2115b475ea41a4a8de8 Mon Sep 17 00:00:00 2001 From: Anjaney Singh Date: Sat, 12 Sep 2026 10:40:14 +0530 Subject: [PATCH] Fix precision loss for identical subsequences --- stumpy/stump.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stumpy/stump.py b/stumpy/stump.py index c5bd435db..78851a0bb 100644 --- a/stumpy/stump.py +++ b/stumpy/stump.py @@ -206,6 +206,11 @@ def _compute_diagonal( pearson = cov * Σ_T_inverse[uint64_j] * σ_Q_inverse[uint64_i] pearson = min(1.0, pearson) + if pearson > 1.0 - 1e-8 and np.array_equal( + T_A[uint64_i : uint64_i + uint64_m], + T_B[uint64_j : uint64_j + uint64_m], + ): + pearson = 1.0 # `ρ[thread_idx, i, :]` is sorted in ascending order and MUST be updated # when the newly-calculated `pearson` value becomes greater than the # first (i.e. smallest) element in this array. Note that a higher