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

Function test_aampi_self_join

tests/test_aampi.py:19–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18
19def test_aampi_self_join():
20 m = 3
21
22 for p in [1.0, 2.0, 3.0]:
23 seed = np.random.randint(100000)
24 np.random.seed(seed)
25
26 n = 30
27 T = np.random.rand(n)
28 stream = aampi(T, m, egress=False, p=p)
29 for i in range(34):
30 t = np.random.rand()
31 stream.update(t)
32
33 comp_P = stream.P_
34 comp_I = stream.I_
35 comp_left_P = stream.left_P_
36 comp_left_I = stream.left_I_
37
38 ref_mp = naive.aamp(stream.T_, m, p=p)
39 ref_P = ref_mp[:, 0]
40 ref_I = ref_mp[:, 1]
41 ref_left_P = np.full(ref_P.shape, np.inf)
42 ref_left_I = ref_mp[:, 2]
43 for i, j in enumerate(ref_left_I):
44 if j >= 0:
45 ref_left_P[i] = np.linalg.norm(
46 stream.T_[i : i + m] - stream.T_[j : j + m], ord=p
47 )
48
49 naive.replace_inf(ref_P)
50 naive.replace_inf(ref_left_P)
51 naive.replace_inf(comp_P)
52 naive.replace_inf(comp_left_P)
53
54 npt.assert_almost_equal(ref_P, comp_P)
55 npt.assert_almost_equal(ref_I, comp_I)
56 npt.assert_almost_equal(ref_left_P, comp_left_P)
57 npt.assert_almost_equal(ref_left_I, comp_left_I)
58
59 np.random.seed(seed)
60 n = 30
61 T = np.random.rand(n)
62 T = pd.Series(T)
63 stream = aampi(T, m, egress=False, p=p)
64 for i in range(34):
65 t = np.random.rand()
66 stream.update(t)
67
68 comp_P = stream.P_
69 comp_I = stream.I_
70 comp_left_P = stream.left_P_
71 comp_left_I = stream.left_I_
72
73 naive.replace_inf(comp_P)
74 naive.replace_inf(comp_left_P)
75
76 npt.assert_almost_equal(ref_P, comp_P)

Callers

nothing calls this directly

Calls 2

aampiClass · 0.90
updateMethod · 0.45

Tested by

no test coverage detected