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

Function test_stumpi_self_join

tests/test_stumpi.py:21–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19
20
21def test_stumpi_self_join():
22 m = 3
23 zone = int(np.ceil(m / 4))
24
25 seed = np.random.randint(100000)
26 np.random.seed(seed)
27
28 T = np.random.rand(30)
29 stream = stumpi(T, m, egress=False)
30 for i in range(34):
31 t = np.random.rand()
32 stream.update(t)
33
34 comp_P = stream.P_
35 comp_I = stream.I_
36 comp_left_P = stream.left_P_
37 comp_left_I = stream.left_I_
38
39 ref_mp = naive.stump(stream.T_, m, exclusion_zone=zone, row_wise=True)
40 ref_P = ref_mp[:, 0]
41 ref_I = ref_mp[:, 1]
42 ref_left_I = ref_mp[:, 2].astype(np.int64)
43 ref_left_P = np.full_like(ref_left_I, np.inf, dtype=np.float64)
44 for i, j in enumerate(ref_left_I):
45 if j >= 0:
46 D = core.mass(stream.T_[i : i + m], stream.T_[j : j + m])
47 ref_left_P[i] = D[0]
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 T = np.random.rand(30)
61 T = pd.Series(T)
62 stream = stumpi(T, m, egress=False)
63 for i in range(34):
64 t = np.random.rand()
65 stream.update(t)
66
67 comp_P = stream.P_
68 comp_I = stream.I_
69 comp_left_P = stream.left_P_
70 comp_left_I = stream.left_I_
71
72 naive.replace_inf(comp_P)
73 naive.replace_inf(comp_left_P)
74
75 npt.assert_almost_equal(ref_P, comp_P)
76 npt.assert_almost_equal(ref_I, comp_I)
77 npt.assert_almost_equal(ref_left_P, comp_left_P)
78 npt.assert_almost_equal(ref_left_I, comp_left_I)

Callers

nothing calls this directly

Calls 2

stumpiClass · 0.90
updateMethod · 0.45

Tested by

no test coverage detected