MCPcopy
hub / github.com/stumpy-dev/stumpy / mstump

Function mstump

tests/naive.py:601–629  ·  view source on GitHub ↗
(T, m, excl_zone, include=None, discords=False, T_subseq_isconstant=None)

Source from the content-addressed store, hash-verified

599
600
601def mstump(T, m, excl_zone, include=None, discords=False, T_subseq_isconstant=None):
602 T = T.copy()
603
604 d, n = T.shape
605 k = n - m + 1
606
607 if T_subseq_isconstant is None or callable(T_subseq_isconstant):
608 T_subseq_isconstant = [T_subseq_isconstant] * d
609 # else means T_subseq_isconstant is list or a numpy 2D array
610
611 T_subseq_isconstant = np.array(
612 [rolling_isconstant(T[i], m, T_subseq_isconstant[i]) for i in range(d)]
613 )
614
615 P = np.full((d, k), np.inf)
616 I = np.ones((d, k), dtype="int64") * -1
617
618 for i in range(k):
619 D = multi_distance_profile(
620 i, T, m, include, discords, T_subseq_isconstant=T_subseq_isconstant
621 )
622 P_i, I_i = PI(D, i, excl_zone)
623
624 for dim in range(T.shape[0]):
625 col_mask = P[dim] > P_i[dim]
626 P[dim, col_mask] = P_i[dim, col_mask]
627 I[dim, col_mask] = I_i[dim, col_mask]
628
629 return P, I
630
631
632def maamp_multi_distance_profile(query_idx, T, m, include=None, discords=False, p=2.0):

Callers

nothing calls this directly

Calls 3

PIFunction · 0.85
rolling_isconstantFunction · 0.70
multi_distance_profileFunction · 0.70

Tested by

no test coverage detected