Esempio n. 1
0
def test_maamp_wrapper(T, m):
    excl_zone = int(np.ceil(m / 4))

    ref_P, ref_I = naive.maamp(T, m, excl_zone)
    comp_P, comp_I = maamp(T, m)

    npt.assert_almost_equal(ref_P, comp_P)
    npt.assert_almost_equal(ref_I, comp_I)

    df = pd.DataFrame(T.T)
    comp_P, comp_I = maamp(df, m)

    npt.assert_almost_equal(ref_P, comp_P)
    npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 2
0
def test_maamp_discords(T, m):
    excl_zone = int(np.ceil(m / 4))

    ref_P, ref_I = naive.maamp(T, m, excl_zone, discords=True)
    comp_P, comp_I = maamp(T, m, discords=True)

    npt.assert_almost_equal(ref_P, comp_P)
    npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 3
0
def test_maamp_wrapper_include(T, m):
    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.maamp(T, m, excl_zone, include)
            comp_P, comp_I = maamp(T, m, include)

            npt.assert_almost_equal(ref_P, comp_P)
            npt.assert_almost_equal(ref_I, comp_I)

            df = pd.DataFrame(T.T)
            comp_P, comp_I = maamp(df, m, include)

            npt.assert_almost_equal(ref_P, comp_P)
            npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 4
0
def test_maamp(T, m):
    excl_zone = int(np.ceil(m / 4))

    for p in [1.0, 2.0, 3.0]:
        ref_P, ref_I = naive.maamp(T, m, excl_zone, p=p)
        comp_P, comp_I = maamp(T, m, p=p)

        npt.assert_almost_equal(ref_P, comp_P)
        npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 5
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))

    ref_P, ref_I = naive.maamp(T, m, excl_zone)
    comp_P, comp_I = maamp(T, m)

    npt.assert_almost_equal(ref_P, comp_P)  # ignore indices
Esempio n. 6
0
def test_maamp_include_discords(T, m):
    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.maamp(T, m, excl_zone, include, discords=True)
            comp_P, comp_I = maamp(T, m, include, discords=True)

            npt.assert_almost_equal(ref_P, comp_P)
            npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 7
0
def test_maamp_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

        ref_P, ref_I = naive.maamp(T_sub, m, excl_zone)
        comp_P, comp_I = maamp(T_sub, m)

        npt.assert_almost_equal(ref_P, comp_P)
        npt.assert_almost_equal(ref_I, comp_I)
Esempio n. 8
0
def test_identical_subsequence_self_join():
    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))

    ref_P, ref_I = naive.maamp(T, m, excl_zone)
    comp_P, comp_I = maamp(T, m)

    npt.assert_almost_equal(
        ref_P, comp_P, decimal=config.STUMPY_TEST_PRECISION)  # ignore indices
def test_mstump(T, m):
    ref = stumpy.maamp(T, m)
    comp = stumpy.mstump(T, m, normalize=False)
    npt.assert_almost_equal(ref, comp)
Esempio n. 10
0
def test_maamp_int_input():
    with pytest.raises(TypeError):
        maamp(np.arange(20).reshape(2, 10), 5)