diff --git a/fastdtw/fastdtw.py b/fastdtw/fastdtw.py index f010d3a..22648e4 100644 --- a/fastdtw/fastdtw.py +++ b/fastdtw/fastdtw.py @@ -62,6 +62,9 @@ def __norm(p): def __fastdtw(x, y, radius, dist): + if not np.issubdtype(x.dtype, np.floating) or not np.issubdtype(y.dtype, np.floating): + return dtw(x, y, dist=dist) + min_time_size = radius + 2 if len(x) < min_time_size or len(y) < min_time_size: @@ -76,8 +79,8 @@ def __fastdtw(x, y, radius, dist): def __prep_inputs(x, y, dist): - x = np.asanyarray(x, dtype='float') - y = np.asanyarray(y, dtype='float') + x = np.asanyarray(x, dtype='str' if isinstance(y[0], str) else 'float') + y = np.asanyarray(y, dtype='str' if isinstance(y[0], str) else 'float') if x.ndim == y.ndim > 1 and x.shape[1] != y.shape[1]: raise ValueError('second dimension of x and y must be the same')