def test_aamped_self_join_df(T_A, T_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 ref_mp = naive.aamp(T_B, m) comp_mp = aamped(dask_client, pd.Series(T_B), m) naive.replace_inf(ref_mp) naive.replace_inf(comp_mp) npt.assert_almost_equal(ref_mp, comp_mp)
def test_aamped_A_B_join(T_A, T_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 ref_mp = naive.aamp(T_A, m, T_B=T_B) comp_mp = aamped(dask_client, 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)
def test_aamped_self_join_df(T_A, T_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 left = naive.aamp(T_B, m) right = aamped(dask_client, pd.Series(T_B), m) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left, right)
def test_aamped_A_B_join(T_A, T_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 left = naive.aamp(T_A, m, T_B=T_B) right = aamped(dask_client, T_A, m, T_B, ignore_trivial=False) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left, right)
def test_stumped(T, m, dask_cluster): if T.ndim > 1: T = T.copy() T = T[0] with Client(dask_cluster) as dask_client: ref = stumpy.aamped(dask_client, T, m) comp = stumpy.stumped(dask_client, T, m, normalize=False) npt.assert_almost_equal(ref, comp)
def test_aamped_self_join_larger_window(T_A, T_B, m, dask_cluster): with Client(dask_cluster) as dask_client: if len(T_B) > m: left = naive.aamp(T_B, m) right = aamped(dask_client, T_B, m) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left, right)
def test_aamped_self_join(T_A, T_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 for p in [1.0, 2.0, 3.0]: ref_mp = naive.aamp(T_B, m, p=p) comp_mp = aamped(dask_client, T_B, m, p=p) naive.replace_inf(ref_mp) naive.replace_inf(comp_mp) npt.assert_almost_equal(ref_mp, comp_mp)
def test_aamped_self_join_larger_window(T_A, T_B, m, dask_cluster): with Client(dask_cluster) as dask_client: if len(T_B) > m: ref_mp = naive.aamp(T_B, m) comp_mp = aamped(dask_client, T_B, m) naive.replace_inf(ref_mp) naive.replace_inf(comp_mp) npt.assert_almost_equal(ref_mp, comp_mp)
def test_aamped_one_constant_subsequence_self_join_df(dask_cluster): with Client(dask_cluster) as dask_client: T_A = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(5, dtype=np.float64))) m = 3 ref_mp = naive.aamp(T_A, m) comp_mp = aamped(dask_client, pd.Series(T_A), m, ignore_trivial=True) naive.replace_inf(ref_mp) naive.replace_inf(comp_mp) npt.assert_almost_equal(ref_mp[:, 0], comp_mp[:, 0]) # ignore indices
def test_aamped_one_constant_subsequence_self_join_df(dask_cluster): with Client(dask_cluster) as dask_client: T_A = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(5, dtype=np.float64))) m = 3 zone = int(np.ceil(m / 4)) left = naive.aamp(T_A, m) right = aamped(dask_client, pd.Series(T_A), m, ignore_trivial=True) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left[:, 0], right[:, 0]) # ignore indices
def test_aamped_one_constant_subsequence_A_B_join(dask_cluster): with Client(dask_cluster) as dask_client: T_A = np.random.rand(20) T_B = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(5, dtype=np.float64))) m = 3 ref_mp = naive.aamp(T_A, m, T_B=T_B) comp_mp = aamped(dask_client, T_A, m, T_B, ignore_trivial=False) naive.replace_inf(ref_mp) naive.replace_inf(comp_mp) npt.assert_almost_equal(ref_mp[:, 0], comp_mp[:, 0]) # ignore indices
def test_aamped_nan_zero_mean_self_join(dask_cluster): with Client(dask_cluster) as dask_client: T = np.array([-1, 0, 1, np.inf, 1, 0, -1]) m = 3 ref_mp = naive.aamp(T, m) comp_mp = aamped(dask_client, T, m, ignore_trivial=True) naive.replace_inf(ref_mp) naive.replace_inf(comp_mp) npt.assert_almost_equal(ref_mp, comp_mp)
def test_aamped_nan_zero_mean_self_join(dask_cluster): with Client(dask_cluster) as dask_client: T = np.array([-1, 0, 1, np.inf, 1, 0, -1]) m = 3 zone = int(np.ceil(m / 4)) left = naive.aamp(T, m) right = aamped(dask_client, T, m, ignore_trivial=True) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left, right)
def test_two_constant_subsequences_A_B_join(dask_cluster): with Client(dask_cluster) as dask_client: T_A = np.concatenate( (np.zeros(10, dtype=np.float64), np.ones(10, dtype=np.float64))) T_B = np.concatenate( (np.zeros(20, dtype=np.float64), np.ones(5, dtype=np.float64))) m = 3 left = naive.aamp(T_A, m, T_B=T_B) right = aamped(dask_client, T_A, m, T_B, ignore_trivial=False) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left[:, 0], right[:, 0]) # ignore indices
def test_aamped_one_subsequence_nan_A_B_join(T_A, T_B, substitution_location_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 T_B_sub = T_B.copy() T_B_sub[substitution_location_B] = np.nan left = naive.aamp(T_A, m, T_B=T_B_sub) right = aamped(dask_client, T_A, m, T_B_sub, ignore_trivial=False) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left, right)
def test_aamped_one_subsequence_inf_A_B_join(T_A, T_B, substitution_location_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 T_B_sub = T_B.copy() T_B_sub[substitution_location_B] = np.inf ref_mp = naive.aamp(T_A, m, T_B=T_B_sub) comp_mp = aamped(dask_client, T_A, 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)
def test_aamped_identical_subsequence_self_join(dask_cluster): with Client(dask_cluster) as dask_client: identical = np.random.rand(8) T_A = np.random.rand(20) T_A[1 : 1 + identical.shape[0]] = identical T_A[11 : 11 + identical.shape[0]] = identical m = 3 ref_mp = naive.aamp(T_A, m) comp_mp = aamped(dask_client, T_A, m, ignore_trivial=True) naive.replace_inf(ref_mp) naive.replace_inf(comp_mp) npt.assert_almost_equal( ref_mp[:, 0], comp_mp[:, 0], decimal=config.STUMPY_TEST_PRECISION ) # ignore indices
def test_aamped_identical_subsequence_self_join(dask_cluster): with Client(dask_cluster) as dask_client: identical = np.random.rand(8) T_A = np.random.rand(20) T_A[1:1 + identical.shape[0]] = identical T_A[11:11 + identical.shape[0]] = identical m = 3 zone = int(np.ceil(m / 4)) left = naive.aamp(T_A, m) right = aamped(dask_client, T_A, m, ignore_trivial=True) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal( left[:, 0], right[:, 0], decimal=config.STUMPY_TEST_PRECISION) # ignore indices
def test_aamped_one_constant_subsequence_A_B_join(dask_cluster): with Client(dask_cluster) as dask_client: identical = np.random.rand(8) T_A = np.random.rand(20) T_B = np.random.rand(20) T_A[1:1 + identical.shape[0]] = identical T_B[11:11 + identical.shape[0]] = identical m = 3 left = naive.aamp(T_A, m, T_B=T_B) right = aamped(dask_client, T_A, m, T_B, ignore_trivial=False) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal( left[:, 0], right[:, 0], decimal=config.STUMPY_TEST_PRECISION) # ignore indices
def test_aamped_one_subsequence_nan_self_join(T_A, T_B, substitution_location_B, dask_cluster): with Client(dask_cluster) as dask_client: m = 3 T_B_sub = T_B.copy() T_B_sub[substitution_location_B] = np.nan zone = int(np.ceil(m / 4)) left = naive.aamp(T_B_sub, m) right = aamped(dask_client, T_B_sub, m, ignore_trivial=True) naive.replace_inf(left) naive.replace_inf(right) npt.assert_almost_equal(left, right)
def test_aamped_one_subsequence_inf_self_join( T_A, T_B, substitution_location_B, dask_cluster ): with Client(dask_cluster) as dask_client: m = 3 T_B_sub = T_B.copy() T_B_sub[substitution_location_B] = np.inf zone = int(np.ceil(m / 4)) ref_mp = naive.aamp(T_B_sub, m) comp_mp = aamped(dask_client, 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)
def test_aamp_int_input(dask_cluster): with pytest.raises(TypeError): with Client(dask_cluster) as dask_client: aamped(dask_client, np.arange(10), 5)