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

Function naive_right_mp

tests/test_floss.py:51–81  ·  view source on GitHub ↗
(T, m, normalize=True, p=2.0, T_subseq_isconstant=None)

Source from the content-addressed store, hash-verified

49
50
51def naive_right_mp(T, m, normalize=True, p=2.0, T_subseq_isconstant=None):
52 # computing `T_subseq_isconstant` boolean array
53 T_subseq_isconstant = naive.rolling_isconstant(T, m, T_subseq_isconstant)
54
55 if normalize:
56 mp = stump(T_A=T, m=m, T_A_subseq_isconstant=T_subseq_isconstant)
57 else:
58 mp = aamp(T, m, p=p)
59 k = mp.shape[0]
60 right_nn = np.zeros((k, m))
61 right_indices = [np.arange(IR, IR + m) for IR in mp[:, 3].tolist()]
62 right_nn[:] = T[np.array(right_indices)]
63 if normalize:
64 mp[:, 0] = np.linalg.norm(
65 core.z_norm(core.rolling_window(T, m), 1) - core.z_norm(right_nn, 1),
66 axis=1,
67 )
68 for i, nn_i in enumerate(mp[:, 3]):
69 if T_subseq_isconstant[i] and T_subseq_isconstant[nn_i]:
70 mp[i, 0] = 0
71 elif T_subseq_isconstant[i] or T_subseq_isconstant[nn_i]:
72 mp[i, 0] = np.sqrt(m)
73 else: # pragma: no cover
74 pass
75 else:
76 mp[:, 0] = np.linalg.norm(core.rolling_window(T, m) - right_nn, axis=1, ord=p)
77 inf_indices = np.argwhere(mp[:, 3] < 0).flatten()
78 mp[inf_indices, 0] = np.inf
79 mp[inf_indices, 3] = inf_indices
80
81 return mp
82
83
84def naive_rea(cac, n_regimes, L, excl_factor):

Callers 5

test_flossFunction · 0.85
test_aamp_flossFunction · 0.85
test_floss_inf_nanFunction · 0.85
test_aamp_floss_inf_nanFunction · 0.85

Calls 2

stumpFunction · 0.90
aampFunction · 0.90

Tested by

no test coverage detected