def test_aampi_self_join_egress(): m = 3 zone = int(np.ceil(m / 4)) seed = np.random.randint(100000) np.random.seed(seed) n = 30 T = np.random.rand(n) left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I) np.random.seed(seed) T = np.random.rand(n) T = pd.Series(T) left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ naive.replace_inf(left_P) naive.replace_inf(right_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I)
def test_aampi_constant_subsequence_self_join_egress(): m = 3 zone = int(np.ceil(m / 4)) seed = np.random.randint(100000) np.random.seed(seed) T = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(10, dtype=np.float64))) left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(right_P) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) # npt.assert_almost_equal(left_left_I, right_left_I) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) # npt.assert_almost_equal(left_left_I, right_left_I) np.random.seed(seed) T = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(10, dtype=np.float64))) T = pd.Series(T) left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(right_P) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) # npt.assert_almost_equal(left_left_I, right_left_I) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P)
def test_aampi_identical_subsequence_self_join_egress(): m = 3 zone = int(np.ceil(m / 4)) seed = np.random.randint(100000) np.random.seed(seed) identical = np.random.rand(8) T = np.random.rand(20) T[1:1 + identical.shape[0]] = identical T[11:11 + identical.shape[0]] = identical left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(right_P) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P, decimal=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P, decimal=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(left_left_I, right_left_I) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P, decimal=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P, decimal=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(left_left_I, right_left_I) np.random.seed(seed) identical = np.random.rand(8) T = np.random.rand(20) T[1:1 + identical.shape[0]] = identical T[11:11 + identical.shape[0]] = identical T = pd.Series(T) left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(right_P) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P, decimal=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P, decimal=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(left_left_I, right_left_I) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P, decimal=config.STUMPY_TEST_PRECISION) # npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P, decimal=config.STUMPY_TEST_PRECISION)
def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations): m = 3 zone = int(np.ceil(m / 4)) seed = np.random.randint(100000) # seed = 58638 for substitution_location in substitution_locations: np.random.seed(seed) n = 30 T = np.random.rand(n) if substitution_location == -1: substitution_location = T.shape[0] - 1 T[substitution_location] = substitute left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(right_P) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I) np.random.seed(seed) n = 30 T = np.random.rand(n) T = pd.Series(T) left = naive.aampi_egress(T, m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T, m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) for i in range(34): t = np.random.rand() left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I)
def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_locations): m = 3 zone = int(np.ceil(m / 4)) seed = np.random.randint(100000) for substitution_location in substitution_locations: np.random.seed(seed) n = 30 T = np.random.rand(64) left = naive.aampi_egress(T[:n], m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(T[:n], m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(right_P) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I) if substitution_location == -1: substitution_location = T[n:].shape[0] - 1 T[n:][substitution_location] = substitute for t in T[n:]: left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I) np.random.seed(seed) T = np.random.rand(64) left = naive.aampi_egress(T[:n], m) left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ stream = aampi(pd.Series(T[:n]), m, egress=True) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ naive.replace_inf(left_P) naive.replace_inf(right_P) naive.replace_inf(left_left_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I) if substitution_location == -1: substitution_location = T[n:].shape[0] - 1 T[n:][substitution_location] = substitute for t in T[n:]: left.update(t) stream.update(t) right_P = stream.P_.copy() right_I = stream.I_ right_left_P = stream.left_P_.copy() right_left_I = stream.left_I_ left_P = left.P_.copy() left_I = left.I_ left_left_P = left.left_P_.copy() left_left_I = left.left_I_ naive.replace_inf(left_P) naive.replace_inf(left_left_P) naive.replace_inf(right_P) naive.replace_inf(right_left_P) npt.assert_almost_equal(left_P, right_P) npt.assert_almost_equal(left_I, right_I) npt.assert_almost_equal(left_left_P, right_left_P) npt.assert_almost_equal(left_left_I, right_left_I)
def test_aampi_self_join_egress(): m = 3 seed = np.random.randint(100000) np.random.seed(seed) n = 30 T = np.random.rand(n) ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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_ 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) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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) np.random.seed(seed) T = np.random.rand(n) T = pd.Series(T) ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ stream = aampi(T, m, egress=True) comp_P = stream.P_.copy() comp_I = stream.I_ 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) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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)
def test_aampi_identical_subsequence_self_join_egress(): m = 3 seed = np.random.randint(100000) np.random.seed(seed) identical = np.random.rand(8) T = np.random.rand(20) T[1:1 + identical.shape[0]] = identical T[11:11 + identical.shape[0]] = identical ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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_ naive.replace_inf(ref_P) naive.replace_inf(comp_P) naive.replace_inf(ref_left_P) naive.replace_inf(comp_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_almost_equal(ref_left_I, comp_left_I) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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, 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_almost_equal(ref_left_I, comp_left_I) np.random.seed(seed) identical = np.random.rand(8) T = np.random.rand(20) T[1:1 + identical.shape[0]] = identical T[11:11 + identical.shape[0]] = identical T = pd.Series(T) ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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_ naive.replace_inf(ref_P) naive.replace_inf(comp_P) naive.replace_inf(ref_left_P) naive.replace_inf(comp_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_almost_equal(ref_left_I, comp_left_I) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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, 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)
def test_aampi_constant_subsequence_self_join_egress(): m = 3 seed = np.random.randint(100000) np.random.seed(seed) T = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(10, dtype=np.float64))) ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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_ naive.replace_inf(ref_P) naive.replace_inf(comp_P) naive.replace_inf(ref_left_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) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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) np.random.seed(seed) T = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(10, dtype=np.float64))) T = pd.Series(T) ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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_ naive.replace_inf(ref_P) naive.replace_inf(comp_P) naive.replace_inf(ref_left_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) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() # ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() # ref_left_I = ref_mp.left_I_ 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)
def test_aampi_stream_nan_inf_self_join_egress(substitute, substitution_locations): m = 3 seed = np.random.randint(100000) for substitution_location in substitution_locations: np.random.seed(seed) n = 30 T = np.random.rand(64) ref_mp = naive.aampi_egress(T[:n], m) ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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_ naive.replace_inf(ref_P) naive.replace_inf(comp_P) naive.replace_inf(ref_left_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) if substitution_location == -1: substitution_location = T[n:].shape[0] - 1 T[n:][substitution_location] = substitute for t in T[n:]: 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_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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) np.random.seed(seed) T = np.random.rand(64) ref_mp = naive.aampi_egress(T[:n], m) ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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_ naive.replace_inf(ref_P) naive.replace_inf(comp_P) naive.replace_inf(ref_left_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) if substitution_location == -1: substitution_location = T[n:].shape[0] - 1 T[n:][substitution_location] = substitute for t in T[n:]: 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_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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)
def test_aampi_init_nan_inf_self_join_egress(substitute, substitution_locations): m = 3 seed = np.random.randint(100000) # seed = 58638 for substitution_location in substitution_locations: np.random.seed(seed) n = 30 T = np.random.rand(n) if substitution_location == -1: substitution_location = T.shape[0] - 1 T[substitution_location] = substitute ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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_ naive.replace_inf(ref_P) naive.replace_inf(comp_P) naive.replace_inf(ref_left_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) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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) np.random.seed(seed) n = 30 T = np.random.rand(n) T = pd.Series(T) ref_mp = naive.aampi_egress(T, m) ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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_ npt.assert_almost_equal(ref_P, comp_P) npt.assert_almost_equal(ref_I, comp_I) naive.replace_inf(ref_left_P) naive.replace_inf(comp_left_P) for i in range(34): t = np.random.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_ ref_P = ref_mp.P_.copy() ref_I = ref_mp.I_ ref_left_P = ref_mp.left_P_.copy() ref_left_I = ref_mp.left_I_ 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)