@@ -31,11 +31,11 @@ def test_random_ostinato(runs):
3131 Ts = [rng .RNG .rand (n ) for n in [64 , 128 , 256 ]]
3232
3333 ref_radius , ref_Ts_idx , ref_subseq_idx = naive .aamp_ostinato (Ts , m )
34- comp_radius , comp_Ts_idx , comp_subseq_idx = aamp_ostinato (Ts , m )
34+ cmp_radius , cmp_Ts_idx , cmp_subseq_idx = aamp_ostinato (Ts , m )
3535
36- npt .assert_almost_equal ( ref_radius , comp_radius )
37- npt .assert_almost_equal ( ref_Ts_idx , comp_Ts_idx )
38- npt .assert_almost_equal ( ref_subseq_idx , comp_subseq_idx )
36+ npt .assert_allclose ( cmp_radius , ref_radius , atol = 1.5e-07 )
37+ npt .assert_allclose ( cmp_Ts_idx , ref_Ts_idx , atol = 1.5e-07 )
38+ npt .assert_allclose ( cmp_subseq_idx , ref_subseq_idx , atol = 1.5e-07 )
3939
4040
4141@pytest .mark .parametrize ("seed" , [41 , 88 , 290 , 292 , 310 , 328 , 538 , 556 , 563 , 570 ])
@@ -47,11 +47,11 @@ def test_deterministic_ostinato(seed):
4747
4848 for p in [1.0 , 2.0 , 3.0 ]:
4949 ref_radius , ref_Ts_idx , ref_subseq_idx = naive .aamp_ostinato (Ts , m , p = p )
50- comp_radius , comp_Ts_idx , comp_subseq_idx = aamp_ostinato (Ts , m , p = p )
50+ cmp_radius , cmp_Ts_idx , cmp_subseq_idx = aamp_ostinato (Ts , m , p = p )
5151
52- npt .assert_almost_equal ( ref_radius , comp_radius )
53- npt .assert_almost_equal ( ref_Ts_idx , comp_Ts_idx )
54- npt .assert_almost_equal ( ref_subseq_idx , comp_subseq_idx )
52+ npt .assert_allclose ( cmp_radius , ref_radius , atol = 1.5e-07 )
53+ npt .assert_allclose ( cmp_Ts_idx , ref_Ts_idx , atol = 1.5e-07 )
54+ npt .assert_allclose ( cmp_subseq_idx , ref_subseq_idx , atol = 1.5e-07 )
5555
5656
5757@pytest .mark .parametrize ("runs" , range (25 ))
@@ -61,11 +61,11 @@ def test_random_ostinatoed(runs, dask_cluster):
6161 Ts = [rng .RNG .rand (n ) for n in [64 , 128 , 256 ]]
6262
6363 ref_radius , ref_Ts_idx , ref_subseq_idx = naive .aamp_ostinato (Ts , m )
64- comp_radius , comp_Ts_idx , comp_subseq_idx = aamp_ostinatoed (dask_client , Ts , m )
64+ cmp_radius , cmp_Ts_idx , cmp_subseq_idx = aamp_ostinatoed (dask_client , Ts , m )
6565
66- npt .assert_almost_equal ( ref_radius , comp_radius )
67- npt .assert_almost_equal ( ref_Ts_idx , comp_Ts_idx )
68- npt .assert_almost_equal ( ref_subseq_idx , comp_subseq_idx )
66+ npt .assert_allclose ( cmp_radius , ref_radius , atol = 1.5e-07 )
67+ npt .assert_allclose ( cmp_Ts_idx , ref_Ts_idx , atol = 1.5e-07 )
68+ npt .assert_allclose ( cmp_subseq_idx , ref_subseq_idx , atol = 1.5e-07 )
6969
7070
7171@pytest .mark .parametrize ("seed" , [41 , 88 , 290 , 292 , 310 , 328 , 538 , 556 , 563 , 570 ])
@@ -78,13 +78,13 @@ def test_deterministic_ostinatoed(seed, dask_cluster):
7878
7979 for p in [1.0 , 2.0 , 3.0 ]:
8080 ref_radius , ref_Ts_idx , ref_subseq_idx = naive .aamp_ostinato (Ts , m , p = p )
81- comp_radius , comp_Ts_idx , comp_subseq_idx = aamp_ostinatoed (
81+ cmp_radius , cmp_Ts_idx , cmp_subseq_idx = aamp_ostinatoed (
8282 dask_client , Ts , m , p = p
8383 )
8484
85- npt .assert_almost_equal ( ref_radius , comp_radius )
86- npt .assert_almost_equal ( ref_Ts_idx , comp_Ts_idx )
87- npt .assert_almost_equal ( ref_subseq_idx , comp_subseq_idx )
85+ npt .assert_allclose ( cmp_radius , ref_radius , atol = 1.5e-07 )
86+ npt .assert_allclose ( cmp_Ts_idx , ref_Ts_idx , atol = 1.5e-07 )
87+ npt .assert_allclose ( cmp_subseq_idx , ref_subseq_idx , atol = 1.5e-07 )
8888
8989
9090def test_input_not_overwritten_ostinato ():
@@ -101,42 +101,46 @@ def test_input_not_overwritten_ostinato():
101101 aamp_ostinato (Ts_input , m )
102102 for i in range (len (Ts )):
103103 T_ref = Ts [i ]
104- T_comp = Ts_input [i ]
105- npt .assert_almost_equal (T_ref [np .isfinite (T_ref )], T_comp [np .isfinite (T_comp )])
104+ T_cmp = Ts_input [i ]
105+ npt .assert_allclose (
106+ T_cmp [np .isfinite (T_cmp )], T_ref [np .isfinite (T_ref )], atol = 1.5e-07
107+ )
106108
107109
108110def test_extract_several_consensus_ostinato ():
109111 # This test is to further ensure that the function `aamp_ostinato`
110112 # does not tamper with the original data.
111113 Ts = [rng .RNG .rand (n ) for n in [256 , 512 , 1024 ]]
112114 Ts_ref = [T .copy () for T in Ts ]
113- Ts_comp = [T .copy () for T in Ts ]
115+ Ts_cmp = [T .copy () for T in Ts ]
114116
115117 m = 20
116118
117119 k = 5 # Get the first `k` consensus motifs
118120 for _ in range (k ):
119- # Find consensus motif and its NN in each time series in Ts_comp
120- # Remove them from Ts_comp as well as Ts_ref, and assert that the
121+ # Find consensus motif and its NN in each time series in Ts_cmp
122+ # Remove them from Ts_cmp as well as Ts_ref, and assert that the
121123 # two time series are the same
122- radius , Ts_idx , subseq_idx = aamp_ostinato (Ts_comp , m )
123- consensus_motif = Ts_comp [Ts_idx ][subseq_idx : subseq_idx + m ].copy ()
124- for i in range (len (Ts_comp )):
124+ radius , Ts_idx , subseq_idx = aamp_ostinato (Ts_cmp , m )
125+ consensus_motif = Ts_cmp [Ts_idx ][subseq_idx : subseq_idx + m ].copy ()
126+ for i in range (len (Ts_cmp )):
125127 if i == Ts_idx :
126128 query_idx = subseq_idx
127129 else :
128130 query_idx = None
129131
130132 idx = np .argmin (
131133 core .mass (
132- consensus_motif , Ts_comp [i ], normalize = False , query_idx = query_idx
134+ consensus_motif , Ts_cmp [i ], normalize = False , query_idx = query_idx
133135 )
134136 )
135- Ts_comp [i ][idx : idx + m ] = np .nan
137+ Ts_cmp [i ][idx : idx + m ] = np .nan
136138 Ts_ref [i ][idx : idx + m ] = np .nan
137139
138- npt .assert_almost_equal (
139- Ts_ref [i ][np .isfinite (Ts_ref [i ])], Ts_comp [i ][np .isfinite (Ts_comp [i ])]
140+ npt .assert_allclose (
141+ Ts_cmp [i ][np .isfinite (Ts_cmp [i ])],
142+ Ts_ref [i ][np .isfinite (Ts_ref [i ])],
143+ atol = 1.5e-07 ,
140144 )
141145
142146
@@ -155,9 +159,9 @@ def test_input_not_overwritten_ostinatoed(dask_cluster):
155159 aamp_ostinatoed (dask_client , Ts_input , m )
156160 for i in range (len (Ts )):
157161 T_ref = Ts [i ]
158- T_comp = Ts_input [i ]
159- npt .assert_almost_equal (
160- T_ref [np .isfinite (T_ref )], T_comp [np .isfinite (T_comp )]
162+ T_cmp = Ts_input [i ]
163+ npt .assert_allclose (
164+ T_cmp [np .isfinite (T_cmp )], T_ref [np .isfinite (T_ref )], atol = 1.5e-07
161165 )
162166
163167
@@ -166,19 +170,19 @@ def test_extract_several_consensus_ostinatoed(dask_cluster):
166170 # does not tamper with the original data.
167171 Ts = [rng .RNG .rand (n ) for n in [256 , 512 , 1024 ]]
168172 Ts_ref = [T .copy () for T in Ts ]
169- Ts_comp = [T .copy () for T in Ts ]
173+ Ts_cmp = [T .copy () for T in Ts ]
170174
171175 m = 20
172176
173177 with Client (dask_cluster ) as dask_client :
174178 k = 5 # Get the first `k` consensus motifs
175179 for _ in range (k ):
176- # Find consensus motif and its NN in each time series in Ts_comp
177- # Remove them from Ts_comp as well as Ts_ref, and assert that the
180+ # Find consensus motif and its NN in each time series in Ts_cmp
181+ # Remove them from Ts_cmp as well as Ts_ref, and assert that the
178182 # two time series are the same
179- radius , Ts_idx , subseq_idx = aamp_ostinatoed (dask_client , Ts_comp , m )
180- consensus_motif = Ts_comp [Ts_idx ][subseq_idx : subseq_idx + m ].copy ()
181- for i in range (len (Ts_comp )):
183+ radius , Ts_idx , subseq_idx = aamp_ostinatoed (dask_client , Ts_cmp , m )
184+ consensus_motif = Ts_cmp [Ts_idx ][subseq_idx : subseq_idx + m ].copy ()
185+ for i in range (len (Ts_cmp )):
182186 if i == Ts_idx :
183187 query_idx = subseq_idx
184188 else :
@@ -187,15 +191,16 @@ def test_extract_several_consensus_ostinatoed(dask_cluster):
187191 idx = np .argmin (
188192 core .mass (
189193 consensus_motif ,
190- Ts_comp [i ],
194+ Ts_cmp [i ],
191195 normalize = False ,
192196 query_idx = query_idx ,
193197 )
194198 )
195- Ts_comp [i ][idx : idx + m ] = np .nan
199+ Ts_cmp [i ][idx : idx + m ] = np .nan
196200 Ts_ref [i ][idx : idx + m ] = np .nan
197201
198- npt .assert_almost_equal (
202+ npt .assert_allclose (
203+ Ts_cmp [i ][np .isfinite (Ts_cmp [i ])],
199204 Ts_ref [i ][np .isfinite (Ts_ref [i ])],
200- Ts_comp [ i ][ np . isfinite ( Ts_comp [ i ])] ,
205+ atol = 1.5e-07 ,
201206 )
0 commit comments