MCPcopy Index your code
hub / github.com/stumpy-dev/stumpy / naive_multi_match

Function naive_multi_match

tests/test_motifs.py:86–116  ·  view source on GitHub ↗
(
    Q,
    T,
    excl_zone,
    max_distance,
    max_matches=None,
    T_subseq_isconstant=None,
    Q_subseq_isconstant=None,
)

Source from the content-addressed store, hash-verified

84
85
86def naive_multi_match(
87 Q,
88 T,
89 excl_zone,
90 max_distance,
91 max_matches=None,
92 T_subseq_isconstant=None,
93 Q_subseq_isconstant=None,
94):
95 m = Q.shape[-1]
96 T_subseq_isconstant = naive.rolling_isconstant(T, m, T_subseq_isconstant)
97 Q_subseq_isconstant = naive.rolling_isconstant(Q, m, Q_subseq_isconstant)
98
99 d, n = T.shape
100 D_total = np.zeros(n - m + 1, np.float64)
101 for i in range(d):
102 D = naive.distance_profile(Q[i], T[i], m)
103 D[np.isnan(D)] = np.inf
104 for j in range(len(D)):
105 if np.isfinite(D[j]):
106 if T_subseq_isconstant[i, j] and Q_subseq_isconstant[i]:
107 D[j] = 0
108 elif T_subseq_isconstant[i, j] or Q_subseq_isconstant[i]:
109 D[j] = np.sqrt(m)
110 else: # pragma: no cover
111 pass
112 D_total[:] = D_total + D
113
114 D_mean = D_total / d
115
116 return naive.find_matches(D_mean, excl_zone, max_distance, max_matches)
117
118
119def naive_match(

Callers 2

test_multi_matchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected