@@ -32,65 +32,83 @@ def test_aamp_self_join(T_A, T_B):
3232 m = 3
3333 for p in [1.0 , 2.0 , 3.0 ]:
3434 ref_mp = naive .aamp (T_B , m , p = p )
35- comp_mp = aamp (T_B , m , p = p )
35+ cmp_mp = aamp (T_B , m , p = p )
3636 naive .replace_inf (ref_mp )
37- naive .replace_inf (comp_mp )
38- npt .assert_almost_equal (ref_mp , comp_mp )
37+ naive .replace_inf (cmp_mp )
38+ npt .assert_allclose (
39+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
40+ )
3941
40- comp_mp = aamp (pd .Series (T_B ), m , p = p )
41- naive .replace_inf (comp_mp )
42- npt .assert_almost_equal (ref_mp , comp_mp )
42+ cmp_mp = aamp (pd .Series (T_B ), m , p = p )
43+ naive .replace_inf (cmp_mp )
44+ npt .assert_allclose (
45+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
46+ )
4347
4448
4549@pytest .mark .parametrize ("T_A, T_B" , test_data )
4650def test_aamp_A_B_join (T_A , T_B ):
4751 m = 3
4852 for p in [1.0 , 2.0 , 3.0 ]:
4953 ref_mp = naive .aamp (T_A , m , T_B = T_B , p = p )
50- comp_mp = aamp (T_A , m , T_B , ignore_trivial = False , p = p )
54+ cmp_mp = aamp (T_A , m , T_B , ignore_trivial = False , p = p )
5155 naive .replace_inf (ref_mp )
52- naive .replace_inf (comp_mp )
53- npt .assert_almost_equal (ref_mp , comp_mp )
56+ naive .replace_inf (cmp_mp )
57+ npt .assert_allclose (
58+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
59+ )
5460
55- comp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False , p = p )
56- naive .replace_inf (comp_mp )
57- npt .assert_almost_equal (ref_mp , comp_mp )
61+ cmp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False , p = p )
62+ naive .replace_inf (cmp_mp )
63+ npt .assert_allclose (
64+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
65+ )
5866
5967
6068def test_aamp_constant_subsequence_self_join ():
6169 T_A = np .concatenate ((np .zeros (20 , dtype = np .float64 ), np .ones (5 , dtype = np .float64 )))
6270 m = 3
6371 ref_mp = naive .aamp (T_A , m )
64- comp_mp = aamp (T_A , m , ignore_trivial = True )
72+ cmp_mp = aamp (T_A , m , ignore_trivial = True )
6573 naive .replace_inf (ref_mp )
66- naive .replace_inf (comp_mp )
67- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
74+ naive .replace_inf (cmp_mp )
75+ npt .assert_allclose (
76+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
77+ ) # ignore indices
6878
69- comp_mp = aamp (pd .Series (T_A ), m , ignore_trivial = True )
70- naive .replace_inf (comp_mp )
71- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
79+ cmp_mp = aamp (pd .Series (T_A ), m , ignore_trivial = True )
80+ naive .replace_inf (cmp_mp )
81+ npt .assert_allclose (
82+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
83+ ) # ignore indices
7284
7385
7486def test_aamp_one_constant_subsequence_A_B_join ():
7587 T_A = rng .RNG .random (20 )
7688 T_B = np .concatenate ((np .zeros (20 , dtype = np .float64 ), np .ones (5 , dtype = np .float64 )))
7789 m = 3
7890 ref_mp = naive .aamp (T_A , m , T_B = T_B )
79- comp_mp = aamp (T_A , m , T_B , ignore_trivial = False )
91+ cmp_mp = aamp (T_A , m , T_B , ignore_trivial = False )
8092 naive .replace_inf (ref_mp )
81- naive .replace_inf (comp_mp )
82- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
93+ naive .replace_inf (cmp_mp )
94+ npt .assert_allclose (
95+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
96+ ) # ignore indices
8397
84- comp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False )
85- naive .replace_inf (comp_mp )
86- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
98+ cmp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False )
99+ naive .replace_inf (cmp_mp )
100+ npt .assert_allclose (
101+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
102+ ) # ignore indices
87103
88104 # Swap inputs
89105 ref_mp = naive .aamp (T_B , m , T_B = T_A )
90- comp_mp = aamp (T_B , m , T_A , ignore_trivial = False )
106+ cmp_mp = aamp (T_B , m , T_A , ignore_trivial = False )
91107 naive .replace_inf (ref_mp )
92- naive .replace_inf (comp_mp )
93- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
108+ naive .replace_inf (cmp_mp )
109+ npt .assert_allclose (
110+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
111+ ) # ignore indices
94112
95113
96114def test_aamp_two_constant_subsequences_A_B_join ():
@@ -100,25 +118,33 @@ def test_aamp_two_constant_subsequences_A_B_join():
100118 T_B = np .concatenate ((np .zeros (20 , dtype = np .float64 ), np .ones (5 , dtype = np .float64 )))
101119 m = 3
102120 ref_mp = naive .aamp (T_A , m , T_B = T_B )
103- comp_mp = aamp (T_A , m , T_B , ignore_trivial = False )
121+ cmp_mp = aamp (T_A , m , T_B , ignore_trivial = False )
104122 naive .replace_inf (ref_mp )
105- naive .replace_inf (comp_mp )
106- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
123+ naive .replace_inf (cmp_mp )
124+ npt .assert_allclose (
125+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
126+ ) # ignore indices
107127
108- comp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False )
109- naive .replace_inf (comp_mp )
110- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
128+ cmp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False )
129+ naive .replace_inf (cmp_mp )
130+ npt .assert_allclose (
131+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
132+ ) # ignore indices
111133
112134 # Swap inputs
113135 ref_mp = naive .aamp (T_B , m , T_B = T_A )
114- comp_mp = aamp (T_B , m , T_A , ignore_trivial = False )
136+ cmp_mp = aamp (T_B , m , T_A , ignore_trivial = False )
115137 naive .replace_inf (ref_mp )
116- naive .replace_inf (comp_mp )
117- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
138+ naive .replace_inf (cmp_mp )
139+ npt .assert_allclose (
140+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
141+ ) # ignore indices
118142
119- comp_mp = aamp (pd .Series (T_B ), m , pd .Series (T_A ), ignore_trivial = False )
120- naive .replace_inf (comp_mp )
121- npt .assert_almost_equal (ref_mp [:, 0 ], comp_mp [:, 0 ]) # ignore indices
143+ cmp_mp = aamp (pd .Series (T_B ), m , pd .Series (T_A ), ignore_trivial = False )
144+ naive .replace_inf (cmp_mp )
145+ npt .assert_allclose (
146+ cmp_mp [:, 0 ].astype (np .float64 ), ref_mp [:, 0 ].astype (np .float64 ), atol = 1.5e-07
147+ ) # ignore indices
122148
123149
124150def test_aamp_identical_subsequence_self_join ():
@@ -128,17 +154,21 @@ def test_aamp_identical_subsequence_self_join():
128154 T_A [11 : 11 + identical .shape [0 ]] = identical
129155 m = 3
130156 ref_mp = naive .aamp (T_A , m )
131- comp_mp = aamp (T_A , m , ignore_trivial = True )
157+ cmp_mp = aamp (T_A , m , ignore_trivial = True )
132158 naive .replace_inf (ref_mp )
133- naive .replace_inf (comp_mp )
134- npt .assert_almost_equal (
135- ref_mp [:, 0 ], comp_mp [:, 0 ], decimal = config .STUMPY_TEST_PRECISION
159+ naive .replace_inf (cmp_mp )
160+ npt .assert_allclose (
161+ cmp_mp [:, 0 ].astype (np .float64 ),
162+ ref_mp [:, 0 ].astype (np .float64 ),
163+ atol = 1.5 * 10 ** - config .STUMPY_TEST_PRECISION ,
136164 ) # ignore indices
137165
138- comp_mp = aamp (pd .Series (T_A ), m , ignore_trivial = True )
139- naive .replace_inf (comp_mp )
140- npt .assert_almost_equal (
141- ref_mp [:, 0 ], comp_mp [:, 0 ], decimal = config .STUMPY_TEST_PRECISION
166+ cmp_mp = aamp (pd .Series (T_A ), m , ignore_trivial = True )
167+ naive .replace_inf (cmp_mp )
168+ npt .assert_allclose (
169+ cmp_mp [:, 0 ].astype (np .float64 ),
170+ ref_mp [:, 0 ].astype (np .float64 ),
171+ atol = 1.5 * 10 ** - config .STUMPY_TEST_PRECISION ,
142172 ) # ignore indices
143173
144174
@@ -150,26 +180,32 @@ def test_aamp_identical_subsequence_A_B_join():
150180 T_B [11 : 11 + identical .shape [0 ]] = identical
151181 m = 3
152182 ref_mp = naive .aamp (T_A , m , T_B = T_B )
153- comp_mp = aamp (T_A , m , T_B , ignore_trivial = False )
183+ cmp_mp = aamp (T_A , m , T_B , ignore_trivial = False )
154184 naive .replace_inf (ref_mp )
155- naive .replace_inf (comp_mp )
156- npt .assert_almost_equal (
157- ref_mp [:, 0 ], comp_mp [:, 0 ], config .STUMPY_TEST_PRECISION
185+ naive .replace_inf (cmp_mp )
186+ npt .assert_allclose (
187+ cmp_mp [:, 0 ].astype (np .float64 ),
188+ ref_mp [:, 0 ].astype (np .float64 ),
189+ atol = 1.5 * 10 ** - config .STUMPY_TEST_PRECISION ,
158190 ) # ignore indices
159191
160- comp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False )
161- naive .replace_inf (comp_mp )
162- npt .assert_almost_equal (
163- ref_mp [:, 0 ], comp_mp [:, 0 ], config .STUMPY_TEST_PRECISION
192+ cmp_mp = aamp (pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False )
193+ naive .replace_inf (cmp_mp )
194+ npt .assert_allclose (
195+ cmp_mp [:, 0 ].astype (np .float64 ),
196+ ref_mp [:, 0 ].astype (np .float64 ),
197+ atol = 1.5 * 10 ** - config .STUMPY_TEST_PRECISION ,
164198 ) # ignore indices
165199
166200 # Swap inputs
167201 ref_mp = naive .aamp (T_B , m , T_B = T_A )
168- comp_mp = aamp (T_B , m , T_A , ignore_trivial = False )
202+ cmp_mp = aamp (T_B , m , T_A , ignore_trivial = False )
169203 naive .replace_inf (ref_mp )
170- naive .replace_inf (comp_mp )
171- npt .assert_almost_equal (
172- ref_mp [:, 0 ], comp_mp [:, 0 ], config .STUMPY_TEST_PRECISION
204+ naive .replace_inf (cmp_mp )
205+ npt .assert_allclose (
206+ cmp_mp [:, 0 ].astype (np .float64 ),
207+ ref_mp [:, 0 ].astype (np .float64 ),
208+ atol = 1.5 * 10 ** - config .STUMPY_TEST_PRECISION ,
173209 ) # ignore indices
174210
175211
@@ -186,14 +222,18 @@ def test_aamp_nan_inf_self_join(T_A, T_B, substitute_B, substitution_locations):
186222 T_B_sub [substitution_location_B ] = substitute_B
187223
188224 ref_mp = naive .aamp (T_B_sub , m )
189- comp_mp = aamp (T_B_sub , m , ignore_trivial = True )
225+ cmp_mp = aamp (T_B_sub , m , ignore_trivial = True )
190226 naive .replace_inf (ref_mp )
191- naive .replace_inf (comp_mp )
192- npt .assert_almost_equal (ref_mp , comp_mp )
227+ naive .replace_inf (cmp_mp )
228+ npt .assert_allclose (
229+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
230+ )
193231
194- comp_mp = aamp (pd .Series (T_B_sub ), m , ignore_trivial = True )
195- naive .replace_inf (comp_mp )
196- npt .assert_almost_equal (ref_mp , comp_mp )
232+ cmp_mp = aamp (pd .Series (T_B_sub ), m , ignore_trivial = True )
233+ naive .replace_inf (cmp_mp )
234+ npt .assert_allclose (
235+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
236+ )
197237
198238
199239@pytest .mark .parametrize ("T_A, T_B" , test_data )
@@ -216,28 +256,34 @@ def test_aamp_nan_inf_A_B_join(
216256 T_B_sub [substitution_location_B ] = substitute_B
217257
218258 ref_mp = naive .aamp (T_A_sub , m , T_B = T_B_sub )
219- comp_mp = aamp (T_A_sub , m , T_B_sub , ignore_trivial = False )
259+ cmp_mp = aamp (T_A_sub , m , T_B_sub , ignore_trivial = False )
220260 naive .replace_inf (ref_mp )
221- naive .replace_inf (comp_mp )
222- npt .assert_almost_equal (ref_mp , comp_mp )
261+ naive .replace_inf (cmp_mp )
262+ npt .assert_allclose (
263+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
264+ )
223265
224- comp_mp = aamp (
266+ cmp_mp = aamp (
225267 pd .Series (T_A_sub ), m , pd .Series (T_B_sub ), ignore_trivial = False
226268 )
227- naive .replace_inf (comp_mp )
228- npt .assert_almost_equal (ref_mp , comp_mp )
269+ naive .replace_inf (cmp_mp )
270+ npt .assert_allclose (
271+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
272+ )
229273
230274
231275def test_aamp_nan_zero_mean_self_join ():
232276 T = np .array ([- 1 , 0 , 1 , np .inf , 1 , 0 , - 1 ])
233277 m = 3
234278
235279 ref_mp = naive .aamp (T , m )
236- comp_mp = aamp (T , m , ignore_trivial = True )
280+ cmp_mp = aamp (T , m , ignore_trivial = True )
237281
238282 naive .replace_inf (ref_mp )
239- naive .replace_inf (comp_mp )
240- npt .assert_almost_equal (ref_mp , comp_mp )
283+ naive .replace_inf (cmp_mp )
284+ npt .assert_allclose (
285+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
286+ )
241287
242288
243289@pytest .mark .parametrize ("T_A, T_B" , test_data )
@@ -246,14 +292,18 @@ def test_aamp_self_join_KNN(T_A, T_B):
246292 for k in range (2 , 4 ):
247293 for p in [1.0 , 2.0 , 3.0 ]:
248294 ref_mp = naive .aamp (T_B , m , p = p , k = k )
249- comp_mp = aamp (T_B , m , p = p , k = k )
295+ cmp_mp = aamp (T_B , m , p = p , k = k )
250296 naive .replace_inf (ref_mp )
251- naive .replace_inf (comp_mp )
252- npt .assert_almost_equal (ref_mp , comp_mp )
297+ naive .replace_inf (cmp_mp )
298+ npt .assert_allclose (
299+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
300+ )
253301
254- comp_mp = aamp (pd .Series (T_B ), m , p = p , k = k )
255- naive .replace_inf (comp_mp )
256- npt .assert_almost_equal (ref_mp , comp_mp )
302+ cmp_mp = aamp (pd .Series (T_B ), m , p = p , k = k )
303+ naive .replace_inf (cmp_mp )
304+ npt .assert_allclose (
305+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
306+ )
257307
258308
259309@pytest .mark .parametrize ("T_A, T_B" , test_data )
@@ -262,13 +312,17 @@ def test_aamp_A_B_join_KNN(T_A, T_B):
262312 for k in range (2 , 4 ):
263313 for p in [1.0 , 2.0 , 3.0 ]:
264314 ref_mp = naive .aamp (T_A , m , T_B = T_B , p = p , k = k )
265- comp_mp = aamp (T_A , m , T_B , ignore_trivial = False , p = p , k = k )
315+ cmp_mp = aamp (T_A , m , T_B , ignore_trivial = False , p = p , k = k )
266316 naive .replace_inf (ref_mp )
267- naive .replace_inf (comp_mp )
268- npt .assert_almost_equal (ref_mp , comp_mp )
317+ naive .replace_inf (cmp_mp )
318+ npt .assert_allclose (
319+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
320+ )
269321
270- comp_mp = aamp (
322+ cmp_mp = aamp (
271323 pd .Series (T_A ), m , pd .Series (T_B ), ignore_trivial = False , p = p , k = k
272324 )
273- naive .replace_inf (comp_mp )
274- npt .assert_almost_equal (ref_mp , comp_mp )
325+ naive .replace_inf (cmp_mp )
326+ npt .assert_allclose (
327+ cmp_mp .astype (np .float64 ), ref_mp .astype (np .float64 ), atol = 1.5e-07
328+ )
0 commit comments