Esempio n. 1
0
def test_mstumped(T, m, dask_client):
    dask_client.restart()
    left_P, left_I = naive_mstump(T, m)
    right_P, right_I = mstumped(dask_client, T, m)

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_almost_equal(left_I, right_I)
    dask_client.restart()

    right_P, right_I = mstumped(dask_client, pd.DataFrame(T), m)

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_almost_equal(left_I, right_I)
Esempio n. 2
0
def test_mstumped_df(T, m, dask_client):
    left_P, left_I = naive_mstump(T, m)
    df = pd.DataFrame(T.T)
    right_P, right_I = mstumped(dask_client, df, m)

    npt.assert_almost_equal(left_P.T, right_P)
    npt.assert_almost_equal(left_I.T, right_I)
Esempio n. 3
0
def test_mstumped(T, m, dask_client):
    excl_zone = int(np.ceil(m / 4))

    left_P, left_I = utils.naive_mstump(T, m, excl_zone)
    right_P, right_I = mstumped(dask_client, T, m)

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_almost_equal(left_I, right_I)
Esempio n. 4
0
def test_mstumped_df(T, m, dask_client):
    excl_zone = int(np.ceil(m / 4))

    left_P, left_I = utils.naive_mstump(T, m, excl_zone)
    df = pd.DataFrame(T.T)
    right_P, right_I = mstumped(dask_client, df, m)

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_almost_equal(left_I, right_I)
Esempio n. 5
0
def test_mstumped(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        excl_zone = int(np.ceil(m / 4))

        left_P, left_I = naive.mstump(T, m, excl_zone)
        right_P, right_I = mstumped(dask_client, T, m)

        npt.assert_almost_equal(left_P, right_P)
        npt.assert_almost_equal(left_I, right_I)
Esempio n. 6
0
def test_mstumped_discords(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        excl_zone = int(np.ceil(m / 4))

        ref_P, ref_I = naive.mstump(T, m, excl_zone, discords=True)
        comp_P, comp_I = mstumped(dask_client, T, m, discords=True)

        npt.assert_almost_equal(ref_P, comp_P)
        npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 7
0
def test_mstumped_discords(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        excl_zone = int(np.ceil(m / 4))

        left_P, left_I = utils.naive_mstump(T, m, excl_zone, discords=True)
        right_P, right_I = mstumped(dask_client, T, m, discords=True)

        npt.assert_almost_equal(left_P, right_P)
        npt.assert_almost_equal(left_I, right_I)
Esempio n. 8
0
def test_mstumped_df(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        excl_zone = int(np.ceil(m / 4))

        ref_P, ref_I = naive.mstump(T, m, excl_zone)
        df = pd.DataFrame(T.T)
        comp_P, comp_I = mstumped(dask_client, df, m)

        npt.assert_almost_equal(ref_P, comp_P)
        npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 9
0
def test_constant_subsequence_self_join(dask_client):
    T_A = np.concatenate(
        (np.zeros(20, dtype=np.float64), np.ones(5, dtype=np.float64)))
    T = np.array([T_A, T_A, np.random.rand(T_A.shape[0])])
    m = 3

    left_P, left_I = naive_mstump(T, m)
    right_P, right_I = mstumped(dask_client, T, m)

    npt.assert_almost_equal(left_P.T, right_P)  # ignore indices
Esempio n. 10
0
def test_mstumped_include(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        for i in range(T.shape[0]):
            include = np.asarray([i])
            excl_zone = int(np.ceil(m / 4))

            left_P, left_I = utils.naive_mstump(T, m, excl_zone, include)
            right_P, right_I = mstumped(dask_client, T, m, include)

            npt.assert_almost_equal(left_P, right_P)
            npt.assert_almost_equal(left_I, right_I)
Esempio n. 11
0
def test_mstumped_one_subsequence_nan_self_join_all_dimensions(
        T, m, substitution_location, dask_client):
    excl_zone = int(np.ceil(m / 4))

    T_sub = T.copy()
    T_sub[:, substitution_location] = np.nan

    left_P, left_I = utils.naive_mstump(T_sub, m, excl_zone)
    right_P, right_I = mstumped(dask_client, T_sub, m)

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_almost_equal(left_I, right_I)
Esempio n. 12
0
def test_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)))
        T = np.array([T_A, T_A, np.random.rand(T_A.shape[0])])
        m = 3

        excl_zone = int(np.ceil(m / 4))

        left_P, left_I = utils.naive_mstump(T, m, excl_zone)
        right_P, right_I = mstumped(dask_client, T, m)

        npt.assert_almost_equal(left_P, right_P)  # ignore indices
def test_mstumped_one_subsequence_inf_self_join_first_dimension(
        T, m, substitution_location, dask_cluster):
    with Client(dask_cluster) as dask_client:
        excl_zone = int(np.ceil(m / 4))

        T_sub = T.copy()
        T_sub[0, substitution_location] = np.inf

        left_P, left_I = utils.naive_mstump(T_sub, m, excl_zone)
        right_P, right_I = mstumped(dask_client, T_sub, m)

        npt.assert_almost_equal(left_P, right_P)
        npt.assert_almost_equal(left_I, right_I)
Esempio n. 14
0
def test_mstumped_one_subsequence_nan_self_join_all_dimensions(
        T, m, substitution_location, dask_cluster):
    with Client(dask_cluster) as dask_client:
        excl_zone = int(np.ceil(m / 4))

        T_sub = T.copy()
        T_sub[:, substitution_location] = np.nan

        ref_P, ref_I, _ = naive.mstump(T_sub, m, excl_zone)
        comp_P, comp_I = mstumped(dask_client, T_sub, m)

        npt.assert_almost_equal(ref_P, comp_P)
        npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 15
0
def test_mstumped_include(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        for width in range(T.shape[0]):
            for i in range(T.shape[0] - width):
                include = np.asarray(range(i, i + width + 1))

                excl_zone = int(np.ceil(m / 4))

                ref_P, ref_I = naive.mstump(T, m, excl_zone, include)
                comp_P, comp_I = mstumped(dask_client, T, m, include)

                npt.assert_almost_equal(ref_P, comp_P)
                npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 16
0
def test_mstumped_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
        T = np.array([T_A, T_A, np.random.rand(T_A.shape[0])])
        m = 3

        excl_zone = int(np.ceil(m / 4))

        left_P, left_I = naive.mstump(T, m, excl_zone)
        right_P, right_I = mstumped(dask_client, T, m)

        npt.assert_almost_equal(left_P, right_P,
                                decimal=naive.PRECISION)  # ignore indices
Esempio n. 17
0
def test_mstumped_include_discords(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        for width in range(T.shape[0]):
            for i in range(T.shape[0] - width):
                include = np.asarray(range(i, i + width + 1))

                excl_zone = int(np.ceil(m / 4))

                left_P, left_I = naive.mstump(T,
                                              m,
                                              excl_zone,
                                              include,
                                              discords=True)
                right_P, right_I = mstumped(dask_client,
                                            T,
                                            m,
                                            include,
                                            discords=True)

                npt.assert_almost_equal(left_P, right_P)
                npt.assert_almost_equal(left_I, right_I)
def test_mstumped(T, m, dask_cluster):
    with Client(dask_cluster) as dask_client:
        ref = stumpy.maamped(dask_client, T, m)
        comp = stumpy.mstumped(dask_client, T, m, normalize=False)
        npt.assert_almost_equal(ref, comp)
Esempio n. 19
0
def test_mstumped(T, m, dask_client):
    left_P, left_I = naive_mstump(T, m)
    right_P, right_I = mstumped(dask_client, T, m)

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_almost_equal(left_I, right_I)
Esempio n. 20
0
def test_mstumped_int_input(dask_cluster):
    with pytest.raises(TypeError):
        with Client(dask_cluster) as dask_client:
            mstumped(dask_client, np.arange(20).reshape(2, 10), 5)