Coder Social home page Coder Social logo

fastdtw's People

Contributors

colobas avatar esquires avatar realead avatar slaypni avatar vmarkovtsev avatar willsalmanj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastdtw's Issues

FutureWarning raised due to future incompatibility with numpy >= 1.14.0

Python version: 3.7.1

It's quite an old issue, but I haven't seen it reported here yet (and it clutters up the output of scripts quite a bit).

When using the latest version (0.3.2) of fastdtw and version of numpy>=1.14, a FutureWarning is raised:

Minimum working example:

In [1]: from fastdtw import fastdtw
In [2]: x = [1, 2, 3, 4, 5]
In [3]: y = [1, 2, 3, 4, 5]
In [10]: fastdtw(x, y)
/home/michael/miniconda3/envs/ds/bin/ipython:1: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  #!/home/michael/miniconda3/envs/ds/bin/python
Out[10]: (0.0, [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)])

There are similarly related issues (that have since been resolved on the h5py project.
h5py/h5py#961

Thanks!

Local step size condition

Hi slaypni,

Thanks for your great work! In my work, I am experimenting with different local step size, such as (2,1)(1,2)(1,1). Could you point out where to change these step sizes in your cython code?

Creating a Loss module in PyTorch with FastDTW

Hi repository owner(s)!

I greatly appreciate your work, and I strongly believe that this implementation can help regression models from becoming similar to persistence models during training to become a forecasting utility.

I need some help in creating a loss module with the help of your library, here is my current design (simple):

class CustomLoss(nn.Module):
    def __init__(self):
        super(CustomLoss, self).__init__()

    def forward(self, predicted, target):
        # Calculate the dynamic time warping distance using FASTDTW
        distance, _ = fastdtw(predicted.detach().numpy(), target.detach().numpy(), dist=euclidean)

        # Convert the distance to a PyTorch tensor
        distance = torch.tensor(distance, dtype=torch.float32, requires_grad=True)

        # Return the distance as the loss
        return distance

criterion = CustomLoss()

Could I ask if this is the way to integrate your module into a custom loss module?

Thank you!

Installing from source: too many errors emitted

Hi, I am trying to install from source enable cython. However there seems to be a lot of errors:

python3 setup.py build

running build
running build_py
creating build
creating build/lib.macosx-10.12-x86_64-3.7
creating build/lib.macosx-10.12-x86_64-3.7/fastdtw
copying fastdtw/init.py -> build/lib.macosx-10.12-x86_64-3.7/fastdtw
copying fastdtw/fastdtw.py -> build/lib.macosx-10.12-x86_64-3.7/fastdtw
running build_ext
building 'fastdtw._fastdtw' extension
creating build/temp.macosx-10.12-x86_64-3.7
creating build/temp.macosx-10.12-x86_64-3.7/fastdtw
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/opt/[email protected]/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c fastdtw/_fastdtw.cpp -o build/temp.macosx-10.12-x86_64-3.7/fastdtw/_fastdtw.o
fastdtw/_fastdtw.cpp:2092:7: warning: & has lower precedence than ==; == will be evaluated
first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:2092:7: note: place parentheses around the '==' expression to silence
this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:2092:7: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:2770:7: warning: & has lower precedence than ==; == will be evaluated
first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:2770:7: note: place parentheses around the '==' expression to silence
this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:2770:7: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:3527:7: warning: & has lower precedence than ==; == will be evaluated
first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:3527:7: note: place parentheses around the '==' expression to silence
this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:3527:7: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:4136:7: warning: & has lower precedence than ==; == will be evaluated
first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:4136:7: note: place parentheses around the '==' expression to silence
this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:4136:7: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:4212:7: warning: & has lower precedence than ==; == will be evaluated
first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:4212:7: note: place parentheses around the '==' expression to silence
this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:4212:7: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:4554:13: warning: & has lower precedence than ==; == will be
evaluated first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:4554:13: note: place parentheses around the '==' expression to
silence this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:4554:13: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:4801:11: warning: & has lower precedence than ==; == will be
evaluated first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:4801:11: note: place parentheses around the '==' expression to
silence this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:4801:11: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:10271:11: warning: & has lower precedence than ==; == will be
evaluated first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:10271:11: note: place parentheses around the '==' expression to
silence this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:10271:11: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:10573:9: warning: & has lower precedence than ==; == will be
evaluated first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:10573:9: note: place parentheses around the '==' expression to
silence this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:10573:9: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:16959:9: warning: & has lower precedence than ==; == will be
evaluated first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:16959:9: note: place parentheses around the '==' expression to
silence this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:16959:9: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:17077:11: warning: & has lower precedence than ==; == will be
evaluated first [-Wparentheses]
if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fastdtw/_fastdtw.cpp:17077:11: note: place parentheses around the '==' expression to
silence this warning
if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fastdtw/_fastdtw.cpp:17077:11: note: place parentheses around the & expression to evaluate
it first
if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:193:79: note: expanded from macro '__Pyx_PyFastCFunction_Check'
...== PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastdtw/_fastdtw.cpp:20258:65: error: too many arguments to function call, expected 3,
have 4
return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/stddef.h:100:18: note:
expanded from macro 'NULL'

define NULL __null

             ^~~~~~

fastdtw/_fastdtw.cpp:22266:21: error: no member named 'exc_type' in '_ts'
*type = tstate->exc_type;
~~~~~~ ^
fastdtw/_fastdtw.cpp:22267:22: error: no member named 'exc_value' in '_ts'; did you mean
'curexc_value'?
*value = tstate->exc_value;
^~~~~~~~~
curexc_value
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:240:15: note:
'curexc_value' declared here
PyObject *curexc_value;
^
fastdtw/_fastdtw.cpp:22268:19: error: no member named 'exc_traceback' in '_ts'; did you
mean 'curexc_traceback'?
*tb = tstate->exc_traceback;
^~~~~~~~~~~~~
curexc_traceback
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:241:15: note:
'curexc_traceback' declared here
PyObject *curexc_traceback;
^
fastdtw/_fastdtw.cpp:22275:24: error: no member named 'exc_type' in '_ts'
tmp_type = tstate->exc_type;
~~~~~~ ^
fastdtw/_fastdtw.cpp:22276:25: error: no member named 'exc_value' in '_ts'; did you mean
'curexc_value'?
tmp_value = tstate->exc_value;
^~~~~~~~~
curexc_value
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:240:15: note:
'curexc_value' declared here
PyObject *curexc_value;
^
fastdtw/_fastdtw.cpp:22277:22: error: no member named 'exc_traceback' in '_ts'; did you
mean 'curexc_traceback'?
tmp_tb = tstate->exc_traceback;
^~~~~~~~~~~~~
curexc_traceback
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:241:15: note:
'curexc_traceback' declared here
PyObject *curexc_traceback;
^
fastdtw/_fastdtw.cpp:22278:13: error: no member named 'exc_type' in '_ts'
tstate->exc_type = type;
~~~~~~ ^
fastdtw/_fastdtw.cpp:22279:13: error: no member named 'exc_value' in '_ts'; did you mean
'curexc_value'?
tstate->exc_value = value;
^~~~~~~~~
curexc_value
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:240:15: note:
'curexc_value' declared here
PyObject *curexc_value;
^
fastdtw/_fastdtw.cpp:22280:13: error: no member named 'exc_traceback' in '_ts'; did you
mean 'curexc_traceback'?
tstate->exc_traceback = tb;
^~~~~~~~~~~~~
curexc_traceback
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:241:15: note:
'curexc_traceback' declared here
PyObject *curexc_traceback;
^
fastdtw/_fastdtw.cpp:22335:24: error: no member named 'exc_type' in '_ts'
tmp_type = tstate->exc_type;
~~~~~~ ^
fastdtw/_fastdtw.cpp:22336:25: error: no member named 'exc_value' in '_ts'; did you mean
'curexc_value'?
tmp_value = tstate->exc_value;
^~~~~~~~~
curexc_value
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:240:15: note:
'curexc_value' declared here
PyObject *curexc_value;
^
fastdtw/_fastdtw.cpp:22337:22: error: no member named 'exc_traceback' in '_ts'; did you
mean 'curexc_traceback'?
tmp_tb = tstate->exc_traceback;
^~~~~~~~~~~~~
curexc_traceback
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:241:15: note:
'curexc_traceback' declared here
PyObject *curexc_traceback;
^
fastdtw/_fastdtw.cpp:22338:13: error: no member named 'exc_type' in '_ts'
tstate->exc_type = local_type;
~~~~~~ ^
fastdtw/_fastdtw.cpp:22339:13: error: no member named 'exc_value' in '_ts'; did you mean
'curexc_value'?
tstate->exc_value = local_value;
^~~~~~~~~
curexc_value
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:240:15: note:
'curexc_value' declared here
PyObject *curexc_value;
^
fastdtw/_fastdtw.cpp:22340:13: error: no member named 'exc_traceback' in '_ts'; did you
mean 'curexc_traceback'?
tstate->exc_traceback = local_tb;
^~~~~~~~~~~~~
curexc_traceback
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:241:15: note:
'curexc_traceback' declared here
PyObject *curexc_traceback;
^
fastdtw/_fastdtw.cpp:22575:24: error: no member named 'exc_type' in '_ts'
tmp_type = tstate->exc_type;
~~~~~~ ^
fastdtw/_fastdtw.cpp:22576:25: error: no member named 'exc_value' in '_ts'; did you mean
'curexc_value'?
tmp_value = tstate->exc_value;
^~~~~~~~~
curexc_value
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:240:15: note:
'curexc_value' declared here
PyObject *curexc_value;
^
fastdtw/_fastdtw.cpp:22577:22: error: no member named 'exc_traceback' in '_ts'; did you
mean 'curexc_traceback'?
tmp_tb = tstate->exc_traceback;
^~~~~~~~~~~~~
curexc_traceback
/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:241:15: note:
'curexc_traceback' declared here
PyObject *curexc_traceback;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
11 warnings and 20 errors generated.
setup.py:86: UserWarning: compilation failed. Installing pure python package
warnings.warn(reason+'compilation failed. Installing pure python package')

Output of the distance matrix

Is it possible to output the distance matrix? Right now it is just the distance and the path (which can also be obtained from the distance matrix).

fastdtw doesn't work in lambda...

I have two code. one is use default dist, another is use Euclidean func..
I test two code in my MacBook. and it work!
but in AWS lambda it doesn't work.. but I don't know why..
because Euclidean func is work but default doesn't work..
this is AWS lambda error..

>>> from fastdtw import fastdtw
>>> import numpy as np
>>> np.zeros((3,5))
array([[ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.]])
>>> a = np.zeros((3,5))
>>> b = np.zeros((3,5))
>>> fastdtw(a,b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fastdtw.py", line 65, in fastdtw
    return __fastdtw(x, y, radius, dist)
  File "fastdtw.py", line 85, in __fastdtw
    __fastdtw(x_shrinked, y_shrinked, radius=radius, dist=dist)
  File "fastdtw.py", line 80, in __fastdtw
    return dtw(x, y, dist=dist)
  File "fastdtw.py", line 128, in dtw
    (D[i-1, j-1][0]+dt, i-1, j-1), key=lambda a: a[0])
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

but same code In my Mackbook.. it work!

>>> import numpy as np
>>> from fastdtw import fastdtw
>>> a = np.zeros((4,5))
>>> b = np.zeros((4,5))
>>> fastdtw(a,b)
Out[6]: (0.0, [(0, 0), (1, 1), (2, 2), (3, 3)])
>>> dist,path = fastdtw(a,b)
>>> dist
Out[8]: 0.0
>>> path
Out[9]: [(0, 0), (1, 1), (2, 2), (3, 3)]

Corner case bug?

I'm getting an index error in line 148 of fastdtw.py

i, j = D[i, j][1], D[i, j][2]

when (i,j) = (0,1) because D[i,j] = (inf,) and that is a tuple of length one. Is it correct that the next step should be (0,0)?

Building wheel for fastdtw (setup.py) ... error

Hi,

When I used pip install fastdtw, I got this error:

Collecting fastdtw
Using cached fastdtw-0.3.4.tar.gz (133 kB)
Requirement already satisfied: numpy in c:\users\alma\appdata\local\programs\python\python38\lib\site-packages (from fastdtw) (1.21.1)
Building wheels for collected packages: fastdtw
Building wheel for fastdtw (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\alma\appdata\local\programs\python\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py'"'"'; file='"'"'C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Alma\AppData\Local\Temp\pip-wheel-eqz2yrmr' cwd: C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2
Complete output (46 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\fastdtw
copying fastdtw\fastdtw.py -> build\lib.win-amd64-3.8\fastdtw
copying fastdtw_init_.py -> build\lib.win-amd64-3.8\fastdtw
running build_ext
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py", line 81, in
setup(**kwargs)
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\setuptools_init_.py", line 153, in setup
return distutils.core.setup(**attrs)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
self.run_command('build')
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
_build_ext.run(self)
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\command\build_ext.py", line 306, in run
self.compiler = new_compiler(compiler=self.compiler,
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\ccompiler.py", line 1032, in new_compiler
return klass(None, dry_run, force)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 282, in init
CygwinCCompiler.init (self, verbose, dry_run, force)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 126, in init
if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'

ERROR: Failed building wheel for fastdtw
Running setup.py clean for fastdtw
Failed to build fastdtw
Installing collected packages: fastdtw
Running setup.py install for fastdtw ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\alma\appdata\local\programs\python\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py'"'"'; file='"'"'C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file)
if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Alma\AppData\Local\Temp\pip-record-zr003v8k\install-record.txt' --single-version-externally-managed --compile --install-headers c:\users\alma\appdata\local\programs\python\python38\Include\fastdtw' cwd: C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2
Complete output (48 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\fastdtw
copying fastdtw\fastdtw.py -> build\lib.win-amd64-3.8\fastdtw
copying fastdtw_init_.py -> build\lib.win-amd64-3.8\fastdtw
running build_ext
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py", line 81, in
setup(**kwargs)
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\setuptools_init_.py", line 153, in setup
return distutils.core.setup(**attrs)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\install.py", line 61, in run
return orig.install.run(self)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
_build_ext.run(self)
File "c:\users\alma\appdata\local\programs\python\python38\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\command\build_ext.py", line 306, in run
self.compiler = new_compiler(compiler=self.compiler,
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\ccompiler.py", line 1032, in new_compiler
return klass(None, dry_run, force)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 282, in init
CygwinCCompiler.init (self, verbose, dry_run, force)
File "c:\users\alma\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 126, in init
if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'

ERROR: Command errored out with exit status 1: 'c:\users\alma\appdata\local\programs\python\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py'"'"'; file='"'"'C:\Users\Alma\AppData\Local\Temp\pip-install-ntat_l8u\fastdtw_79f25377447c4796a756f2578fb594e2\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Alma\AppData\Local\Temp\pip-record
-zr003v8k\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\alma\appdata\local\programs\python\python38\In
clude\fastdtw' Check the logs for full command output.

What should I do?
Thanks in advance.

Changing radius has no effect

Please see the example below - changing radius produces no change in distance function, which doesn't make sense for this example. It seems like radius parameter is ignored....

N = 100
idx = np.linspace(0, 2*np.pi, N)
T1 = np.cos(idx)
Q1 = np.sin(idx) + np.array(np.random.uniform(low=0,high=1,size=(N,)))/10

for r in range(1,10):
    print(5*r)
    dist_f1, path_f1 = fastdtw(Q1, T1, dist=euclidean, radius=r)
    print(dist_f1)

bug in __reduce_by_half(x) ?

I think there is a bug in the shortest function: __reduce_by_half(x). With the current version, only the first half of x is used to compute the reduced vector.

Shouldn't it be something like:
def __reduce_by_half(x):
return [(x[i] + x[1+i]) / 2 for i in xrange(0, len(x)-len(x)%2, 2)]

path & distance

Hi, is there any possibility how to express the both parameters (path & distance) with one metric - integer?
distance, path = fastdtw(ref, x)

Tests fail: No module named 'fastdtw._fastdtw'

================================================================================== ERRORS ===================================================================================
__________________________________________________________________ ERROR collecting tests/test_fastdtw.py ___________________________________________________________________
ImportError while importing test module '/usr/ports/math/py-fastdtw/work-py36/fastdtw-0.3.2/tests/test_fastdtw.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_fastdtw.py:10: in <module>
    from fastdtw._fastdtw import fastdtw as fastdtw_c
E   ModuleNotFoundError: No module named 'fastdtw._fastdtw'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================== 1 error in 0.27 seconds ==========================================================================

Synchronize more than 2 Time-Series

Hi,

with the following code there is possible to synchronize two time series (x and y).

import numpy as np
from scipy.spatial.distance import euclidean

from fastdtw import fastdtw

x = np.array([[1,1], [2,2], [3,3], [4,4], [5,5]])
y = np.array([[2,2], [3,3], [4,4]])
distance, path = fastdtw(x, y, dist=euclidean)

Is there any way how to synchronize more than two time series?

I tried to:
distance, path = fastdtw(x, y, z, dist=euclidean)
but only size-1 arrays can be converted to Python scalars.

To use the cython extension with windows ...

I had to do the following modifications:

  1. Install the msvc for python https://www.microsoft.com/en-us/download/details.aspx?id=44266
  2. Adjust the setup.py a) to not use stdlibc++, b) to use cythonize (from Cython.Build import cythonize and in kwargs change ext_module to 'ext_modules': cythonize(extensions), c) import numpy and add include_dirs=[numpy.get_include()], in extensions:
from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
import os.path
import warnings
import numpy

classifiers = [
    'Programming Language :: Python :: 2',
    'Programming Language :: Python :: 3',
    'Intended Audience :: Science/Research',
    'License :: OSI Approved :: MIT License',
    'Topic :: Scientific/Engineering'
]

extensions = [Extension(
        'fastdtw._fastdtw',
        [os.path.join('fastdtw', "_fastdtw.pyx")],
        language="c++",
        include_dirs=[numpy.get_include()],
#       if you want to debug from MSVC IDE uncomment the following
#        extra_compile_args=["-Zi", "/Od"],
#        extra_link_args=["-debug"],

#        libraries=["stdc++","stdc"]
    )]

kwargs = {
    'name': 'fastdtw',
    'version': '0.3.0',
    'author': 'Kazuaki Tanida',
    'url': 'https://github.com/slaypni/fastdtw',
    'description': 'Dynamic Time Warping (DTW) algorithm with an O(N) time and memory complexity.',
    'license': 'MIT',
    'keywords': ['dtw'],
    'install_requires': ['numpy'],
    'packages': find_packages(),
    'ext_modules':  cythonize(extensions),
    'test_suite': 'tests',
    'setup_requires': ['pytest-runner'],
    'tests_require': ['pytest'],
    'classifiers': classifiers
}

try:
    setup(**kwargs)
except SystemExit:
    del kwargs['ext_modules']
    warnings.warn('compilation failed. Installing pure python package')
    setup(**kwargs)
  1. Modify the cpx to use the INFINITY definition from numpy:
#from libc.math cimport INFINITY,pow, fabs
from libc.math cimport pow, fabs
from numpy.math cimport INFINITY

Thank you for your great work!

Jan

Compilation Failed

I am getting the following error while building the library. Would you mind looking into this?

screen shot 2017-08-21 at 6 07 15 pm

Using dist=euclidean is slow

Just wanted to note that the performance of using dist=euclidean is much slower compared to dist=2

In [51]: def get_dtw_distances(integer, dist=2):
    ...:     ind = np.argwhere(events == integer)[0][0]
    ...:     a = dataset[:, :n_steps, 0].reshape(N_SAMPLES, n_steps)
    ...:     b = dataset[ind, :n_steps, 0].flatten()
    ...:     for i, row in enumerate(a):
    ...:         if i==1000:
    ...:             return fastdtw(b, row, dist=dist)[0]
    ...:         fastdtw(b, row, dist=dist)[0]
    ...:

In [52]: %timeit get_dtw_distances(519855, dist=2)
123 ms ± 1.66 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [53]: %timeit get_dtw_distances(519855, dist=euclidean)
5.31 s ± 41.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [54]: get_dtw_distances(519855, dist=2)
Out[54]: 424.53000000000003

In [55]: get_dtw_distances(519855, dist=euclidean)
Out[55]: 424.53000000000003

or for the example in the README (which maybe should be changed....)

In [1]: import numpy as np
   ...: from scipy.spatial.distance import euclidean
   ...:
   ...: from fastdtw import fastdtw
   ...:
   ...: x = np.array([[1,1], [2,2], [3,3], [4,4], [5,5]])
   ...: y = np.array([[2,2], [3,3], [4,4]])
   ...: distance, path = fastdtw(x, y, dist=euclidean)
   ...: print(distance)
2.8284271247461903

In [2]: %timeit distance, path = fastdtw(x, y, dist=euclidean)
325 µs ± 7.49 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [3]: %timeit distance, path = fastdtw(x, y, dist=2)
69.8 µs ± 1.19 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)

In [4]: distance, path = fastdtw(x, y, dist=2)

In [5]: distance
Out[5]: 2.8284271247461903

Tuple out of index error

I got a time-series dataset containing 27 columns X 782 rows. I found that once the dataset exceeded 20000 float-point data. fastdtw will throw IndexError: tuple index out of range.
Is there a way to fix this because I need to cluster at least 50 columns X 782 rows.
David Fung
Environment: Windows 10 Home, Python 3.8.3, IPython 7.16.1

The following is the dump generated by the Spyder IDE:
runfile('C:/Users/dfoo1/anaconda3/AIOPython/SP500MK02M02_test.py', wdir='C:/Users/dfoo1/anaconda3/AIOPython')
Scaling...

Applying Trend Clustering...

Dataset dimensions: 21087
15176786 function calls (15176752 primitive calls) in 4.859 seconds

Ordered by: standard name

ncalls tottime percall cumtime percall filename:lineno(function)
5 0.000 0.000 0.000 0.000 :1017(_handle_fromlist)
1 0.000 0.000 4.859 4.859 :1()
2 0.000 0.000 4.836 2.418 SP500MK02M02_test.py:144(fastdtw_distance)
1 0.000 0.000 4.859 4.859 SP500MK02M02_test.py:57(fit)
1 0.022 0.022 0.022 0.022 SP500MK02M02_test.py:77()
1 0.000 0.000 4.836 4.836 SP500MK02M02_test.py:81()
2 0.000 0.000 4.836 2.418 SP500MK02M02_test.py:82()
8/4 0.000 0.000 0.000 0.000 _asarray.py:16(asarray)
8 0.000 0.000 0.000 0.000 _asarray.py:88(asanyarray)
3 0.000 0.000 0.000 0.000 _dtype.py:319(_name_includes_bit_suffix)
3 0.000 0.000 0.000 0.000 _dtype.py:333(_name_get)
3 0.000 0.000 0.000 0.000 _dtype.py:36(_kind_name)
6 0.000 0.000 0.000 0.000 _internal.py:830(npy_ctypes_check)
4 0.000 0.000 0.000 0.000 _ufunc_config.py:139(geterr)
4 0.000 0.000 0.000 0.000 _ufunc_config.py:39(seterr)
2 0.000 0.000 0.000 0.000 _ufunc_config.py:437(init)
2 0.000 0.000 0.000 0.000 _ufunc_config.py:441(enter)
2 0.000 0.000 0.000 0.000 _ufunc_config.py:446(exit)
17 0.000 0.000 0.000 0.000 abc.py:96(instancecheck)
1 0.000 0.000 0.000 0.000 base.py:1026(iter)
1 0.000 0.000 0.000 0.000 base.py:1186(name)
14 0.000 0.000 0.000 0.000 base.py:247(is_dtype)
2 0.000 0.000 0.000 0.000 base.py:5294(ensure_index)
1 0.000 0.000 0.000 0.000 base.py:5388(default_index)
5 0.000 0.000 0.000 0.000 base.py:5394(maybe_extract_name)
1 0.000 0.000 0.000 0.000 base.py:592(_reset_identity)
3 0.000 0.000 0.000 0.000 blocks.py:118(init)
3 0.000 0.000 0.000 0.000 blocks.py:129(_check_ndim)
2 0.000 0.000 0.000 0.000 blocks.py:187(is_categorical_astype)
2 0.000 0.000 0.000 0.000 blocks.py:202(external_values)
3 0.000 0.000 0.000 0.000 blocks.py:213(internal_values)
4 0.000 0.000 0.000 0.000 blocks.py:219(array_values)
2 0.000 0.000 0.000 0.000 blocks.py:225(get_values)
5 0.000 0.000 0.000 0.000 blocks.py:247(mgr_locs)
3 0.000 0.000 0.000 0.000 blocks.py:251(mgr_locs)
2 0.000 0.000 0.000 0.000 blocks.py:2597(init)
3 0.000 0.000 0.000 0.000 blocks.py:2987(get_block_type)
3 0.000 0.000 0.000 0.000 blocks.py:3033(make_block)
2 0.000 0.000 0.000 0.000 blocks.py:3059(_extend_blocks)
2 0.000 0.000 0.000 0.000 blocks.py:335(shape)
5 0.000 0.000 0.000 0.000 blocks.py:339(dtype)
2 0.000 0.000 0.000 0.000 blocks.py:554(astype)
1 0.000 0.000 0.000 0.000 cast.py:1088(maybe_castable)
1 0.000 0.000 0.000 0.000 cast.py:1102(maybe_infer_to_datetimelike)
1 0.000 0.000 0.000 0.000 cast.py:1209(maybe_cast_to_datetime)
1 0.000 0.000 0.000 0.000 cast.py:1483(construct_1d_ndarray_preserving_na)
2 0.000 0.000 0.000 0.000 cast.py:799(astype_nansafe)
14 0.000 0.000 0.000 0.000 common.py:1565(is_extension_array_dtype)
4 0.000 0.000 0.000 0.000 common.py:1672(_get_dtype)
16 0.000 0.000 0.000 0.000 common.py:1708(_is_dtype_type)
2 0.000 0.000 0.000 0.000 common.py:179(ensure_python_int)
1 0.000 0.000 0.000 0.000 common.py:183(all_none)
9 0.000 0.000 0.000 0.000 common.py:1844(pandas_dtype)
2 0.000 0.000 0.000 0.000 common.py:187()
15 0.000 0.000 0.000 0.000 common.py:206(classes)
15 0.000 0.000 0.000 0.000 common.py:208()
1 0.000 0.000 0.000 0.000 common.py:211(classes_and_not_datetimelike)
1 0.000 0.000 0.000 0.000 common.py:216()
7 0.000 0.000 0.000 0.000 common.py:222(is_object_dtype)
3 0.000 0.000 0.000 0.000 common.py:252(is_sparse)
1 0.000 0.000 0.000 0.000 common.py:275(maybe_iterable_to_list)
3 0.000 0.000 0.000 0.000 common.py:339(is_categorical)
4 0.000 0.000 0.000 0.000 common.py:372(is_datetime64_dtype)
3 0.000 0.000 0.000 0.000 common.py:403(is_datetime64tz_dtype)
4 0.000 0.000 0.000 0.000 common.py:441(is_timedelta64_dtype)
3 0.000 0.000 0.000 0.000 common.py:472(is_period_dtype)
3 0.000 0.000 0.000 0.000 common.py:506(is_interval_dtype)
5 0.000 0.000 0.000 0.000 common.py:542(is_categorical_dtype)
2 0.000 0.000 0.000 0.000 common.py:685(is_dtype_equal)
1 0.000 0.000 0.000 0.000 common.py:775(is_integer_dtype)
1 0.000 0.000 0.000 0.000 construction.py:337(extract_array)
1 0.000 0.000 0.000 0.000 construction.py:388(sanitize_array)
1 0.000 0.000 0.000 0.000 construction.py:506(_try_cast)
3 0.000 0.000 0.000 0.000 construction.py:570(is_empty_data)
3 0.000 0.000 0.000 0.000 dtypes.py:1124(is_dtype)
16 0.000 0.000 0.000 0.000 dtypes.py:75(find)
3 0.000 0.000 0.000 0.000 dtypes.py:917(is_dtype)
12 0.780 0.065 1.599 0.133 fastdtw.py:133(__dtw)
2 0.000 0.000 0.000 0.000 fastdtw.py:136()
502384 0.093 0.000 0.093 0.000 fastdtw.py:137()
6140 0.002 0.000 0.002 0.000 fastdtw.py:138()
1507116 0.117 0.000 0.117 0.000 fastdtw.py:143()
2 0.004 0.002 4.836 2.418 fastdtw.py:15(fastdtw)
20 0.000 0.000 0.002 0.000 fastdtw.py:153(__reduce_by_half)
20 0.002 0.000 0.002 0.000 fastdtw.py:154()
10 1.660 0.166 3.097 0.310 fastdtw.py:157(__expand_window)
5219612 0.755 0.000 0.755 0.000 fastdtw.py:160()
12/2 0.134 0.011 4.832 2.416 fastdtw.py:64(__fastdtw)
4 0.000 0.000 0.000 0.000 fastdtw.py:78(__prep_inputs)
2 0.000 0.000 0.004 0.002 fastdtw.py:98(dtw)
66 0.000 0.000 0.000 0.000 generic.py:10(check)
3 0.000 0.000 0.000 0.000 generic.py:190(init)
2 0.000 0.000 0.000 0.000 generic.py:238(attrs)
2 0.000 0.000 0.000 0.000 generic.py:5235(finalize)
11 0.000 0.000 0.000 0.000 generic.py:5257(getattr)
3 0.000 0.000 0.000 0.000 generic.py:5276(setattr)
2 0.000 0.000 0.000 0.000 generic.py:5563(astype)
5 0.000 0.000 0.000 0.000 inference.py:299(is_dict_like)
11 0.000 0.000 0.000 0.000 inference.py:325()
12 0.000 0.000 0.000 0.000 inference.py:358(is_hashable)
2 0.000 0.000 0.000 0.000 inspect.py:72(isclass)
3 0.000 0.000 0.000 0.000 managers.py:1467(init)
12 0.000 0.000 0.000 0.000 managers.py:1520(block)
2 0.000 0.000 0.000 0.000 managers.py:1544(index)
3 0.000 0.000 0.000 0.000 managers.py:1548(dtype)
2 0.000 0.000 0.000 0.000 managers.py:1562(external_values)
3 0.000 0.000 0.000 0.000 managers.py:1565(internal_values)
2 0.000 0.000 0.000 0.000 managers.py:1582(consolidate_inplace)
3 0.000 0.000 0.000 0.000 managers.py:232(items)
3 0.000 0.000 0.000 0.000 managers.py:314(len)
2 0.000 0.000 0.000 0.000 managers.py:368(apply)
2 0.000 0.000 0.000 0.000 managers.py:419()
2 0.000 0.000 0.000 0.000 managers.py:581(astype)
3 0.000 0.000 0.000 0.000 numeric.py:155(is_all_dates)
1 0.000 0.000 0.000 0.000 numeric.py:83(validate_dtype)
10 0.000 0.000 0.000 0.000 numerictypes.py:293(issubclass
)
5 0.000 0.000 0.000 0.000 numerictypes.py:365(issubdtype)
4 0.000 0.000 0.000 0.000 numpy
.py:138(init)
4 0.000 0.000 0.000 0.000 numpy
.py:183(array)
4 0.000 0.000 0.000 0.000 numpy.py:42(init)
1 0.000 0.000 0.000 0.000 range.py:131(_simple_new)
5 0.000 0.000 0.000 0.000 range.py:675(len)
1 0.000 0.000 0.000 0.000 range.py:83(new)
3 0.000 0.000 0.000 0.000 series.py:183(init)
2 0.000 0.000 0.000 0.000 series.py:359(_constructor)
2/1 0.000 0.000 4.836 4.836 series.py:3719(apply)
3 0.000 0.000 0.000 0.000 series.py:376(_set_axis)
3 0.000 0.000 0.000 0.000 series.py:403(_set_subtyp)
3 0.000 0.000 0.000 0.000 series.py:414(dtype)
5 0.000 0.000 0.000 0.000 series.py:428(name)
5 0.000 0.000 0.000 0.000 series.py:432(name)
2 0.000 0.000 0.000 0.000 series.py:438(values)
3 0.000 0.000 0.000 0.000 series.py:480(_values)
4 0.000 0.000 0.000 0.000 series.py:515(array)
3 0.000 0.000 0.000 0.000 series.py:548(len)
4 0.000 0.000 0.000 0.000 series.py:707(array)
502372 0.206 0.000 0.247 0.000 utils.py:25(abs_distance)
1 0.000 0.000 0.000 0.000 {built-in method new of type object at 0x00007FF9F575C810}
17 0.000 0.000 0.000 0.000 {built-in method _abc._abc_instancecheck}
502372 0.041 0.000 0.041 0.000 {built-in method builtins.abs}
6 0.000 0.000 0.000 0.000 {built-in method builtins.all}
2 0.000 0.000 0.000 0.000 {built-in method builtins.callable}
1 0.000 0.000 4.859 4.859 {built-in method builtins.exec}
102 0.000 0.000 0.000 0.000 {built-in method builtins.getattr}
19 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr}
12 0.000 0.000 0.000 0.000 {built-in method builtins.hash}
218 0.000 0.000 0.000 0.000 {built-in method builtins.isinstance}
75 0.000 0.000 0.000 0.000 {built-in method builtins.issubclass}
138/128 0.000 0.000 0.000 0.000 {built-in method builtins.len}
502372 0.359 0.000 0.475 0.000 {built-in method builtins.min}
1 0.000 0.000 0.000 0.000 {built-in method numpy.arange}
18/10 0.000 0.000 0.000 0.000 {built-in method numpy.array}
8 0.000 0.000 0.000 0.000 {built-in method numpy.geterrobj}
4 0.000 0.000 0.000 0.000 {built-in method numpy.seterrobj}
5928830 0.653 0.000 0.653 0.000 {method 'add' of 'set' objects}
504311 0.030 0.000 0.030 0.000 {method 'append' of 'list' objects}
4 0.000 0.000 0.000 0.000 {method 'astype' of 'numpy.ndarray' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
1 0.000 0.000 0.000 0.000 {method 'format' of 'str' objects}
2 0.000 0.000 0.000 0.000 {method 'pop' of 'dict' objects}
2 0.000 0.000 0.000 0.000 {method 'ravel' of 'numpy.ndarray' objects}
2 0.000 0.000 0.000 0.000 {method 'reshape' of 'numpy.ndarray' objects}
11 0.000 0.000 0.000 0.000 {method 'reverse' of 'list' objects}
7 0.000 0.000 0.000 0.000 {pandas._libs.lib.is_list_like}
2 0.000 0.000 0.000 0.000 {pandas._libs.lib.is_scalar}
2/1 0.000 0.000 4.836 4.836 {pandas._libs.lib.map_infer}

Traceback (most recent call last):

File "C:\Users\dfoo1\anaconda3\AIOPython\SP500MK02M02_test.py", line 219, in
cProfile.run('trendy.fit(stockPriceList)')

File "C:\Users\dfoo1\anaconda3\lib\cProfile.py", line 16, in run
return _pyprofile._Utils(Profile).run(statement, filename, sort)

File "C:\Users\dfoo1\anaconda3\lib\profile.py", line 53, in run
prof.run(statement)

File "C:\Users\dfoo1\anaconda3\lib\cProfile.py", line 95, in run
return self.runctx(cmd, dict, dict)

File "C:\Users\dfoo1\anaconda3\lib\cProfile.py", line 100, in runctx
exec(cmd, globals, locals)

File "", line 1, in

File "C:\Users\dfoo1\anaconda3\AIOPython\SP500MK02M02_test.py", line 80, in fit
X_idx.apply(

File "C:\Users\dfoo1\anaconda3\lib\site-packages\pandas\core\series.py", line 3848, in apply
mapped = lib.map_infer(values, f, convert=convert_dtype)

File "pandas_libs\lib.pyx", line 2329, in pandas._libs.lib.map_infer

File "C:\Users\dfoo1\anaconda3\AIOPython\SP500MK02M02_test.py", line 81, in
lambda x: X_idx.apply(

File "C:\Users\dfoo1\anaconda3\lib\site-packages\pandas\core\series.py", line 3848, in apply
mapped = lib.map_infer(values, f, convert=convert_dtype)

File "pandas_libs\lib.pyx", line 2329, in pandas._libs.lib.map_infer

File "C:\Users\dfoo1\anaconda3\AIOPython\SP500MK02M02_test.py", line 82, in
lambda y: self.fastdtw_distance(X[x], X[y]))))

File "C:\Users\dfoo1\anaconda3\AIOPython\SP500MK02M02_test.py", line 166, in fastdtw_distance
return fastdtw(x, y, radius, dist=d)[0]

File "C:\Users\dfoo1\anaconda3\lib\site-packages\fastdtw\fastdtw.py", line 53, in fastdtw
return __fastdtw(x, y, radius, dist)

File "C:\Users\dfoo1\anaconda3\lib\site-packages\fastdtw\fastdtw.py", line 75, in __fastdtw
return __dtw(x, y, window, dist=dist)

File "C:\Users\dfoo1\anaconda3\lib\site-packages\fastdtw\fastdtw.py", line 148, in __dtw
i, j = D[i, j][1], D[i, j][2]

IndexError: tuple index out of range

Using with x/y sizes of (n, m) where m >1

I appreciate your package - it has made my life much easier. However, I have a question that I was hoping you could resolve:
In the case of:
X being an array of size (n,1), and
Y being an array of size (m,1), where m/n are number of samples,

What if I had arrays of:
X being size (n,2), and
Y being size (n,2).

Example of use case being if I have two related time series measurements such as machine vibration frequency and machine operating temperature. Both are distinct measurements, and when doing a manual correlation you can better match events when using both indicators in tandem than just one.

The code certainly runs in both scenarios, and outputs unique paths when I run just component 1 vs. just component 2 vs. both 1 and 2 at same time.

However, with existing documentation it's hard to understand the workings of what is going on.

Difference in result between python and .so

Hi

import fastdtw

x = range(0, 1000)
y = [0 for i in x]

distance, path = fastdtw.fastdtw(x, y)

With .so the path is:
0000 = {tuple} <class 'tuple'>: (0, 0)
0001 = {tuple} <class 'tuple'>: (1, 1)
0002 = {tuple} <class 'tuple'>: (2, 2)
0003 = {tuple} <class 'tuple'>: (3, 3)
0004 = {tuple} <class 'tuple'>: (4, 4)
0005 = {tuple} <class 'tuple'>: (5, 5)
0006 = {tuple} <class 'tuple'>: (6, 6)
0007 = {tuple} <class 'tuple'>: (7, 7)
0008 = {tuple} <class 'tuple'>: (8, 8)
0009 = {tuple} <class 'tuple'>: (9, 9)
0010 = {tuple} <class 'tuple'>: (10, 10)
0011 = {tuple} <class 'tuple'>: (11, 11)
0012 = {tuple} <class 'tuple'>: (12, 12)
0013 = {tuple} <class 'tuple'>: (13, 13)
0014 = {tuple} <class 'tuple'>: (14, 14)
0015 = {tuple} <class 'tuple'>: (15, 15)
0016 = {tuple} <class 'tuple'>: (16, 16)
0017 = {tuple} <class 'tuple'>: (17, 17)
0018 = {tuple} <class 'tuple'>: (18, 18)
0019 = {tuple} <class 'tuple'>: (19, 19)
0020 = {tuple} <class 'tuple'>: (20, 20)
0021 = {tuple} <class 'tuple'>: (21, 21)
0022 = {tuple} <class 'tuple'>: (22, 22)
0023 = {tuple} <class 'tuple'>: (23, 23)
0024 = {tuple} <class 'tuple'>: (24, 24)
0025 = {tuple} <class 'tuple'>: (25, 25)
0026 = {tuple} <class 'tuple'>: (26, 26)
0027 = {tuple} <class 'tuple'>: (27, 27)
0028 = {tuple} <class 'tuple'>: (28, 28)
0029 = {tuple} <class 'tuple'>: (29, 29)
0030 = {tuple} <class 'tuple'>: (30, 30)
0031 = {tuple} <class 'tuple'>: (31, 31)
0032 = {tuple} <class 'tuple'>: (32, 32)
0033 = {tuple} <class 'tuple'>: (33, 33)
0034 = {tuple} <class 'tuple'>: (34, 34)
0035 = {tuple} <class 'tuple'>: (35, 35)
0036 = {tuple} <class 'tuple'>: (36, 36)
0037 = {tuple} <class 'tuple'>: (37, 37)
0038 = {tuple} <class 'tuple'>: (38, 38)
0039 = {tuple} <class 'tuple'>: (39, 39)
0040 = {tuple} <class 'tuple'>: (40, 40)
0041 = {tuple} <class 'tuple'>: (41, 41)
0042 = {tuple} <class 'tuple'>: (42, 42)
0043 = {tuple} <class 'tuple'>: (43, 43)
0044 = {tuple} <class 'tuple'>: (44, 44)
0045 = {tuple} <class 'tuple'>: (45, 45)
0046 = {tuple} <class 'tuple'>: (46, 46)
0047 = {tuple} <class 'tuple'>: (47, 47)
0048 = {tuple} <class 'tuple'>: (48, 48)
0049 = {tuple} <class 'tuple'>: (49, 49)
0050 = {tuple} <class 'tuple'>: (50, 50)
0051 = {tuple} <class 'tuple'>: (51, 51)
0052 = {tuple} <class 'tuple'>: (52, 52)
0053 = {tuple} <class 'tuple'>: (53, 53)
0054 = {tuple} <class 'tuple'>: (54, 54)
0055 = {tuple} <class 'tuple'>: (55, 55)
0056 = {tuple} <class 'tuple'>: (56, 56)
0057 = {tuple} <class 'tuple'>: (57, 57)
0058 = {tuple} <class 'tuple'>: (58, 58)
0059 = {tuple} <class 'tuple'>: (59, 59)
0060 = {tuple} <class 'tuple'>: (60, 60)
0061 = {tuple} <class 'tuple'>: (61, 61)
0062 = {tuple} <class 'tuple'>: (62, 62)
0063 = {tuple} <class 'tuple'>: (63, 63)
0064 = {tuple} <class 'tuple'>: (64, 64)
0065 = {tuple} <class 'tuple'>: (65, 65)
0066 = {tuple} <class 'tuple'>: (66, 66)
0067 = {tuple} <class 'tuple'>: (67, 67)
0068 = {tuple} <class 'tuple'>: (68, 68)
0069 = {tuple} <class 'tuple'>: (69, 69)
0070 = {tuple} <class 'tuple'>: (70, 70)
0071 = {tuple} <class 'tuple'>: (71, 71)
0072 = {tuple} <class 'tuple'>: (72, 72)
0073 = {tuple} <class 'tuple'>: (73, 73)
0074 = {tuple} <class 'tuple'>: (74, 74)
0075 = {tuple} <class 'tuple'>: (75, 75)
0076 = {tuple} <class 'tuple'>: (76, 76)
0077 = {tuple} <class 'tuple'>: (77, 77)
0078 = {tuple} <class 'tuple'>: (78, 78)
0079 = {tuple} <class 'tuple'>: (79, 79)
0080 = {tuple} <class 'tuple'>: (80, 80)
0081 = {tuple} <class 'tuple'>: (81, 81)
0082 = {tuple} <class 'tuple'>: (82, 82)
0083 = {tuple} <class 'tuple'>: (83, 83)
0084 = {tuple} <class 'tuple'>: (84, 84)
0085 = {tuple} <class 'tuple'>: (85, 85)
0086 = {tuple} <class 'tuple'>: (86, 86)
0087 = {tuple} <class 'tuple'>: (87, 87)
0088 = {tuple} <class 'tuple'>: (88, 88)
0089 = {tuple} <class 'tuple'>: (89, 89)
0090 = {tuple} <class 'tuple'>: (90, 90)
0091 = {tuple} <class 'tuple'>: (91, 91)
0092 = {tuple} <class 'tuple'>: (92, 92)
0093 = {tuple} <class 'tuple'>: (93, 93)
0094 = {tuple} <class 'tuple'>: (94, 94)
0095 = {tuple} <class 'tuple'>: (95, 95)
0096 = {tuple} <class 'tuple'>: (96, 96)
0097 = {tuple} <class 'tuple'>: (97, 97)
0098 = {tuple} <class 'tuple'>: (98, 98)
0099 = {tuple} <class 'tuple'>: (99, 99)

However, when I remove .so from the system (or use Mac with no cython) the result is:
0000 = {tuple} <class 'tuple'>: (0, 0)
0001 = {tuple} <class 'tuple'>: (0, 1)
0002 = {tuple} <class 'tuple'>: (0, 2)
0003 = {tuple} <class 'tuple'>: (0, 3)
0004 = {tuple} <class 'tuple'>: (0, 4)
0005 = {tuple} <class 'tuple'>: (0, 5)
0006 = {tuple} <class 'tuple'>: (1, 5)
0007 = {tuple} <class 'tuple'>: (2, 6)
0008 = {tuple} <class 'tuple'>: (3, 7)
0009 = {tuple} <class 'tuple'>: (4, 8)
0010 = {tuple} <class 'tuple'>: (5, 9)
0011 = {tuple} <class 'tuple'>: (6, 10)
0012 = {tuple} <class 'tuple'>: (7, 11)
0013 = {tuple} <class 'tuple'>: (8, 12)
0014 = {tuple} <class 'tuple'>: (9, 13)
0015 = {tuple} <class 'tuple'>: (10, 14)
0016 = {tuple} <class 'tuple'>: (11, 15)
0017 = {tuple} <class 'tuple'>: (12, 16)
0018 = {tuple} <class 'tuple'>: (13, 17)
0019 = {tuple} <class 'tuple'>: (14, 18)
0020 = {tuple} <class 'tuple'>: (15, 19)
0021 = {tuple} <class 'tuple'>: (16, 20)
0022 = {tuple} <class 'tuple'>: (17, 21)
0023 = {tuple} <class 'tuple'>: (18, 22)
0024 = {tuple} <class 'tuple'>: (19, 23)
0025 = {tuple} <class 'tuple'>: (20, 24)
0026 = {tuple} <class 'tuple'>: (21, 25)
0027 = {tuple} <class 'tuple'>: (22, 26)
0028 = {tuple} <class 'tuple'>: (23, 27)
0029 = {tuple} <class 'tuple'>: (24, 28)
0030 = {tuple} <class 'tuple'>: (25, 29)
0031 = {tuple} <class 'tuple'>: (26, 30)
0032 = {tuple} <class 'tuple'>: (27, 31)
0033 = {tuple} <class 'tuple'>: (28, 32)
0034 = {tuple} <class 'tuple'>: (29, 33)
0035 = {tuple} <class 'tuple'>: (30, 34)
0036 = {tuple} <class 'tuple'>: (31, 35)
0037 = {tuple} <class 'tuple'>: (32, 36)
0038 = {tuple} <class 'tuple'>: (33, 37)
0039 = {tuple} <class 'tuple'>: (34, 38)
0040 = {tuple} <class 'tuple'>: (35, 39)
0041 = {tuple} <class 'tuple'>: (36, 40)
0042 = {tuple} <class 'tuple'>: (37, 41)
0043 = {tuple} <class 'tuple'>: (38, 42)
0044 = {tuple} <class 'tuple'>: (39, 43)
0045 = {tuple} <class 'tuple'>: (40, 44)
0046 = {tuple} <class 'tuple'>: (41, 45)
0047 = {tuple} <class 'tuple'>: (42, 46)
0048 = {tuple} <class 'tuple'>: (43, 47)
0049 = {tuple} <class 'tuple'>: (44, 48)
0050 = {tuple} <class 'tuple'>: (45, 49)
0051 = {tuple} <class 'tuple'>: (46, 50)
0052 = {tuple} <class 'tuple'>: (47, 51)
0053 = {tuple} <class 'tuple'>: (48, 52)
0054 = {tuple} <class 'tuple'>: (49, 53)
0055 = {tuple} <class 'tuple'>: (50, 54)
0056 = {tuple} <class 'tuple'>: (51, 55)
0057 = {tuple} <class 'tuple'>: (52, 56)
0058 = {tuple} <class 'tuple'>: (53, 57)
0059 = {tuple} <class 'tuple'>: (54, 58)
0060 = {tuple} <class 'tuple'>: (55, 59)
0061 = {tuple} <class 'tuple'>: (56, 60)
0062 = {tuple} <class 'tuple'>: (57, 61)
0063 = {tuple} <class 'tuple'>: (58, 62)
0064 = {tuple} <class 'tuple'>: (59, 63)
0065 = {tuple} <class 'tuple'>: (60, 64)
0066 = {tuple} <class 'tuple'>: (61, 65)
0067 = {tuple} <class 'tuple'>: (62, 66)
0068 = {tuple} <class 'tuple'>: (63, 67)
0069 = {tuple} <class 'tuple'>: (64, 68)
0070 = {tuple} <class 'tuple'>: (65, 69)
0071 = {tuple} <class 'tuple'>: (66, 70)
0072 = {tuple} <class 'tuple'>: (67, 71)
0073 = {tuple} <class 'tuple'>: (68, 72)
0074 = {tuple} <class 'tuple'>: (69, 73)
0075 = {tuple} <class 'tuple'>: (70, 74)
0076 = {tuple} <class 'tuple'>: (71, 75)
0077 = {tuple} <class 'tuple'>: (72, 76)
0078 = {tuple} <class 'tuple'>: (73, 77)
0079 = {tuple} <class 'tuple'>: (74, 78)
0080 = {tuple} <class 'tuple'>: (75, 79)
0081 = {tuple} <class 'tuple'>: (76, 80)
0082 = {tuple} <class 'tuple'>: (77, 81)
0083 = {tuple} <class 'tuple'>: (78, 82)
0084 = {tuple} <class 'tuple'>: (79, 83)
0085 = {tuple} <class 'tuple'>: (80, 84)
0086 = {tuple} <class 'tuple'>: (81, 85)
0087 = {tuple} <class 'tuple'>: (82, 86)
0088 = {tuple} <class 'tuple'>: (83, 87)
0089 = {tuple} <class 'tuple'>: (84, 88)
0090 = {tuple} <class 'tuple'>: (85, 89)
0091 = {tuple} <class 'tuple'>: (86, 90)
0092 = {tuple} <class 'tuple'>: (87, 91)
0093 = {tuple} <class 'tuple'>: (88, 92)
0094 = {tuple} <class 'tuple'>: (89, 93)
0095 = {tuple} <class 'tuple'>: (90, 94)
0096 = {tuple} <class 'tuple'>: (91, 95)
0097 = {tuple} <class 'tuple'>: (92, 96)
0098 = {tuple} <class 'tuple'>: (93, 97)
0099 = {tuple} <class 'tuple'>: (94, 98)
0100 = {tuple} <class 'tuple'>: (95, 99)
0101 = {tuple} <class 'tuple'>: (96, 100)
0102 = {tuple} <class 'tuple'>: (97, 101)
0103 = {tuple} <class 'tuple'>: (98, 102)
0104 = {tuple} <class 'tuple'>: (99, 103)

The same applies to input series that has constant values over some time windows.

cython extensions

This is a great library. Thank you for open sourcing it. It would be nice if it ran a bit faster perhaps with cython extensions. Is there any interest in that?

Incorrect DTW path for Euclidean distance?

I'm struggling understanding a very simple example. I boiled it down to the following test:

from fastdtw import fastdtw
from scipy.spatial.distance import euclidean, sqeuclidean
def test_euclidean_distance():
    q=[0,1,2,3,4,5,6,7,8]
    r=[1,2,3,4,5,6,7,8,0]
    distA, pathA = fastdtw(q, r, radius=2, dist=euclidean)
    distB, pathB = fastdtw(q, r, radius=2, dist=sqeuclidean)
    assert all([a==b for a,b in zip(pathA, pathB)])
    assert distA*distA == distB   # 9*9 == 65 fails

Since the paths are the same I would expect to that also the distances are the same. The correct Euclidean distance should be sqrt(65) (only first and last elements of the input vectors contribute). Since it is 9 it looks like the Manhattan distance is used instead of the Euclidean distance.

I have the feeling that I miss something simple. But could someone give me a hint?

Accessing fastdtw from C language

Hi,
I see that the main library is implemented in C. Can you please point out steps to load and call the fastdtw function from C language instead of python?

"python setup.py egg_info" failed with error code 1 in /tmp/pip-install-lyc8tzkz/fastdtw/

Hi All,

I have a RHEL 7 server and I have installed python 3.6 in virtual environment and I am trying to install fastdtw package in it but getting below error. I am not able to understand it, could you please help me resolve this issue.


(py36-venv) [user@server py36-venv]$ pip install fastdtw --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org
Collecting fastdtw
Downloading https://files.pythonhosted.org/packages/fa/ef/a4cf2d72518b5fccd302 100% |ââââââââââââââââââââââââââââââââ| 122kB 2.7MB/s
Complete output from command python setup.py egg_info:
Download error on https://pypi.org/simple/pytest-runner/: [SSL: CERTIFICATE_ERIFY_FAILED] certificate verify failed (_ssl.c:777) -- Some packages may not be found!
Couldn't find index page for 'pytest-runner' (maybe misspelled?)
Download error on https://pypi.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777) -- Some packages may not be found!
No local packages or working download links found for pytest-runner
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-lyc8tzkz/fastdtw/setup.py", line 77, in
setup(**kwargs)
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/setuptools/init.py", line 144, in setup
_install_setup_requires(attrs)
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/setuptools/init.py", line 139, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/setuptools/dist.py", line 724, in fetch_build_eggs
replace_conflicting=True,
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pkg_resources/init.py", line 782, in resolve
replace_conflicting=replace_conflicting
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pkg_resources/init.py", line 1065, in best_match
return self.obtain(req, installer)
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pkg_resources/init.py", line 1077, in obtain
return installer(requirement)
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/setuptools/dist.py", line 791, in fetch_build_egg
return cmd.easy_install(req)
File "/root/pydev/py36-venv/lib64/python3.6/site-packages/setuptools/command/easy_install.py", line 673, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pytest-runner')

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-lyc8tzkz/fastdtw/

Inconsistent results between different python environment.

Hello, I got inconsistent results from the same data when I changed the python environment.

test code:

import numpy as np
from fastdtw import fastdtw

x = [1, 6, 6, 33, 35]
y = [1, 6, 6, 33, 35]

d, path = fastdtw(x, y, radius=len(x))

print(f"d: {d}")
print(f"path: {path}")

environment a: WinPython 3.8.5 on Windows 10 Pro 64bit

$ python --version
Python 3.8.5

$ pip list | grep fastdtw
fastdtw                0.3.4

$ python test_fastdtw.py
d: 0.0
path: [(0, 0), (1, 1), (1, 2), (2, 2), (3, 3), (4, 4)]

environment b: Debian GNU/Linux(buster) (WSL)

$ python -V
Python 3.7.3

$ pip list | grep fastdtw
fastdtw                0.3.4

$ python test_fastdtw.py
d: 0.0
path: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]

The result of latter is what I need. Could anyone please advise me to avoid this inconsistency?

one question

when i run the following code,it appears the error,please help me:
from fastdtw import fastdtw
ImportError: cannot import name 'fastdtw'

Question about __expand_window()

Hi!

Thank you for developing and sharing this library. I have been using it quite successfully.

In function __expand_window(), is there a reason for thickening the path with radius before doubling the search window axes rather than the other way around?
This way the search window becomes 4 * radius instead of 2 * radius.

Thanks in advance,
Vasco.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.