Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions tests/test_stomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ def test_stomp_self_join(T_A, T_B):
m = 3
zone = int(np.ceil(m / 4))
ref_mp = naive.stump(T_B, m, exclusion_zone=zone, row_wise=True)
comp_mp = _stomp(T_B, m, ignore_trivial=True)
cmp_mp = _stomp(T_B, m, ignore_trivial=True)
naive.replace_inf(ref_mp)
naive.replace_inf(comp_mp)
npt.assert_almost_equal(ref_mp, comp_mp)
naive.replace_inf(cmp_mp)
npt.assert_allclose(
cmp_mp.astype(np.float64), ref_mp.astype(np.float64), atol=1.5e-07
)


@pytest.mark.parametrize("T_A, T_B", test_data)
Expand All @@ -44,21 +46,25 @@ def test_stump_self_join_larger_window(T_A, T_B, m):
if len(T_B) > m:
zone = int(np.ceil(m / 4))
ref_mp = naive.stump(T_B, m, exclusion_zone=zone, row_wise=True)
comp_mp = _stomp(T_B, m, ignore_trivial=True)
cmp_mp = _stomp(T_B, m, ignore_trivial=True)
naive.replace_inf(ref_mp)
naive.replace_inf(comp_mp)
naive.replace_inf(cmp_mp)

npt.assert_almost_equal(ref_mp, comp_mp)
npt.assert_allclose(
cmp_mp.astype(np.float64), ref_mp.astype(np.float64), atol=1.5e-07
)


@pytest.mark.parametrize("T_A, T_B", test_data)
def test_stomp_A_B_join(T_A, T_B):
m = 3
ref_mp = naive.stump(T_A, m, T_B=T_B, row_wise=True)
comp_mp = _stomp(T_A, m, T_B, ignore_trivial=False)
cmp_mp = _stomp(T_A, m, T_B, ignore_trivial=False)
naive.replace_inf(ref_mp)
naive.replace_inf(comp_mp)
npt.assert_almost_equal(ref_mp, comp_mp)
naive.replace_inf(cmp_mp)
npt.assert_allclose(
cmp_mp.astype(np.float64), ref_mp.astype(np.float64), atol=1.5e-07
)


@pytest.mark.parametrize("T_A, T_B", test_data)
Expand All @@ -75,10 +81,12 @@ def test_stomp_nan_inf_self_join(T_A, T_B, substitute_B, substitution_locations)

zone = int(np.ceil(m / 4))
ref_mp = naive.stump(T_B_sub, m, exclusion_zone=zone, row_wise=True)
comp_mp = _stomp(T_B_sub, m, ignore_trivial=True)
cmp_mp = _stomp(T_B_sub, m, ignore_trivial=True)
naive.replace_inf(ref_mp)
naive.replace_inf(comp_mp)
npt.assert_almost_equal(ref_mp, comp_mp)
naive.replace_inf(cmp_mp)
npt.assert_allclose(
cmp_mp.astype(np.float64), ref_mp.astype(np.float64), atol=1.5e-07
)


@pytest.mark.parametrize("T_A, T_B", test_data)
Expand All @@ -101,10 +109,12 @@ def test_stomp_nan_inf_A_B_join(
T_B_sub[substitution_location_B] = substitute_B

ref_mp = naive.stump(T_A_sub, m, T_B=T_B_sub, row_wise=True)
comp_mp = _stomp(T_A_sub, m, T_B_sub, ignore_trivial=False)
cmp_mp = _stomp(T_A_sub, m, T_B_sub, ignore_trivial=False)
naive.replace_inf(ref_mp)
naive.replace_inf(comp_mp)
npt.assert_almost_equal(ref_mp, comp_mp)
naive.replace_inf(cmp_mp)
npt.assert_allclose(
cmp_mp.astype(np.float64), ref_mp.astype(np.float64), atol=1.5e-07
)


def test_stomp_nan_zero_mean_self_join():
Expand All @@ -113,8 +123,10 @@ def test_stomp_nan_zero_mean_self_join():

zone = int(np.ceil(m / 4))
ref_mp = naive.stump(T, m, exclusion_zone=zone, row_wise=True)
comp_mp = _stomp(T, m, ignore_trivial=True)
cmp_mp = _stomp(T, m, ignore_trivial=True)

naive.replace_inf(ref_mp)
naive.replace_inf(comp_mp)
npt.assert_almost_equal(ref_mp, comp_mp)
naive.replace_inf(cmp_mp)
npt.assert_allclose(
cmp_mp.astype(np.float64), ref_mp.astype(np.float64), atol=1.5e-07
)
Loading