Esempio n. 1
0
def test_stumped_A_B_join(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        ref_mp = naive.stump(T_A, m, T_B=T_B)
        comp_mp = stumped(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)
Esempio n. 2
0
def test_stumped_A_B_join(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        left = utils.naive_stamp(T_A, m, T_B=T_B)
        right = stumped(dask_client, T_A, m, T_B, ignore_trivial=False)
        utils.replace_inf(left)
        utils.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 3
0
def test_stumped_self_join_df(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        zone = int(np.ceil(m / 4))
        left = utils.naive_stamp(T_B, m, exclusion_zone=zone)
        right = stumped(dask_client, pd.Series(T_B), m, ignore_trivial=True)
        utils.replace_inf(left)
        utils.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 4
0
def test_stumped_A_B_join(T_A, T_B, dask_client):
    dask_client.restart()
    m = 3
    left = np.array(
        [naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)], dtype=object
    )
    right = stumped(dask_client, T_A, m, T_B, ignore_trivial=False)
    replace_inf(left)
    replace_inf(right)
    npt.assert_almost_equal(left, right)
    dask_client.restart()

    right = stumped(
        dask_client, pd.Series(T_A), m, pd.Series(T_B), ignore_trivial=False
    )
    replace_inf(right)
    npt.assert_almost_equal(left, right)
    dask_client.restart()
Esempio n. 5
0
def test_stumped_self_join(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        zone = int(np.ceil(m / 4))
        left = naive.stump(T_B, m, exclusion_zone=zone)
        right = stumped(dask_client, T_B, m, ignore_trivial=True)
        naive.replace_inf(left)
        naive.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 6
0
def test_stumped_A_B_join(T_A, T_B, dask_client):
    m = 3
    left = np.array(
        [utils.naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)],
        dtype=object)
    right = stumped(dask_client, T_A, m, T_B, ignore_trivial=False)
    utils.replace_inf(left)
    utils.replace_inf(right)
    npt.assert_almost_equal(left, right)
Esempio n. 7
0
def test_stumped_self_join_df(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        zone = int(np.ceil(m / 4))
        ref_mp = naive.stump(T_B, m, exclusion_zone=zone)
        comp_mp = stumped(dask_client, pd.Series(T_B), m, ignore_trivial=True)
        naive.replace_inf(ref_mp)
        naive.replace_inf(comp_mp)
        npt.assert_almost_equal(ref_mp, comp_mp)
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)
Esempio n. 9
0
def test_stumped_A_B_join_df(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        left = naive.stamp(T_A, m, T_B=T_B)
        right = stumped(
            dask_client, pd.Series(T_A), m, pd.Series(T_B), ignore_trivial=False
        )
        naive.replace_inf(left)
        naive.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 10
0
def test_stump_self_join_larger_window(T_A, T_B, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        if len(T_B) > m:
            zone = int(np.ceil(m / 4))
            ref_mp = naive.stump(T_B, m, exclusion_zone=zone)
            comp_mp = stumped(dask_client, T_B, m, ignore_trivial=True)
            naive.replace_inf(ref_mp)
            naive.replace_inf(comp_mp)

            npt.assert_almost_equal(ref_mp, comp_mp)
Esempio n. 11
0
def test_stumped_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))
        ref_mp = naive.stump(T_A, m, exclusion_zone=zone)
        comp_mp = stumped(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
Esempio n. 12
0
def test_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
        left = naive.stamp(T_A, m, T_B=T_B)
        right = stumped(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
Esempio n. 13
0
def test_one_constant_subsequence_self_join(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.stamp(T_A, m, exclusion_zone=zone)
        right = stumped(dask_client, T_A, m, ignore_trivial=True)
        naive.replace_inf(left)
        naive.replace_inf(right)
        npt.assert_almost_equal(left[:, 0], right[:, 0])  # ignore indices
Esempio n. 14
0
def test_stump_self_join_larger_window(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        for m in [8, 16, 32]:
            if len(T_B) > m:
                zone = int(np.ceil(m / 4))
                left = utils.naive_stamp(T_B, m, exclusion_zone=zone)
                right = stumped(dask_client, T_B, m, ignore_trivial=True)
                utils.replace_inf(left)
                utils.replace_inf(right)

                npt.assert_almost_equal(left, right)
Esempio n. 15
0
def test_stumped_one_constant_subsequence_A_B_join_swap(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.stump(T_A, m, T_B=T_B)
        comp_mp = stumped(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
Esempio n. 16
0
def test_one_constant_subsequence_A_B_join(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
    left = np.array(
        [utils.naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)],
        dtype=object)
    right = stumped(dask_client, T_A, m, T_B, ignore_trivial=False)
    utils.replace_inf(left)
    utils.replace_inf(right)
    npt.assert_almost_equal(left[:, 0], right[:, 0])  # ignore indices
Esempio n. 17
0
def test_stumped_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.stamp(T, m, exclusion_zone=zone)
        right = stumped(dask_client, T, m, ignore_trivial=True)

        naive.replace_inf(left)
        naive.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 18
0
def test_stumped_self_join(T_A, T_B, dask_client):
    dask_client.restart()
    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 = stumped(dask_client, T_B, m, ignore_trivial=True)
    replace_inf(left)
    replace_inf(right)
    npt.assert_almost_equal(left, right)
    dask_client.restart()

    right = stumped(dask_client, pd.Series(T_B), m, ignore_trivial=True)
    replace_inf(right)
    npt.assert_almost_equal(left, right)
    dask_client.restart()
Esempio n. 19
0
def test_stumped_A_B_join_df(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        left = np.array(
            [utils.naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)],
            dtype=object,
        )
        right = stumped(
            dask_client, pd.Series(T_A), m, pd.Series(T_B), ignore_trivial=False
        )
        utils.replace_inf(left)
        utils.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 20
0
def test_stumped_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

        left = utils.naive_stamp(T_A, m, T_B=T_B_sub)
        right = stumped(dask_client, T_A, m, T_B_sub, ignore_trivial=False)
        utils.replace_inf(left)
        utils.replace_inf(right)
        npt.assert_almost_equal(left, right)
def test_two_constant_subsequences_A_B_join_swap(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 = utils.naive_stamp(T_B, m, T_B=T_A)
        right = stumped(dask_client, T_B, m, T_A, ignore_trivial=False)
        utils.replace_inf(left)
        utils.replace_inf(right)
        npt.assert_almost_equal(left[:, 0], right[:, 0])  # ignore indices
Esempio n. 22
0
def test_stumped_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

        ref_mp = naive.stump(T_A, m, T_B=T_B_sub)
        comp_mp = stumped(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)
Esempio n. 23
0
def test_stumped_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))
        left = naive.stamp(T_B_sub, m, exclusion_zone=zone)
        right = stumped(dask_client, T_B_sub, m, ignore_trivial=True)
        naive.replace_inf(left)
        naive.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 24
0
def test_stumped_self_join_df(T_A, T_B, dask_cluster):
    with Client(dask_cluster) as dask_client:
        m = 3
        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 = stumped(dask_client, pd.Series(T_B), m, ignore_trivial=True)
        utils.replace_inf(left)
        utils.replace_inf(right)
        npt.assert_almost_equal(left, right)
Esempio n. 25
0
def test_stumped_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))
        ref_mp = naive.stump(T_A, m, exclusion_zone=zone)
        comp_mp = stumped(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
Esempio n. 26
0
def test_stumped_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))
        ref_mp = naive.stump(T_B_sub, m, exclusion_zone=zone)
        comp_mp = stumped(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_stumped_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.stamp(T_A, m, T_B=T_B)
        right = stumped(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=naive.PRECISION)  # ignore indices
Esempio n. 28
0
def test_stumped_identical_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
        ref_mp = naive.stump(T_A, m, T_B=T_B)
        comp_mp = stumped(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],
            decimal=config.STUMPY_TEST_PRECISION)  # ignore indices
def test_stumped_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.stamp(T_A, m, exclusion_zone=zone)
        right = stumped(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=naive.PRECISION)  # ignore indices
Esempio n. 30
0
def test_stump_self_join_larger_window(T_A, T_B, dask_client):
    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 = stumped(dask_client, T_B, m, ignore_trivial=True)
            utils.replace_inf(left)
            utils.replace_inf(right)

            npt.assert_almost_equal(left, right)