wannesm / dtaidistance

Time series distances: Dynamic Time Warping (fast DTW implementation in C)
Other
1.08k stars 184 forks source link

RuntimeWarning: invalid value encountered in sqrt #122

Closed pachacamac closed 3 years ago

pachacamac commented 3 years ago

getting the following error when I try to execute one of the examples:

  dtw = np.sqrt(dtw)

the example code from the readme I tried was:

from dtaidistance import dtw_visualisation as dtwvis
import random
import numpy as np
x = np.arange(0, 20, .5)
s1 = np.sin(x)
s2 = np.sin(x - 1)
random.seed(1)
for idx in range(len(s2)):
    if random.random() < 0.05:
        s2[idx] += (random.random() - 0.5) / 2
d, paths = dtw.warping_paths(s1, s2, window=25, psi=2)
best_path = dtw.best_path(paths)
dtwvis.plot_warpingpaths(s1, s2, paths, best_path)
wannesm commented 3 years ago

Thanks for the report and reproducible example. This is related to #114 . A fix is in the works.

wannesm commented 3 years ago

This is fixed in b2d79c12ad7fe416521790453198ec714da438f7.