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

Function naive_match

tests/test_motifs.py:119–146  ·  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

117
118
119def naive_match(
120 Q,
121 T,
122 excl_zone,
123 max_distance,
124 max_matches=None,
125 T_subseq_isconstant=None,
126 Q_subseq_isconstant=None,
127):
128 # Q_subseq_isconstant is a boolean array of size 1
129 # this does not support multi-dim T, and Q
130
131 m = Q.shape[0]
132 T_subseq_isconstant = naive.rolling_isconstant(T, m, T_subseq_isconstant)
133 Q_subseq_isconstant = naive.rolling_isconstant(Q, m, Q_subseq_isconstant)[0]
134
135 D = naive.distance_profile(Q, T, m)
136 D[np.isnan(D)] = np.inf
137 for i in range(len(D)):
138 if np.isfinite(D[i]):
139 if T_subseq_isconstant[i] and Q_subseq_isconstant:
140 D[i] = 0
141 elif T_subseq_isconstant[i] or Q_subseq_isconstant:
142 D[i] = np.sqrt(m)
143 else: # pragma: no cover
144 pass
145
146 return naive.find_matches(D, excl_zone, max_distance, max_matches)
147
148
149test_data = [

Callers 5

test_matchFunction · 0.85
test_match_mean_stddevFunction · 0.85
test_match_isconstantFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected