def test_stomp_nan_inf_A_B_join( T_A, T_B, substitute_A, substitute_B, substitution_locations ): m = 3 T_A_sub = T_A.copy() T_B_sub = T_B.copy() for substitution_location_B in substitution_locations: for substitution_location_A in substitution_locations: T_A_sub[:] = T_A[:] T_B_sub[:] = T_B[:] T_A_sub[substitution_location_A] = substitute_A T_B_sub[substitution_location_B] = substitute_B left = np.array( [ utils.naive_mass(Q, T_A_sub, m) for Q in core.rolling_window(T_B_sub, m) ], dtype=object, ) right = stomp(T_A_sub, m, T_B_sub, ignore_trivial=False) utils.replace_inf(left) utils.replace_inf(right) npt.assert_almost_equal(left, right)
def test_stomp_A_B_join(T_A, T_B): m = 3 left = np.array( [naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)], dtype=object) right = stomp(T_A, m, T_B, ignore_trivial=False) replace_inf(left) replace_inf(right) npt.assert_almost_equal(left, right)
def test_stomp_self_join(T_A, T_B): m = 3 zone = int(np.ceil(m / 4)) left = np.array([ naive_mass(Q, T_B, m, i, zone, True) for i, Q in enumerate(core.rolling_window(T_B, m)) ], dtype=object) right = stomp(T_B, m, ignore_trivial=True) replace_inf(left) replace_inf(right) npt.assert_almost_equal(left, right)
def test_stump_self_join_larger_window(T_A, T_B): for m in [8, 16, 32]: if len(T_B) > m: zone = int(np.ceil(m / 4)) left = np.array( [ utils.naive_mass(Q, T_B, m, i, zone, True) for i, Q in enumerate(core.rolling_window(T_B, m)) ], dtype=object, ) right = stomp(T_B, m, ignore_trivial=True) utils.replace_inf(left) utils.replace_inf(right) npt.assert_almost_equal(left, right)
def test_stomp_nan_inf_self_join(T_A, T_B, substitute_B, substitution_locations): m = 3 T_B_sub = T_B.copy() for substitution_location_B in substitution_locations: T_B_sub[:] = T_B[:] T_B_sub[substitution_location_B] = substitute_B zone = int(np.ceil(m / 4)) left = np.array( [ utils.naive_mass(Q, T_B_sub, m, i, zone, True) for i, Q in enumerate(core.rolling_window(T_B_sub, m)) ], dtype=object, ) right = stomp(T_B_sub, m, ignore_trivial=True) utils.replace_inf(left) utils.replace_inf(right) npt.assert_almost_equal(left, right)
def test_stomp_int_input(): with pytest.raises(TypeError): stomp(np.arange(10), 5, ignore_trivial=True)