Skip to content

Commit f349385

Browse files
Fixed #842 Incorrect Post-Processing in Naive mass_PI (#886)
* fix mass_PI * removed unnecessary blank line
1 parent d609a07 commit f349385

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/naive.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,20 @@ def mass_PI(
145145
T_subseq_isconstant = rolling_isconstant(T, m, T_subseq_isconstant)
146146

147147
D = distance_profile(Q, T, m)
148+
D[np.isnan(D)] = np.inf
148149
for i in range(len(T) - m + 1):
149-
if Q_subseq_isconstant and T_subseq_isconstant[i]:
150-
D[i] = 0
151-
elif Q_subseq_isconstant or T_subseq_isconstant[i]:
152-
D[i] = np.sqrt(m)
153-
else: # pragma: no cover
154-
pass
150+
if np.isfinite(D[i]):
151+
if Q_subseq_isconstant and T_subseq_isconstant[i]:
152+
D[i] = 0
153+
elif Q_subseq_isconstant or T_subseq_isconstant[i]:
154+
D[i] = np.sqrt(m)
155+
else: # pragma: no cover
156+
pass
155157

156158
if ignore_trivial:
157159
apply_exclusion_zone(D, trivial_idx, excl_zone, np.inf)
158160
start = max(0, trivial_idx - excl_zone)
159161
stop = min(D.shape[0], trivial_idx + excl_zone + 1)
160-
D[np.isnan(D)] = np.inf
161162

162163
I = np.argmin(D)
163164
P = D[I]

0 commit comments

Comments
 (0)