@@ -103,8 +103,8 @@ def naive_rea(cac, n_regimes, L, excl_factor):
103103@pytest .mark .parametrize ("I" , test_data )
104104def test_nnmark (I ):
105105 ref = naive_nnmark (I )
106- comp = _nnmark (I )
107- npt .assert_almost_equal ( ref , comp )
106+ cmp = _nnmark (I )
107+ npt .assert_allclose ( cmp , ref , atol = 1.5e-07 )
108108
109109
110110@pytest .mark .parametrize ("I" , test_data )
@@ -114,8 +114,8 @@ def test_cac(I):
114114 custom_iac = _iac (I .shape [0 ])
115115 ref = naive_cac (I , L , excl_factor , custom_iac )
116116 bidirectional = True
117- comp = _cac (I , L , bidirectional , excl_factor )
118- npt .assert_almost_equal ( ref , comp )
117+ cmp = _cac (I , L , bidirectional , excl_factor )
118+ npt .assert_allclose ( cmp , ref , atol = 1.5e-07 )
119119
120120
121121@pytest .mark .parametrize ("I" , test_data )
@@ -125,8 +125,8 @@ def test_cac_custom_iac(I):
125125 ref = naive_cac (I , L , excl_factor )
126126 custom_iac = naive_iac (I .shape [0 ])
127127 bidirectional = True
128- comp = _cac (I , L , bidirectional , excl_factor , custom_iac )
129- npt .assert_almost_equal ( ref , comp )
128+ cmp = _cac (I , L , bidirectional , excl_factor , custom_iac )
129+ npt .assert_allclose ( cmp , ref , atol = 1.5e-07 )
130130
131131
132132@pytest .mark .parametrize ("I" , test_data )
@@ -136,8 +136,8 @@ def test_rea(I):
136136 cac = naive_cac (I , L , excl_factor )
137137 n_regimes = 3
138138 ref = naive_rea (cac , n_regimes , L , excl_factor )
139- comp = _rea (cac , n_regimes , L , excl_factor )
140- npt .assert_almost_equal ( ref , comp )
139+ cmp = _rea (cac , n_regimes , L , excl_factor )
140+ npt .assert_allclose ( cmp , ref , atol = 1.5e-07 )
141141
142142
143143@pytest .mark .parametrize ("I" , test_data )
@@ -148,9 +148,9 @@ def test_fluss(I):
148148 ref_cac = naive_cac (I , L , excl_factor )
149149 n_regimes = 3
150150 ref_rea = naive_rea (ref_cac , n_regimes , L , excl_factor )
151- comp_cac , comp_rea = fluss (I , L , n_regimes , excl_factor , custom_iac )
152- npt .assert_almost_equal ( ref_cac , comp_cac )
153- npt .assert_almost_equal ( ref_rea , comp_rea )
151+ cmp_cac , cmp_rea = fluss (I , L , n_regimes , excl_factor , custom_iac )
152+ npt .assert_allclose ( cmp_cac , ref_cac , atol = 1.5e-07 )
153+ npt .assert_allclose ( cmp_rea , ref_rea , atol = 1.5e-07 )
154154
155155
156156def test_floss ():
@@ -160,14 +160,14 @@ def test_floss():
160160 old_data = data [:n ]
161161
162162 mp = naive_right_mp (old_data , m )
163- comp_mp = stump (old_data , m )
163+ cmp_mp = stump (old_data , m )
164164 k = mp .shape [0 ]
165165
166166 rolling_Ts = core .rolling_window (data [1 :], n )
167167 L = 5
168168 excl_factor = 1
169169 custom_iac = _iac (k , bidirectional = False )
170- stream = floss (comp_mp , old_data , m , L , excl_factor , custom_iac = custom_iac )
170+ stream = floss (cmp_mp , old_data , m , L , excl_factor , custom_iac = custom_iac )
171171 last_idx = n - m + 1
172172 excl_zone = int (np .ceil (m / 4 ))
173173 zone_start = max (0 , k - excl_zone )
@@ -199,19 +199,23 @@ def test_floss():
199199 ref_I [ref_mp [:, 0 ] == np .inf ] = - 1
200200
201201 stream .update (ref_T [- 1 ])
202- comp_cac_1d = stream .cac_1d_
203- comp_P = stream .P_
202+ cmp_cac_1d = stream .cac_1d_
203+ cmp_P = stream .P_
204204
205- comp_I = stream .I_
206- comp_T = stream .T_
205+ cmp_I = stream .I_
206+ cmp_T = stream .T_
207207
208208 naive .replace_inf (ref_P )
209- naive .replace_inf (comp_P )
209+ naive .replace_inf (cmp_P )
210210
211- npt .assert_almost_equal (ref_cac_1d , comp_cac_1d )
212- npt .assert_almost_equal (ref_P , comp_P )
213- npt .assert_almost_equal (ref_I , comp_I )
214- npt .assert_almost_equal (ref_T , comp_T )
211+ npt .assert_allclose (cmp_cac_1d , ref_cac_1d , atol = 1.5e-07 )
212+ npt .assert_allclose (
213+ cmp_P .astype (np .float64 ), ref_P .astype (np .float64 ), atol = 1.5e-07
214+ )
215+ npt .assert_allclose (
216+ cmp_I .astype (np .float64 ), ref_I .astype (np .float64 ), atol = 1.5e-07
217+ )
218+ npt .assert_allclose (cmp_T , ref_T , atol = 1.5e-07 )
215219
216220
217221def test_aamp_floss ():
@@ -222,15 +226,15 @@ def test_aamp_floss():
222226
223227 for p in range (1 , 4 ):
224228 mp = naive_right_mp (old_data , m , normalize = False , p = p )
225- comp_mp = aamp (old_data , m , p = p )
229+ cmp_mp = aamp (old_data , m , p = p )
226230 k = mp .shape [0 ]
227231
228232 rolling_Ts = core .rolling_window (data [1 :], n )
229233 L = 5
230234 excl_factor = 1
231235 custom_iac = _iac (k , bidirectional = False )
232236 stream = floss (
233- comp_mp ,
237+ cmp_mp ,
234238 old_data ,
235239 m ,
236240 L ,
@@ -270,18 +274,22 @@ def test_aamp_floss():
270274 ref_I [ref_mp [:, 0 ] == np .inf ] = - 1
271275
272276 stream .update (ref_T [- 1 ])
273- comp_cac_1d = stream .cac_1d_
274- comp_P = stream .P_
275- comp_I = stream .I_
276- comp_T = stream .T_
277+ cmp_cac_1d = stream .cac_1d_
278+ cmp_P = stream .P_
279+ cmp_I = stream .I_
280+ cmp_T = stream .T_
277281
278282 naive .replace_inf (ref_P )
279- naive .replace_inf (comp_P )
283+ naive .replace_inf (cmp_P )
280284
281- npt .assert_almost_equal (ref_cac_1d , comp_cac_1d )
282- npt .assert_almost_equal (ref_P , comp_P )
283- npt .assert_almost_equal (ref_I , comp_I )
284- npt .assert_almost_equal (ref_T , comp_T )
285+ npt .assert_allclose (cmp_cac_1d , ref_cac_1d , atol = 1.5e-07 )
286+ npt .assert_allclose (
287+ cmp_P .astype (np .float64 ), ref_P .astype (np .float64 ), atol = 1.5e-07
288+ )
289+ npt .assert_allclose (
290+ cmp_I .astype (np .float64 ), ref_I .astype (np .float64 ), atol = 1.5e-07
291+ )
292+ npt .assert_allclose (cmp_T , ref_T , atol = 1.5e-07 )
285293
286294
287295@pytest .mark .parametrize ("substitute" , substitution_values )
@@ -297,14 +305,14 @@ def test_floss_inf_nan(substitute, substitution_locations):
297305 old_data = data [:n ]
298306
299307 mp = naive_right_mp (old_data , m )
300- comp_mp = stump (old_data , m )
308+ cmp_mp = stump (old_data , m )
301309 k = mp .shape [0 ]
302310
303311 rolling_Ts = core .rolling_window (data [1 :], n )
304312 L = 5
305313 excl_factor = 1
306314 custom_iac = _iac (k , bidirectional = False )
307- stream = floss (comp_mp , old_data , m , L , excl_factor , custom_iac = custom_iac )
315+ stream = floss (cmp_mp , old_data , m , L , excl_factor , custom_iac = custom_iac )
308316 last_idx = n - m + 1
309317 excl_zone = int (np .ceil (m / 4 ))
310318 zone_start = max (0 , k - excl_zone )
@@ -342,18 +350,22 @@ def test_floss_inf_nan(substitute, substitution_locations):
342350 ref_I [ref_mp [:, 0 ] == np .inf ] = - 1
343351
344352 stream .update (ref_T [- 1 ])
345- comp_cac_1d = stream .cac_1d_
346- comp_P = stream .P_
347- comp_I = stream .I_
348- comp_T = stream .T_
353+ cmp_cac_1d = stream .cac_1d_
354+ cmp_P = stream .P_
355+ cmp_I = stream .I_
356+ cmp_T = stream .T_
349357
350358 naive .replace_inf (ref_P )
351- naive .replace_inf (comp_P )
359+ naive .replace_inf (cmp_P )
352360
353- npt .assert_almost_equal (ref_cac_1d , comp_cac_1d )
354- npt .assert_almost_equal (ref_P , comp_P )
355- npt .assert_almost_equal (ref_I , comp_I )
356- npt .assert_almost_equal (ref_T , comp_T )
361+ npt .assert_allclose (cmp_cac_1d , ref_cac_1d , atol = 1.5e-07 )
362+ npt .assert_allclose (
363+ cmp_P .astype (np .float64 ), ref_P .astype (np .float64 ), atol = 1.5e-07
364+ )
365+ npt .assert_allclose (
366+ cmp_I .astype (np .float64 ), ref_I .astype (np .float64 ), atol = 1.5e-07
367+ )
368+ npt .assert_allclose (cmp_T , ref_T , atol = 1.5e-07 )
357369
358370
359371@pytest .mark .parametrize ("substitute" , substitution_values )
@@ -369,15 +381,15 @@ def test_aamp_floss_inf_nan(substitute, substitution_locations):
369381 old_data = data [:n ]
370382
371383 mp = naive_right_mp (old_data , m , normalize = False )
372- comp_mp = aamp (old_data , m )
384+ cmp_mp = aamp (old_data , m )
373385 k = mp .shape [0 ]
374386
375387 rolling_Ts = core .rolling_window (data [1 :], n )
376388 L = 5
377389 excl_factor = 1
378390 custom_iac = _iac (k , bidirectional = False )
379391 stream = floss (
380- comp_mp , old_data , m , L , excl_factor , custom_iac = custom_iac , normalize = False
392+ cmp_mp , old_data , m , L , excl_factor , custom_iac = custom_iac , normalize = False
381393 )
382394 last_idx = n - m + 1
383395 excl_zone = int (np .ceil (m / 4 ))
@@ -416,18 +428,22 @@ def test_aamp_floss_inf_nan(substitute, substitution_locations):
416428 ref_I [ref_mp [:, 0 ] == np .inf ] = - 1
417429
418430 stream .update (ref_T [- 1 ])
419- comp_cac_1d = stream .cac_1d_
420- comp_P = stream .P_
421- comp_I = stream .I_
422- comp_T = stream .T_
431+ cmp_cac_1d = stream .cac_1d_
432+ cmp_P = stream .P_
433+ cmp_I = stream .I_
434+ cmp_T = stream .T_
423435
424436 naive .replace_inf (ref_P )
425- naive .replace_inf (comp_P )
437+ naive .replace_inf (cmp_P )
426438
427- npt .assert_almost_equal (ref_cac_1d , comp_cac_1d )
428- npt .assert_almost_equal (ref_P , comp_P )
429- npt .assert_almost_equal (ref_I , comp_I )
430- npt .assert_almost_equal (ref_T , comp_T )
439+ npt .assert_allclose (cmp_cac_1d , ref_cac_1d , atol = 1.5e-07 )
440+ npt .assert_allclose (
441+ cmp_P .astype (np .float64 ), ref_P .astype (np .float64 ), atol = 1.5e-07
442+ )
443+ npt .assert_allclose (
444+ cmp_I .astype (np .float64 ), ref_I .astype (np .float64 ), atol = 1.5e-07
445+ )
446+ npt .assert_allclose (cmp_T , ref_T , atol = 1.5e-07 )
431447
432448
433449def test_floss_with_isconstant ():
@@ -445,15 +461,15 @@ def test_floss_with_isconstant():
445461 )
446462
447463 mp = naive_right_mp (T = old_data , m = m , T_subseq_isconstant = isconstant_custom_func )
448- comp_mp = stump (T_A = old_data , m = m , T_A_subseq_isconstant = isconstant_custom_func )
464+ cmp_mp = stump (T_A = old_data , m = m , T_A_subseq_isconstant = isconstant_custom_func )
449465 k = mp .shape [0 ]
450466
451467 rolling_Ts = core .rolling_window (data [1 :], n )
452468 L = 5
453469 excl_factor = 1
454470 custom_iac = _iac (k , bidirectional = False )
455471 stream = floss (
456- comp_mp ,
472+ cmp_mp ,
457473 old_data ,
458474 m ,
459475 L ,
@@ -502,15 +518,19 @@ def test_floss_with_isconstant():
502518 ref_I [ref_mp [:, 0 ] == np .inf ] = - 1
503519
504520 stream .update (ref_T [- 1 ])
505- comp_cac_1d = stream .cac_1d_
506- comp_P = stream .P_
507- comp_I = stream .I_
508- comp_T = stream .T_
521+ cmp_cac_1d = stream .cac_1d_
522+ cmp_P = stream .P_
523+ cmp_I = stream .I_
524+ cmp_T = stream .T_
509525
510526 naive .replace_inf (ref_P )
511- naive .replace_inf (comp_P )
527+ naive .replace_inf (cmp_P )
512528
513- npt .assert_almost_equal (ref_cac_1d , comp_cac_1d )
514- npt .assert_almost_equal (ref_P , comp_P )
515- npt .assert_almost_equal (ref_I , comp_I )
516- npt .assert_almost_equal (ref_T , comp_T )
529+ npt .assert_allclose (cmp_cac_1d , ref_cac_1d , atol = 1.5e-07 )
530+ npt .assert_allclose (
531+ cmp_P .astype (np .float64 ), ref_P .astype (np .float64 ), atol = 1.5e-07
532+ )
533+ npt .assert_allclose (
534+ cmp_I .astype (np .float64 ), ref_I .astype (np .float64 ), atol = 1.5e-07
535+ )
536+ npt .assert_allclose (cmp_T , ref_T , atol = 1.5e-07 )
0 commit comments