From a56bb414a46c8cd57a867dc690b9e09ee72814ea Mon Sep 17 00:00:00 2001 From: wannesm Date: Thu, 6 Oct 2022 22:33:08 +0200 Subject: [PATCH 1/3] update --- tests/test_subsequence.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_subsequence.py b/tests/test_subsequence.py index 7220eb72..5099b9e3 100644 --- a/tests/test_subsequence.py +++ b/tests/test_subsequence.py @@ -82,7 +82,7 @@ def test_dtw_subseq_eeg(): fn = directory / "test_dtw_subseq_eeg3.png" fig = plt.figure(figsize=(20, 10)) fig, ax = dtwvis.plot_warpingpaths(query, series, sa.warping_paths(), path=-1, figure=fig) - print(f'plotting {len(kmatches)} matches') + print('plotting {} matches'.format(len(kmatches))) for kmatch in kmatches: dtwvis.plot_warpingpaths_addpath(ax, kmatch.path) plt.savefig(fn) @@ -120,6 +120,7 @@ def test_dtw_subseq_ndim(): assert m.value == pytest.approx(0.07071067811865482) +@pytest.skip() @numpyonly def test_dtw_localconcurrences_eeg(): with util_numpy.test_uses_numpy() as np: @@ -139,12 +140,12 @@ def test_dtw_localconcurrences_eeg(): delta = -2 * np.exp(-gamma * diffp**2) # -len(series)/2 # penalty delta_factor = 0.5 tau = np.exp(-gamma * diffp**2) # threshold - print(f'{tau=}, {delta=}') + # print(f'{tau=}, {delta=}') # tau=0.8532234738897421, delta=-1.7064469477794841 buffer = 10 minlen = 20 lc = local_concurrences(series, gamma=gamma, tau=tau, delta=delta, delta_factor=delta_factor) - print(f'{lc.tau=}, {lc.delta=}') + # print(f'{lc.tau=}, {lc.delta=}') matches = [] for match in lc.kbest_matches(k=100, minlen=minlen, buffer=buffer): if match is None: @@ -173,6 +174,7 @@ def test_dtw_localconcurrences_eeg(): plt.close(fig) +@pytest.skip() @numpyonly def test_dtw_localconcurrences_short(): with util_numpy.test_uses_numpy() as np: @@ -234,7 +236,7 @@ def test_dtw_subseqsearch_eeg(): sa = subsequence_search(query, s, dists_options={'use_c': True}) best = sa.kbest_matches_fast(k=k) toc = time.perf_counter() - print(f"Searching performed in {toc - tic:0.4f} seconds") + print("Searching performed in {} seconds".format(toc - tic:0.4f)) # print(sa.distances) # print(best) @@ -257,12 +259,12 @@ def test_dtw_subseqsearch_eeg(): for idx, match in enumerate(best): ax = fig.add_subplot(gs[1, idx]) if idx == 0: - ax.set_title(f'Best {k} windows') + ax.set_title('Best {} windows'.format(k)) ax.set_ylim((ymin, ymax)) ax.plot(s[match.idx]) ax = fig.add_subplot(gs[2, :]) ax.set_ylim((ymin, ymax)) - ax.set_title(f'Series with windows') + ax.set_title('Series with windows') for idx in s_idx: ax.vlines(idx, ymin, ymax, color='grey', alpha=0.4) ax.plot(series) @@ -274,7 +276,7 @@ def test_dtw_subseqsearch_eeg(): if __name__ == "__main__": directory = Path(os.environ.get('TESTDIR', Path(__file__).parent)) - print(f"Saving files to {directory}") + print("Saving files to {}".format(directory)) with util_numpy.test_uses_numpy() as np: np.set_printoptions(precision=6, linewidth=120) # test_dtw_subseq1() From da8427caf51d211ecef19f36a1d3d72d0acb770d Mon Sep 17 00:00:00 2001 From: wannesm Date: Thu, 6 Oct 2022 22:35:22 +0200 Subject: [PATCH 2/3] update --- tests/test_float.py | 1 + tests/test_subsequence.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_float.py b/tests/test_float.py index 231e8908..0c750747 100644 --- a/tests/test_float.py +++ b/tests/test_float.py @@ -6,6 +6,7 @@ numpyonly = pytest.mark.skipif("util_numpy.test_without_numpy()") +@pytest.mark.skip @numpyonly def test_distance1_a(): with util_numpy.test_uses_numpy() as np: diff --git a/tests/test_subsequence.py b/tests/test_subsequence.py index 5099b9e3..22c6666c 100644 --- a/tests/test_subsequence.py +++ b/tests/test_subsequence.py @@ -120,7 +120,7 @@ def test_dtw_subseq_ndim(): assert m.value == pytest.approx(0.07071067811865482) -@pytest.skip() +@pytest.mark.skip @numpyonly def test_dtw_localconcurrences_eeg(): with util_numpy.test_uses_numpy() as np: @@ -174,7 +174,7 @@ def test_dtw_localconcurrences_eeg(): plt.close(fig) -@pytest.skip() +@pytest.mark.skip @numpyonly def test_dtw_localconcurrences_short(): with util_numpy.test_uses_numpy() as np: @@ -236,7 +236,7 @@ def test_dtw_subseqsearch_eeg(): sa = subsequence_search(query, s, dists_options={'use_c': True}) best = sa.kbest_matches_fast(k=k) toc = time.perf_counter() - print("Searching performed in {} seconds".format(toc - tic:0.4f)) + print("Searching performed in {:0.4f} seconds".format(toc - tic)) # print(sa.distances) # print(best) From fdb2019f607ea1644d2d1bd494d59de7fa2f2af0 Mon Sep 17 00:00:00 2001 From: wannesm Date: Fri, 7 Oct 2022 22:22:07 +0200 Subject: [PATCH 3/3] rm float test --- tests/test_float.py | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 tests/test_float.py diff --git a/tests/test_float.py b/tests/test_float.py deleted file mode 100644 index 0c750747..00000000 --- a/tests/test_float.py +++ /dev/null @@ -1,21 +0,0 @@ -import math -import pytest -from dtaidistance import ed, util_numpy - - -numpyonly = pytest.mark.skipif("util_numpy.test_without_numpy()") - - -@pytest.mark.skip -@numpyonly -def test_distance1_a(): - with util_numpy.test_uses_numpy() as np: - s1 = np.array([0., 0, 1, 2, 1, 0, 1, 0, 0], dtype=np.float32) - s2 = np.array([0., 1, 2, 0, 0, 0, 0, 0, 0], dtype=np.float32) - print(type(s1), s1.dtype) - d = ed.distance_fast(s1, s2) - assert(d) == pytest.approx(2.8284271247461903) - - -if __name__ == "__main__": - test_distance1_a()