def test_distance1():
    with util_numpy.test_uses_numpy() as np:
        directory = prepare_directory()

        s1 = np.array([0., 0, 1, 2, 1, 0, 1, 0, 0, 2, 1, 0, 0])
        s2 = np.array([0., 1, 2, 3, 1, 10, 1, 0, 2, 1, 0, 0, 0])
        d, paths = dtw.warping_paths(s1, s2)
        # print(d, "\n", paths)
        if not dtwvis.test_without_visualization():
            dtwvis.plot_warpingpaths(s1,
                                     s2,
                                     paths,
                                     filename=directory / "temp1.png")

        weights = np.full((len(s1), 8), np.inf)
        weights[:, 2:4] = 0.0
        weights[4:7, 2:4] = 10.0
        weights[:, 4:6] = 0.0
        weights[4:7, 4:6] = 10.0
        d, paths = dtww.warping_paths(s1, s2, weights)
        # print(d, "\n", paths)
        if not dtwvis.test_without_visualization():
            dtwvis.plot_warpingpaths(s1,
                                     s2,
                                     paths,
                                     filename=directory / "temp2.png")
def test_distance1():
    directory = prepare_directory()

    s1 = np.array([0., 0, 1, 2, 1, 0, 1, 0, 0, 2, 1, 0, 0])
    s2 = np.array([0., 1, 2, 3, 1, 10, 1, 0, 2, 1, 0, 0, 0])
    d, paths = dtw.warping_paths(s1, s2)
    # print(d, "\n", paths)
    dtwvis.plot_warpingpaths(s1, s2, paths, filename=directory / "temp1.png")

    weights = np.full((len(s1), 8), np.inf)
    weights[:, 2:4] = 0.0
    weights[4:7, 2:4] = 10.0
    weights[:, 4:6] = 0.0
    weights[4:7, 4:6] = 10.0
    d, paths = dtww.warping_paths(s1, s2, weights)
    # print(d, "\n", paths)
    dtwvis.plot_warpingpaths(s1, s2, paths, filename=directory / "temp2.png")
def test_distance3():
    s = np.array([[0., 0, 1, 2, 1, 0, 1.3, 0, 0], [0., 1, 2, 0, 0, 0, 0, 0,
                                                   0]])
    w = np.array([[np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf],
                  [np.inf, np.inf, 1.1, 1., 0., 0., np.inf, np.inf],
                  [np.inf, np.inf, 1.1, 1., 0., 0., np.inf, np.inf],
                  [np.inf, np.inf, 0., 0., 2., 2.2, np.inf, np.inf],
                  [np.inf, np.inf, 0., 0., 1., 1.1, np.inf, np.inf],
                  [np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf],
                  [np.inf, np.inf, 0., 0., 1.3, 1.43, np.inf, np.inf],
                  [np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf],
                  [np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf]])

    d, paths = dtww.warping_paths(s[0], s[1], w, window=0)
    path = dtw.best_path(paths)
    if directory:
        wp_fn = directory / "warping_paths.png"
        dtwvis.plot_warpingpaths(s[0], s[1], paths, path, filename=wp_fn)
def test_distance3():
    with util_numpy.test_uses_numpy() as np:
        s = np.array([[0., 0, 1, 2, 1, 0, 1.3, 0, 0],
                      [0., 1, 2, 0, 0, 0, 0, 0, 0]])
        w = np.array([[np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf],
                      [np.inf, np.inf, 1.1, 1., 0., 0., np.inf, np.inf],
                      [np.inf, np.inf, 1.1, 1., 0., 0., np.inf, np.inf],
                      [np.inf, np.inf, 0., 0., 2., 2.2, np.inf, np.inf],
                      [np.inf, np.inf, 0., 0., 1., 1.1, np.inf, np.inf],
                      [np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf],
                      [np.inf, np.inf, 0., 0., 1.3, 1.43, np.inf, np.inf],
                      [np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf],
                      [np.inf, np.inf, 0., 0., 0., 0., np.inf, np.inf]])

        d, paths = dtww.warping_paths(s[0], s[1], w, window=0)
        path = dtw.best_path(paths)
        if not dtwvis.test_without_visualization():
            if directory:
                wp_fn = directory / "warping_paths.png"
                dtwvis.plot_warpingpaths(s[0],
                                         s[1],
                                         paths,
                                         path,
                                         filename=wp_fn)