From 7762e9c301d28260807a74590f1492fb98b5749a Mon Sep 17 00:00:00 2001 From: viknesh-ai Date: Sun, 16 Aug 2026 20:51:09 +0530 Subject: [PATCH] Migrate tests/test_aampi.py from npt.assert_almost_equal to npt.assert_allclose --- tests/test_aampi.py | 804 ++++++++++++++++++++++++-------------------- 1 file changed, 444 insertions(+), 360 deletions(-) diff --git a/tests/test_aampi.py b/tests/test_aampi.py index 5aa3b1c8c..2b6e96fad 100644 --- a/tests/test_aampi.py +++ b/tests/test_aampi.py @@ -28,10 +28,10 @@ def test_aampi_self_join(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ - comp_left_P = stream.left_P_ - comp_left_I = stream.left_I_ + cmp_P = stream.P_ + cmp_I = stream.I_ + cmp_left_P = stream.left_P_ + cmp_left_I = stream.left_I_ ref_mp = naive.aamp(stream.T_, m, p=p) ref_P = ref_mp[:, 0] @@ -46,13 +46,25 @@ def test_aampi_self_join(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_left_P.astype(np.float64), + ref_left_P.astype(np.float64), + atol=1.5e-07, + ) + npt.assert_allclose( + cmp_left_I.astype(np.float64), + ref_left_I.astype(np.float64), + atol=1.5e-07, + ) with rng.fix_state(): n = 30 @@ -63,18 +75,30 @@ def test_aampi_self_join(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ - comp_left_P = stream.left_P_ - comp_left_I = stream.left_I_ + cmp_P = stream.P_ + cmp_I = stream.I_ + cmp_left_P = stream.left_P_ + cmp_left_I = stream.left_I_ - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_left_P.astype(np.float64), + ref_left_P.astype(np.float64), + atol=1.5e-07, + ) + npt.assert_allclose( + cmp_left_I.astype(np.float64), + ref_left_I.astype(np.float64), + atol=1.5e-07, + ) def test_aampi_self_join_egress(): @@ -93,20 +117,20 @@ def test_aampi_self_join_egress(): stream = aampi(T, m, egress=True, p=p) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() @@ -114,10 +138,10 @@ def test_aampi_self_join_egress(): ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -126,13 +150,13 @@ def test_aampi_self_join_egress(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) with rng.fix_state(): T = rng.RNG.rand(n) @@ -144,14 +168,14 @@ def test_aampi_self_join_egress(): stream = aampi(T, m, egress=True, p=p) - comp_P = stream.P_.copy() - comp_I = stream.I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() @@ -159,10 +183,10 @@ def test_aampi_self_join_egress(): ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -171,13 +195,13 @@ def test_aampi_self_join_egress(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) @pytest.mark.parametrize("substitute", substitution_values) @@ -198,8 +222,8 @@ def test_aampi_init_nan_inf_self_join(substitute, substitution_locations): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ + cmp_P = stream.P_ + cmp_I = stream.I_ stream.T_[substitution_location] = substitute ref_mp = naive.aamp(stream.T_, m) @@ -207,9 +231,13 @@ def test_aampi_init_nan_inf_self_join(substitute, substitution_locations): ref_I = ref_mp[:, 1] naive.replace_inf(ref_P) - naive.replace_inf(comp_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) + naive.replace_inf(cmp_P) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) with rng.fix_state(): n = 30 @@ -224,13 +252,17 @@ def test_aampi_init_nan_inf_self_join(substitute, substitution_locations): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ + cmp_P = stream.P_ + cmp_I = stream.I_ - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) @pytest.mark.parametrize("substitute", substitution_values) @@ -255,20 +287,20 @@ def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations) stream = aampi(T, m, egress=True) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() @@ -276,10 +308,10 @@ def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations) ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -288,13 +320,13 @@ def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations) naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) with rng.fix_state(): n = 30 @@ -309,15 +341,15 @@ def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations) stream = aampi(T, m, egress=True) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) for i in range(34): t = rng.RNG.rand() @@ -325,10 +357,10 @@ def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations) ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -337,13 +369,13 @@ def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations) naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) @pytest.mark.parametrize("substitute", substitution_values) @@ -363,8 +395,8 @@ def test_aampi_stream_nan_inf_self_join(substitute, substitution_locations): for t in T[n:]: stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ + cmp_P = stream.P_ + cmp_I = stream.I_ stream.T_[n:][substitution_location] = substitute ref_mp = naive.aamp(stream.T_, m) @@ -372,10 +404,14 @@ def test_aampi_stream_nan_inf_self_join(substitute, substitution_locations): ref_I = ref_mp[:, 1] naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) with rng.fix_state(): T = rng.RNG.rand(64) @@ -387,13 +423,17 @@ def test_aampi_stream_nan_inf_self_join(substitute, substitution_locations): for t in T[n:]: stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ + cmp_P = stream.P_ + cmp_I = stream.I_ - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) @pytest.mark.parametrize("substitute", substitution_values) @@ -414,20 +454,20 @@ def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_location stream = aampi(T[:n], m, egress=True) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) if substitution_location == -1: substitution_location = T[n:].shape[0] - 1 @@ -436,10 +476,10 @@ def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_location ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -448,13 +488,13 @@ def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_location naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) with rng.fix_state(): T = rng.RNG.rand(64) @@ -467,20 +507,20 @@ def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_location stream = aampi(pd.Series(T[:n]), m, egress=True) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) if substitution_location == -1: # pragma: no cover substitution_location = T[n:].shape[0] - 1 T[n:][substitution_location] = substitute @@ -488,10 +528,10 @@ def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_location ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -500,13 +540,13 @@ def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_location naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) def test_aampi_constant_subsequence_self_join(): @@ -521,18 +561,20 @@ def test_aampi_constant_subsequence_self_join(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - # comp_I = stream.I_ + cmp_P = stream.P_ + # cmp_I = stream.I_ ref_mp = naive.aamp(stream.T_, m) ref_P = ref_mp[:, 0] # ref_I = ref_mp[:, 1] naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P) - # npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) with rng.fix_state(): T = np.concatenate( @@ -544,13 +586,15 @@ def test_aampi_constant_subsequence_self_join(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - # comp_I = stream.I_ + cmp_P = stream.P_ + # cmp_I = stream.I_ - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P) - # npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) def test_aampi_constant_subsequence_self_join_egress(): @@ -569,30 +613,30 @@ def test_aampi_constant_subsequence_self_join_egress(): stream = aampi(T, m, egress=True) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ @@ -601,13 +645,13 @@ def test_aampi_constant_subsequence_self_join_egress(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) with rng.fix_state(): T = np.concatenate( @@ -623,30 +667,30 @@ def test_aampi_constant_subsequence_self_join_egress(): stream = aampi(T, m, egress=True) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ @@ -655,13 +699,13 @@ def test_aampi_constant_subsequence_self_join_egress(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) def test_aampi_update_constant_subsequence_self_join(): @@ -677,14 +721,16 @@ def test_aampi_update_constant_subsequence_self_join(): t = T_full[i] stream.update(t) - comp_P = stream.P_ + cmp_P = stream.P_ ref_mp = naive.aamp(stream.T_, m) ref_P = ref_mp[:, 0] naive.replace_inf(ref_P) - naive.replace_inf(comp_P) - npt.assert_almost_equal(ref_P, comp_P) + naive.replace_inf(cmp_P) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) T_full = pd.Series(T_full) T_stream = T_full[:10].copy() @@ -694,10 +740,12 @@ def test_aampi_update_constant_subsequence_self_join(): t = T_full[i] stream.update(t) - comp_P = stream.P_ + cmp_P = stream.P_ - naive.replace_inf(comp_P) - npt.assert_almost_equal(ref_P, comp_P) + naive.replace_inf(cmp_P) + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) def test_aampi_update_constant_subsequence_self_join_egress(): @@ -718,19 +766,19 @@ def test_aampi_update_constant_subsequence_self_join_egress(): ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_left_P = stream.left_P_.copy() + cmp_P = stream.P_.copy() + cmp_left_P = stream.left_P_.copy() ref_P = ref_mp.P_.copy() ref_left_P = ref_mp.left_P_.copy() naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_left_P, comp_left_P) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) T_full = pd.Series(T_full) T_stream = T_full[:10].copy() @@ -746,19 +794,19 @@ def test_aampi_update_constant_subsequence_self_join_egress(): ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_left_P = stream.left_P_.copy() + cmp_P = stream.P_.copy() + cmp_left_P = stream.left_P_.copy() ref_P = ref_mp.P_.copy() ref_left_P = ref_mp.left_P_.copy() naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_left_P, comp_left_P) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) def test_aampi_identical_subsequence_self_join(): @@ -773,18 +821,22 @@ def test_aampi_identical_subsequence_self_join(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - # comp_I = stream.I_ + cmp_P = stream.P_ + # cmp_I = stream.I_ ref_mp = naive.aamp(stream.T_, m) ref_P = ref_mp[:, 0] # ref_I = ref_mp[:, 1] naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P, decimal=config.STUMPY_TEST_PRECISION) - # npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose( + cmp_P.astype(np.float64), + ref_P.astype(np.float64), + atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + ) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) with rng.fix_state(): identical = rng.RNG.rand(8) @@ -797,13 +849,17 @@ def test_aampi_identical_subsequence_self_join(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - # comp_I = stream.I_ + cmp_P = stream.P_ + # cmp_I = stream.I_ - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P, decimal=config.STUMPY_TEST_PRECISION) - # npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose( + cmp_P.astype(np.float64), + ref_P.astype(np.float64), + atol=1.5 * 10**-config.STUMPY_TEST_PRECISION, + ) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) def test_aampi_identical_subsequence_self_join_egress(): @@ -823,32 +879,32 @@ def test_aampi_identical_subsequence_self_join_egress(): stream = aampi(T, m, egress=True) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P, decimal=config.STUMPY_TEST_PRECISION) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal( - ref_left_P, comp_left_P, decimal=config.STUMPY_TEST_PRECISION + npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose( + cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION ) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ @@ -857,15 +913,17 @@ def test_aampi_identical_subsequence_self_join_egress(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P, decimal=config.STUMPY_TEST_PRECISION) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal( - ref_left_P, comp_left_P, decimal=config.STUMPY_TEST_PRECISION + npt.assert_allclose( + cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose( + cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION ) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) with rng.fix_state(): identical = rng.RNG.rand(8) @@ -882,32 +940,32 @@ def test_aampi_identical_subsequence_self_join_egress(): stream = aampi(T, m, egress=True) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P, decimal=config.STUMPY_TEST_PRECISION) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal( - ref_left_P, comp_left_P, decimal=config.STUMPY_TEST_PRECISION + npt.assert_allclose(cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose( + cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION ) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - # comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - # comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + # cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + # cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ @@ -916,15 +974,17 @@ def test_aampi_identical_subsequence_self_join_egress(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P, decimal=config.STUMPY_TEST_PRECISION) - # npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal( - ref_left_P, comp_left_P, decimal=config.STUMPY_TEST_PRECISION + npt.assert_allclose( + cmp_P, ref_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION + ) + # npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose( + cmp_left_P, ref_left_P, atol=1.5 * 10**-config.STUMPY_TEST_PRECISION ) - # npt.assert_almost_equal(ref_left_I, comp_left_I) + # npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) def test_aampi_profile_index_match(): @@ -935,28 +995,28 @@ def test_aampi_profile_index_match(): T_stream = T_full[:warm_start].copy() stream = aampi(T_stream, m, egress=True) - P = np.full(stream.P_.shape, np.inf) - left_P = np.full(stream.left_P_.shape, np.inf) + ref_P = np.full(stream.P_.shape, np.inf) + ref_left_P = np.full(stream.left_P_.shape, np.inf) n = 0 for i in range(len(T_stream), len(T_full)): t = T_full[i] stream.update(t) - P[:] = np.inf + ref_P[:] = np.inf idx = np.argwhere(stream.I_ >= 0).flatten() - P[idx] = naive.distance( + ref_P[idx] = naive.distance( T_full_subseq[idx + n + 1], T_full_subseq[stream.I_[idx]], axis=1 ) - left_P[:] = np.inf + ref_left_P[:] = np.inf idx = np.argwhere(stream.left_I_ >= 0).flatten() - left_P[idx] = naive.distance( + ref_left_P[idx] = naive.distance( T_full_subseq[idx + n + 1], T_full_subseq[stream.left_I_[idx]], axis=1 ) - npt.assert_almost_equal(stream.P_, P) - npt.assert_almost_equal(stream.left_P_, left_P) + npt.assert_allclose(stream.P_, ref_P, atol=1.5e-07) + npt.assert_allclose(stream.left_P_, ref_left_P, atol=1.5e-07) n += 1 @@ -973,10 +1033,10 @@ def test_aampi_self_join_KNN(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ - comp_left_P = stream.left_P_ - comp_left_I = stream.left_I_ + cmp_P = stream.P_ + cmp_I = stream.I_ + cmp_left_P = stream.left_P_ + cmp_left_I = stream.left_I_ ref_mp = naive.aamp(stream.T_, m, p=p, k=k) ref_P = ref_mp[:, :k] @@ -992,13 +1052,25 @@ def test_aampi_self_join_KNN(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) - - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) + + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_left_P.astype(np.float64), + ref_left_P.astype(np.float64), + atol=1.5e-07, + ) + npt.assert_allclose( + cmp_left_I.astype(np.float64), + ref_left_I.astype(np.float64), + atol=1.5e-07, + ) with rng.fix_state(): n = 30 @@ -1009,18 +1081,30 @@ def test_aampi_self_join_KNN(): t = rng.RNG.rand() stream.update(t) - comp_P = stream.P_ - comp_I = stream.I_ - comp_left_P = stream.left_P_ - comp_left_I = stream.left_I_ - - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) - - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + cmp_P = stream.P_ + cmp_I = stream.I_ + cmp_left_P = stream.left_P_ + cmp_left_I = stream.left_I_ + + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) + + npt.assert_allclose( + cmp_P.astype(np.float64), ref_P.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_I.astype(np.float64), ref_I.astype(np.float64), atol=1.5e-07 + ) + npt.assert_allclose( + cmp_left_P.astype(np.float64), + ref_left_P.astype(np.float64), + atol=1.5e-07, + ) + npt.assert_allclose( + cmp_left_I.astype(np.float64), + ref_left_I.astype(np.float64), + atol=1.5e-07, + ) def test_aampi_self_join_egress_KNN(): @@ -1039,20 +1123,20 @@ def test_aampi_self_join_egress_KNN(): stream = aampi(T, m, egress=True, p=p, k=k) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() @@ -1060,10 +1144,10 @@ def test_aampi_self_join_egress_KNN(): ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -1072,13 +1156,13 @@ def test_aampi_self_join_egress_KNN(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) with rng.fix_state(): T = rng.RNG.rand(n) @@ -1090,14 +1174,14 @@ def test_aampi_self_join_egress_KNN(): stream = aampi(T, m, egress=True, p=p, k=k) - comp_P = stream.P_.copy() - comp_I = stream.I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ naive.replace_inf(ref_P) - naive.replace_inf(comp_P) + naive.replace_inf(cmp_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() @@ -1105,10 +1189,10 @@ def test_aampi_self_join_egress_KNN(): ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -1117,13 +1201,13 @@ def test_aampi_self_join_egress_KNN(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) def test_aampi_self_join_egress_passing_mp(): @@ -1143,20 +1227,20 @@ def test_aampi_self_join_egress_passing_mp(): stream = aampi(T, m, egress=True, p=p, mp=mp) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07) for i in range(34): t = rng.RNG.rand() @@ -1164,10 +1248,10 @@ def test_aampi_self_join_egress_passing_mp(): ref_mp.update(t) stream.update(t) - comp_P = stream.P_.copy() - comp_I = stream.I_ - comp_left_P = stream.left_P_.copy() - comp_left_I = stream.left_I_ + cmp_P = stream.P_.copy() + cmp_I = stream.I_ + cmp_left_P = stream.left_P_.copy() + cmp_left_I = stream.left_I_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ @@ -1176,10 +1260,10 @@ def test_aampi_self_join_egress_passing_mp(): naive.replace_inf(ref_P) naive.replace_inf(ref_left_P) - naive.replace_inf(comp_P) - naive.replace_inf(comp_left_P) + naive.replace_inf(cmp_P) + naive.replace_inf(cmp_left_P) - npt.assert_almost_equal(ref_P, comp_P) - npt.assert_almost_equal(ref_I, comp_I) - npt.assert_almost_equal(ref_left_P, comp_left_P) - npt.assert_almost_equal(ref_left_I, comp_left_I) + npt.assert_allclose(cmp_P, ref_P, atol=1.5e-07) + npt.assert_allclose(cmp_I, ref_I, atol=1.5e-07) + npt.assert_allclose(cmp_left_P, ref_left_P, atol=1.5e-07) + npt.assert_allclose(cmp_left_I, ref_left_I, atol=1.5e-07)