Esempio n. 1
0
def test_naive_mstump():
    T = np.random.uniform(-1000, 1000, [1, 1000]).astype(np.float64)
    m = 20

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

    left = np.array(
        [
            utils.naive_mass(Q,
                             T[0],
                             m,
                             trivial_idx=i,
                             ignore_trivial=True,
                             excl_zone=excl_zone)
            for i, Q in enumerate(core.rolling_window(T[0], m))
        ],
        dtype=object,
    )
    left_P = left[np.newaxis, :, 0].T
    left_I = left[np.newaxis, :, 1].T

    right_P, right_I = utils.naive_mstump(T, m, excl_zone)

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

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

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_almost_equal(left_I, right_I)
Esempio n. 3
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. 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_mstump_include(T, m):
    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 = mstump(T, m, include)

        npt.assert_almost_equal(left_P, right_P)
        npt.assert_almost_equal(left_I, right_I)
Esempio n. 6
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. 7
0
def test_constant_subsequence_self_join():
    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 = mstump(T, m)

    npt.assert_almost_equal(left_P, right_P)  # ignore indices
Esempio n. 8
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)
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. 10
0
def test_get_first_mstump_profile(T, m):
    excl_zone = int(np.ceil(m / 4))
    start = 0

    left_P, left_I = utils.naive_mstump(T, m, excl_zone)
    left_P = left_P[start, :]
    left_I = left_I[start, :]

    M_T, Σ_T = core.compute_mean_std(T, m)
    right_P, right_I = _get_first_mstump_profile(start, T, T, m, excl_zone, M_T, Σ_T)

    npt.assert_almost_equal(left_P, right_P)
    npt.assert_equal(left_I, right_I)
Esempio n. 11
0
def test_naive_mstump():
    T = np.random.uniform(-1000, 1000, [1, 1000]).astype(np.float64)
    m = 20

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

    left = utils.naive_stamp(T[0], m, exclusion_zone=zone)
    left_P = left[np.newaxis, :, 0].T
    left_I = left[np.newaxis, :, 1].T

    right_P, right_I = utils.naive_mstump(T, m, zone)

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

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

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

    df = pd.DataFrame(T.T)
    right_P, right_I = mstump(df, m)

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

    T_sub = T.copy()

    for substitution_location in substitution_locations:
        T_sub[:] = T[:]
        T_sub[:, substitution_location] = substitute

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

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