Commit 6feba67b authored by Franck Thollard's avatar Franck Thollard
Browse files

adding check capability

parent dff57cdc
from pathlib import Path
from invoke import task
import numpy as np
here = Path(__file__).parent.absolute()
......@@ -19,6 +20,18 @@ def build(c):
if (path / "Makefile").exists():
c.run(f"cd {path} && make", echo=True)
@task
def check(c):
ref_dtw = np.load("ref_small_dtw.npy")
ref_cort = np.load("ref_small_cort.npy")
for path in directories:
c.run(f"cd {path} && ./dtw_cort_dist_mat.py -s res", echo=True)
calc_dtw = np.load(f"{path / 'res_dtw.npy'}")
print(f"{path.name} dtw : allclose {np.allclose(ref_dtw, calc_dtw)}")
calc_cort = np.load(f"{path / 'res_cort.npy'}")
print(f"{path.name} cort: allclose {np.allclose(ref_cort, calc_cort)}")
@task
def bench(c, medium=False):
......
......@@ -33,6 +33,9 @@ def main(compute, only_init=False):
parser.add_argument(
"-n", type=int, default=None, help="number of series (default all 200)"
)
parser.add_argument(
"-s", type=str, default=None, help="save the matrices (provide prefixes)"
)
parser.add_argument(
"-v", action="store_true", default=None, help="visualize the matrix"
)
......@@ -55,12 +58,18 @@ def main(compute, only_init=False):
_dist_mat_dtw, _dist_mat_cort = compute(series, nb_series)
print("elapsed time = {:.3f} s".format(time() - t0))
if args.s:
dtw_mat = "{}_dtw".format(args.s)
np.save(dtw_mat, _dist_mat_dtw)
cort_mat = "{}_cort".format(args.s)
np.save(cort_mat, _dist_mat_cort)
if args.v:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(2)
cax0 = axes[0].imshow(_dist_mat_dtw, cmap=plt.cm.gray)
axes[0].imshow(_dist_mat_dtw, cmap=plt.cm.gray)
axes[0].set_title("dtw")
cax1 = axes[1].imshow(_dist_mat_cort, cmap=plt.cm.gray)
axes[1].imshow(_dist_mat_cort, cmap=plt.cm.gray)
axes[1].set_title("cort")
plt.show()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment