From 92133c1f327852f317efa10a931125c1180cb7b8 Mon Sep 17 00:00:00 2001 From: Kazuaki Tanida Date: Sat, 12 Nov 2016 18:35:16 +0900 Subject: [PATCH] Try to cythonize when Cython is installed --- fastdtw/_fastdtw.cpp | 2365 ++++++++++++++++++++++++++---------------- fastdtw/_fastdtw.pyx | 11 +- setup.py | 29 +- 3 files changed, 1532 insertions(+), 873 deletions(-) diff --git a/fastdtw/_fastdtw.cpp b/fastdtw/_fastdtw.cpp index 15b15ab..99c0f29 100644 --- a/fastdtw/_fastdtw.cpp +++ b/fastdtw/_fastdtw.cpp @@ -1,4 +1,4 @@ -/* Generated by Cython 0.24.1 */ +/* Generated by Cython 0.25.1 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -7,7 +7,7 @@ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else -#define CYTHON_ABI "0_24_1" +#define CYTHON_ABI "0_25_1" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -29,6 +29,11 @@ #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #define HAVE_LONG_LONG + #endif +#endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif @@ -37,13 +42,110 @@ #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 #else #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif #endif -#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 - #define CYTHON_USE_PYLONG_INTERNALS 1 +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" @@ -79,24 +181,44 @@ #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif +#ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #else #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY @@ -121,6 +243,13 @@ #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 @@ -149,6 +278,7 @@ #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type @@ -187,18 +317,20 @@ #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif -#if PY_VERSION_HEX >= 0x030500B1 -#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods -#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) -#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; -} __Pyx_PyAsyncMethodsStruct; -#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif #else -#define __Pyx_PyType_AsAsync(obj) NULL + #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -230,6 +362,8 @@ class __Pyx_FakeReference { __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } T *operator->() { return ptr; } operator T&() { return *ptr; } + template bool operator ==(U other) { return *ptr == other; }; + template bool operator !=(U other) { return *ptr != other; }; private: T *ptr; }; @@ -277,16 +411,17 @@ static CYTHON_INLINE float __PYX_NAN() { #define __PYX_HAVE__fastdtw___fastdtw #define __PYX_HAVE_API__fastdtw___fastdtw -#include "math.h" +#include #include #include "ios" #include "new" #include "stdexcept" #include "typeinfo" +#include "numpy/npy_math.h" #include "pythread.h" -#include "string.h" -#include "stdlib.h" -#include "stdio.h" +#include +#include +#include #include "pystate.h" #ifdef _OPENMP #include @@ -393,7 +528,7 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) @@ -504,7 +639,7 @@ static const char *__pyx_filename; static const char *__pyx_f[] = { "fastdtw/_fastdtw.pyx", - "stringsource", + "fastdtw/stringsource", }; /* MemviewSliceStruct.proto */ struct __pyx_memoryview_obj; @@ -614,7 +749,7 @@ struct __pyx_t_7fastdtw_8_fastdtw_WindowElement; struct __pyx_t_7fastdtw_8_fastdtw_CostElement; struct __pyx_t_7fastdtw_8_fastdtw_PathElement; -/* "fastdtw/_fastdtw.pyx":13 +/* "fastdtw/_fastdtw.pyx":20 * * * cdef struct LowHigh: # <<<<<<<<<<<<<< @@ -626,7 +761,7 @@ struct __pyx_t_7fastdtw_8_fastdtw_LowHigh { int high; }; -/* "fastdtw/_fastdtw.pyx":16 +/* "fastdtw/_fastdtw.pyx":23 * int low, high * * cdef struct WindowElement: # <<<<<<<<<<<<<< @@ -641,7 +776,7 @@ struct __pyx_t_7fastdtw_8_fastdtw_WindowElement { int cost_idx_corner; }; -/* "fastdtw/_fastdtw.pyx":19 +/* "fastdtw/_fastdtw.pyx":26 * int x_idx, y_idx, cost_idx_left, cost_idx_up, cost_idx_corner * * cdef struct CostElement: # <<<<<<<<<<<<<< @@ -653,7 +788,7 @@ struct __pyx_t_7fastdtw_8_fastdtw_CostElement { int prev_idx; }; -/* "fastdtw/_fastdtw.pyx":23 +/* "fastdtw/_fastdtw.pyx":30 * int prev_idx * * cdef struct PathElement: # <<<<<<<<<<<<<< @@ -665,7 +800,7 @@ struct __pyx_t_7fastdtw_8_fastdtw_PathElement { int y_idx; }; -/* "fastdtw/_fastdtw.pyx":210 +/* "fastdtw/_fastdtw.pyx":217 * * * def __norm(p): # <<<<<<<<<<<<<< @@ -881,7 +1016,7 @@ static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice; #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) @@ -914,6 +1049,24 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); @@ -934,7 +1087,7 @@ static CYTHON_INLINE int __Pyx_IterFinish(void); static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* ListCompAppend.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); @@ -1033,7 +1186,7 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, static int __pyx_CyFunction_init(void); /* PyThreadStateGet.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); #else @@ -1042,7 +1195,7 @@ static int __pyx_CyFunction_init(void); #endif /* PyErrFetchRestore.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) @@ -1060,7 +1213,7 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* PyIntBinop.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace); #else #define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\ @@ -1114,7 +1267,7 @@ static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int); static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); /* PyIntBinop.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long intval, int inplace); #else #define __Pyx_PyInt_RemainderObjC(op1, op2, intval, inplace)\ @@ -1122,7 +1275,7 @@ static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long in #endif /* PyIntBinop.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace); #else #define __Pyx_PyInt_TrueDivideObjC(op1, op2, intval, inplace)\ @@ -1130,7 +1283,7 @@ static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long i #endif /* SaveResetException.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) @@ -1141,7 +1294,7 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* PyErrExceptionMatches.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else @@ -1149,7 +1302,7 @@ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tsta #endif /* GetException.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else @@ -1198,7 +1351,7 @@ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /* SwapException.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else @@ -1210,7 +1363,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ /* PyIntBinop.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ @@ -1231,7 +1384,7 @@ static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { } /* ListAppend.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); @@ -1340,6 +1493,8 @@ static void __Pyx_CppExn2PyErr() { PyErr_SetString(PyExc_MemoryError, exn.what()); } catch (const std::bad_cast& exn) { PyErr_SetString(PyExc_TypeError, exn.what()); + } catch (const std::bad_typeid& exn) { + PyErr_SetString(PyExc_TypeError, exn.what()); } catch (const std::domain_error& exn) { PyErr_SetString(PyExc_ValueError, exn.what()); } catch (const std::invalid_argument& exn) { @@ -1423,6 +1578,8 @@ static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memo /* Module declarations from 'libcpp.vector' */ +/* Module declarations from 'numpy.math' */ + /* Module declarations from 'fastdtw._fastdtw' */ static PyTypeObject *__pyx_ptype_7fastdtw_8_fastdtw___pyx_scope_struct____norm = 0; static PyTypeObject *__pyx_ptype___pyx_scope_struct____Pyx_CFunc_double____double____double___to_py = 0; @@ -1562,13 +1719,13 @@ static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_cfunc_to_py[] = "cfunc.to_py"; static const char __pyx_k_prep_inputs[] = "__prep_inputs"; -static const char __pyx_k_dtw_line_114[] = "dtw (line 114)"; +static const char __pyx_k_dtw_line_121[] = "dtw (line 121)"; static const char __pyx_k_stringsource[] = "stringsource"; static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; static const char __pyx_k_AttributeError[] = "AttributeError"; static const char __pyx_k_allocate_buffer[] = "allocate_buffer"; static const char __pyx_k_dtype_is_object[] = "dtype_is_object"; -static const char __pyx_k_fastdtw_line_27[] = "fastdtw (line 27)"; +static const char __pyx_k_fastdtw_line_34[] = "fastdtw (line 34)"; static const char __pyx_k_fastdtw__fastdtw[] = "fastdtw._fastdtw"; static const char __pyx_k_norm_locals_lambda[] = "__norm.."; static const char __pyx_k_strided_and_direct[] = ""; @@ -1583,7 +1740,7 @@ static const char __pyx_k_Pyx_CFunc_double____double[] = "__Pyx_CFunc_double____ static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array"; static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; static const char __pyx_k_strided_and_direct_or_indirect[] = ""; -static const char __pyx_k_home_esquires_repos_temp_fastdt[] = "/home/esquires/repos/temp/fastdtw/fastdtw/_fastdtw.pyx"; +static const char __pyx_k_Users_kazuaki_tanida_dev_myproj[] = "/Users/kazuaki-tanida/dev/myproj/fastdtw/fastdtw/_fastdtw.pyx"; static const char __pyx_k_return_the_approximate_distance[] = " return the approximate distance between 2 time series with O(N)\n time and memory complexity\n\n Parameters\n ----------\n x : array_like\n input array 1\n y : array_like\n input array 2\n radius : int\n size of neighborhood when expanding the path. A higher value will\n increase the accuracy of the calculation but also increase time\n and memory consumption. A radius equal to the size of x and y will\n yield an exact dynamic time warping calculation.\n dist : function or int\n The method for calculating the distance between x[i] and y[j]. If\n dist is an int of value p > 0, then the p-norm will be used. If\n dist is a function then dist(x[i], y[j]) will be used. If dist is\n None then abs(x[i] - y[j]) will be used.\n\n Returns\n -------\n distance : float\n the approximate distance between the 2 time series\n path : list\n list of indexes for the inputs x and y\n\n Examples\n --------\n >>> import numpy as np\n >>> import fastdtw\n >>> x = np.array([1, 2, 3, 4, 5], dtype='float')\n >>> y = np.array([2, 3, 4], dtype='float')\n >>> fastdtw.fastdtw(x, y)\n (2.0, [(0, 0), (1, 0), (2, 1), (3, 2), (4, 2)])\n\n Optimization Considerations\n ---------------------------\n This function runs fastest if the following conditions are satisfied:\n 1) x and y are either 1 or 2d numpy arrays whose dtype is a\n subtype of np.float\n 2) The dist input is a positive integer or None\n "; static const char __pyx_k_return_the_distance_between_2_t[] = " return the distance between 2 time series without approximation\n\n Parameters\n ----------\n x : array_like\n input array 1\n y : array_like\n input array 2\n dist : function or int\n The method for calculating the distance between x[i] and y[j]. If\n dist is an int of value p > 0, then the p-norm will be used. If\n dist is a function then dist(x[i], y[j]) will be used. If dist is\n None then abs(x[i] - y[j]) will be used.\n\n Returns\n -------\n distance : float\n the approximate distance between the 2 time series\n path : list\n list of indexes for the inputs x and y\n\n Examples\n --------\n >>> import numpy as np\n >>> import fastdtw\n >>> x = np.array([1, 2, 3, 4, 5], dtype='float')\n >>> y = np.array([2, 3, 4], dtype='float')\n >>> fastdtw.dtw(x, y)\n (2.0, [(0, 0), (1, 0), (2, 1), (3, 2), (4, 2)])\n\n Optimization Considerations\n ---------------------------\n This function runs fastest if the following conditions are satisfied:\n 1) x and y are either 1 or 2d numpy arrays whose dtype is a\n subtype of np.float\n 2) The dist input is a positive integer or None\n "; static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides"; @@ -1617,6 +1774,7 @@ static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a; static PyObject *__pyx_n_s_Pyx_CFunc_double____double; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; +static PyObject *__pyx_kp_s_Users_kazuaki_tanida_dev_myproj; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_a; static PyObject *__pyx_n_s_allocate_buffer; @@ -1633,7 +1791,7 @@ static PyObject *__pyx_n_s_cost; static PyObject *__pyx_n_s_dist; static PyObject *__pyx_kp_s_dist_cannot_be_a_negative_intege; static PyObject *__pyx_n_s_dtw; -static PyObject *__pyx_kp_u_dtw_line_114; +static PyObject *__pyx_kp_u_dtw_line_121; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dtype_is_object; static PyObject *__pyx_n_s_encode; @@ -1641,14 +1799,13 @@ static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_error; static PyObject *__pyx_n_s_fastdtw; static PyObject *__pyx_n_s_fastdtw__fastdtw; -static PyObject *__pyx_kp_u_fastdtw_line_27; +static PyObject *__pyx_kp_u_fastdtw_line_34; static PyObject *__pyx_n_s_flags; static PyObject *__pyx_n_s_float; static PyObject *__pyx_n_s_format; static PyObject *__pyx_n_s_fortran; static PyObject *__pyx_n_u_fortran; static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi; -static PyObject *__pyx_kp_s_home_esquires_repos_temp_fastdt; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_idx; @@ -1786,7 +1943,7 @@ static PyObject *__pyx_codeobj__21; static PyObject *__pyx_codeobj__23; static PyObject *__pyx_codeobj__25; -/* "fastdtw/_fastdtw.pyx":27 +/* "fastdtw/_fastdtw.pyx":34 * * * def fastdtw(x, y, int radius=1, dist=None): # <<<<<<<<<<<<<< @@ -1829,7 +1986,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_1fastdtw(PyObject *__pyx_self, PyOb case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fastdtw", 0, 2, 4, 1); __PYX_ERR(0, 27, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fastdtw", 0, 2, 4, 1); __PYX_ERR(0, 34, __pyx_L3_error) } case 2: if (kw_args > 0) { @@ -1843,7 +2000,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_1fastdtw(PyObject *__pyx_self, PyOb } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fastdtw") < 0)) __PYX_ERR(0, 27, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fastdtw") < 0)) __PYX_ERR(0, 34, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -1858,7 +2015,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_1fastdtw(PyObject *__pyx_self, PyOb __pyx_v_x = values[0]; __pyx_v_y = values[1]; if (values[2]) { - __pyx_v_radius = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_radius == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L3_error) + __pyx_v_radius = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_radius == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 34, __pyx_L3_error) } else { __pyx_v_radius = ((int)1); } @@ -1866,7 +2023,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_1fastdtw(PyObject *__pyx_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fastdtw", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 27, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fastdtw", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 34, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("fastdtw._fastdtw.fastdtw", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -1890,30 +2047,30 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - Py_ssize_t __pyx_t_4; + int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); Py_ssize_t __pyx_t_7; - double __pyx_t_8; - int __pyx_t_9; + Py_ssize_t __pyx_t_8; + double __pyx_t_9; int __pyx_t_10; int __pyx_t_11; __Pyx_RefNannySetupContext("fastdtw", 0); __Pyx_INCREF(__pyx_v_x); __Pyx_INCREF(__pyx_v_y); - /* "fastdtw/_fastdtw.pyx":71 + /* "fastdtw/_fastdtw.pyx":78 * 2) The dist input is a positive integer or None * ''' * x, y = __prep_inputs(x, y, dist) # <<<<<<<<<<<<<< * * # passing by reference to recursive functions apparently doesn't work */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_prep_inputs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_prep_inputs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); @@ -1923,27 +2080,45 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p __pyx_t_4 = 1; } } - __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_x, __pyx_v_y, __pyx_v_dist}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_x, __pyx_v_y, __pyx_v_dist}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_INCREF(__pyx_v_x); + __Pyx_GIVEREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_x); + __Pyx_INCREF(__pyx_v_y); + __Pyx_GIVEREF(__pyx_v_y); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_y); + __Pyx_INCREF(__pyx_v_dist); + __Pyx_GIVEREF(__pyx_v_dist); + PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_dist); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } - __Pyx_INCREF(__pyx_v_x); - __Pyx_GIVEREF(__pyx_v_x); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_x); - __Pyx_INCREF(__pyx_v_y); - __Pyx_GIVEREF(__pyx_v_y); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_y); - __Pyx_INCREF(__pyx_v_dist); - __Pyx_GIVEREF(__pyx_v_dist); - PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_dist); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -1951,9 +2126,9 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 71, __pyx_L1_error) + __PYX_ERR(0, 78, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); @@ -1964,15 +2139,15 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; - __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; @@ -1980,7 +2155,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) __PYX_ERR(0, 71, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) __PYX_ERR(0, 78, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L4_unpacking_done; @@ -1988,7 +2163,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 71, __pyx_L1_error) + __PYX_ERR(0, 78, __pyx_L1_error) __pyx_L4_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_2); @@ -1996,26 +2171,26 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_5); __pyx_t_5 = 0; - /* "fastdtw/_fastdtw.pyx":76 + /* "fastdtw/_fastdtw.pyx":83 * # so we are passing pointers * cdef PathElement *path = ( * PyMem_Malloc((len(x) + len(y) - 1) * # <<<<<<<<<<<<<< * sizeof(PathElement))) * cdef int path_len = 0, i */ - __pyx_t_4 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 76, __pyx_L1_error) - __pyx_t_7 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_7 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 83, __pyx_L1_error) - /* "fastdtw/_fastdtw.pyx":77 + /* "fastdtw/_fastdtw.pyx":84 * cdef PathElement *path = ( * PyMem_Malloc((len(x) + len(y) - 1) * * sizeof(PathElement))) # <<<<<<<<<<<<<< * cdef int path_len = 0, i * cost = __fastdtw(x, y, radius, dist, path, path_len) */ - __pyx_v_path = ((struct __pyx_t_7fastdtw_8_fastdtw_PathElement *)PyMem_Malloc((((__pyx_t_4 + __pyx_t_7) - 1) * (sizeof(struct __pyx_t_7fastdtw_8_fastdtw_PathElement))))); + __pyx_v_path = ((struct __pyx_t_7fastdtw_8_fastdtw_PathElement *)PyMem_Malloc((((__pyx_t_7 + __pyx_t_8) - 1) * (sizeof(struct __pyx_t_7fastdtw_8_fastdtw_PathElement))))); - /* "fastdtw/_fastdtw.pyx":78 + /* "fastdtw/_fastdtw.pyx":85 * PyMem_Malloc((len(x) + len(y) - 1) * * sizeof(PathElement))) * cdef int path_len = 0, i # <<<<<<<<<<<<<< @@ -2024,55 +2199,55 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p */ __pyx_v_path_len = 0; - /* "fastdtw/_fastdtw.pyx":79 + /* "fastdtw/_fastdtw.pyx":86 * sizeof(PathElement))) * cdef int path_len = 0, i * cost = __fastdtw(x, y, radius, dist, path, path_len) # <<<<<<<<<<<<<< * * path_lst = [] */ - __pyx_t_8 = __pyx_f_7fastdtw_8_fastdtw___fastdtw(__pyx_v_x, __pyx_v_y, __pyx_v_radius, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_8 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L1_error) - __pyx_v_cost = __pyx_t_8; + __pyx_t_9 = __pyx_f_7fastdtw_8_fastdtw___fastdtw(__pyx_v_x, __pyx_v_y, __pyx_v_radius, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_9 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L1_error) + __pyx_v_cost = __pyx_t_9; - /* "fastdtw/_fastdtw.pyx":81 + /* "fastdtw/_fastdtw.pyx":88 * cost = __fastdtw(x, y, radius, dist, path, path_len) * * path_lst = [] # <<<<<<<<<<<<<< * if path != NULL: * path_lst = [(path[i].x_idx, path[i].y_idx) for i in range(path_len)] */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_path_lst = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":82 + /* "fastdtw/_fastdtw.pyx":89 * * path_lst = [] * if path != NULL: # <<<<<<<<<<<<<< * path_lst = [(path[i].x_idx, path[i].y_idx) for i in range(path_len)] * PyMem_Free(path) */ - __pyx_t_9 = ((__pyx_v_path != NULL) != 0); - if (__pyx_t_9) { + __pyx_t_10 = ((__pyx_v_path != NULL) != 0); + if (__pyx_t_10) { - /* "fastdtw/_fastdtw.pyx":83 + /* "fastdtw/_fastdtw.pyx":90 * path_lst = [] * if path != NULL: * path_lst = [(path[i].x_idx, path[i].y_idx) for i in range(path_len)] # <<<<<<<<<<<<<< * PyMem_Free(path) * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __pyx_v_path_len; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_t_4 = __pyx_v_path_len; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_4; __pyx_t_11+=1) { __pyx_v_i = __pyx_t_11; - __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).x_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).x_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).y_idx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).y_idx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); @@ -2080,13 +2255,13 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_5 = 0; __pyx_t_2 = 0; - if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 83, __pyx_L1_error) + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_path_lst, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":84 + /* "fastdtw/_fastdtw.pyx":91 * if path != NULL: * path_lst = [(path[i].x_idx, path[i].y_idx) for i in range(path_len)] * PyMem_Free(path) # <<<<<<<<<<<<<< @@ -2095,7 +2270,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p */ PyMem_Free(__pyx_v_path); - /* "fastdtw/_fastdtw.pyx":82 + /* "fastdtw/_fastdtw.pyx":89 * * path_lst = [] * if path != NULL: # <<<<<<<<<<<<<< @@ -2104,7 +2279,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p */ } - /* "fastdtw/_fastdtw.pyx":86 + /* "fastdtw/_fastdtw.pyx":93 * PyMem_Free(path) * * return cost, path_lst # <<<<<<<<<<<<<< @@ -2112,9 +2287,9 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_cost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_cost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -2126,7 +2301,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p __pyx_t_3 = 0; goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":27 + /* "fastdtw/_fastdtw.pyx":34 * * * def fastdtw(x, y, int radius=1, dist=None): # <<<<<<<<<<<<<< @@ -2151,7 +2326,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_fastdtw(CYTHON_UNUSED PyObject *__p return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":89 +/* "fastdtw/_fastdtw.pyx":96 * * * cdef double __fastdtw(x, y, int radius, dist, # <<<<<<<<<<<<<< @@ -2184,7 +2359,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject int __pyx_t_12; __Pyx_RefNannySetupContext("__fastdtw", 0); - /* "fastdtw/_fastdtw.pyx":94 + /* "fastdtw/_fastdtw.pyx":101 * cdef double cost * * min_time_size = radius + 2 # <<<<<<<<<<<<<< @@ -2193,36 +2368,36 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject */ __pyx_v_min_time_size = (__pyx_v_radius + 2); - /* "fastdtw/_fastdtw.pyx":96 + /* "fastdtw/_fastdtw.pyx":103 * min_time_size = radius + 2 * * if len(x) < min_time_size or len(y) < min_time_size: # <<<<<<<<<<<<<< * cost, path_lst = dtw(x, y, dist=dist) * (&path_len)[0] = len(path_lst) */ - __pyx_t_2 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 96, __pyx_L1_error) + __pyx_t_2 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 103, __pyx_L1_error) __pyx_t_3 = ((__pyx_t_2 < __pyx_v_min_time_size) != 0); if (!__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } - __pyx_t_2 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 96, __pyx_L1_error) + __pyx_t_2 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 103, __pyx_L1_error) __pyx_t_3 = ((__pyx_t_2 < __pyx_v_min_time_size) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "fastdtw/_fastdtw.pyx":97 + /* "fastdtw/_fastdtw.pyx":104 * * if len(x) < min_time_size or len(y) < min_time_size: * cost, path_lst = dtw(x, y, dist=dist) # <<<<<<<<<<<<<< * (&path_len)[0] = len(path_lst) * for i in range((&path_len)[0]): */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtw); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtw); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); @@ -2230,17 +2405,17 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_y); - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dist, __pyx_v_dist) < 0) __PYX_ERR(0, 97, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 97, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dist, __pyx_v_dist) < 0) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) { PyObject* sequence = __pyx_t_7; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -2248,9 +2423,9 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 97, __pyx_L1_error) + __PYX_ERR(0, 104, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); @@ -2261,15 +2436,15 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); #else - __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { Py_ssize_t index = -1; - __pyx_t_4 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_4 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; @@ -2277,7 +2452,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_5 = __pyx_t_8(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_4), 2) < 0) __PYX_ERR(0, 97, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_4), 2) < 0) __PYX_ERR(0, 104, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L7_unpacking_done; @@ -2285,26 +2460,26 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 97, __pyx_L1_error) + __PYX_ERR(0, 104, __pyx_L1_error) __pyx_L7_unpacking_done:; } - __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_cost = __pyx_t_9; __pyx_v_path_lst = __pyx_t_5; __pyx_t_5 = 0; - /* "fastdtw/_fastdtw.pyx":98 + /* "fastdtw/_fastdtw.pyx":105 * if len(x) < min_time_size or len(y) < min_time_size: * cost, path_lst = dtw(x, y, dist=dist) * (&path_len)[0] = len(path_lst) # <<<<<<<<<<<<<< * for i in range((&path_len)[0]): * path[i].x_idx = path_lst[i][0] */ - __pyx_t_2 = PyObject_Length(__pyx_v_path_lst); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 98, __pyx_L1_error) + __pyx_t_2 = PyObject_Length(__pyx_v_path_lst); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 105, __pyx_L1_error) ((&__pyx_v_path_len)[0]) = __pyx_t_2; - /* "fastdtw/_fastdtw.pyx":99 + /* "fastdtw/_fastdtw.pyx":106 * cost, path_lst = dtw(x, y, dist=dist) * (&path_len)[0] = len(path_lst) * for i in range((&path_len)[0]): # <<<<<<<<<<<<<< @@ -2315,40 +2490,40 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_i = __pyx_t_11; - /* "fastdtw/_fastdtw.pyx":100 + /* "fastdtw/_fastdtw.pyx":107 * (&path_len)[0] = len(path_lst) * for i in range((&path_len)[0]): * path[i].x_idx = path_lst[i][0] # <<<<<<<<<<<<<< * path[i].y_idx = path_lst[i][1] * */ - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_path_lst, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_path_lst, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; (__pyx_v_path[__pyx_v_i]).x_idx = __pyx_t_12; - /* "fastdtw/_fastdtw.pyx":101 + /* "fastdtw/_fastdtw.pyx":108 * for i in range((&path_len)[0]): * path[i].x_idx = path_lst[i][0] * path[i].y_idx = path_lst[i][1] # <<<<<<<<<<<<<< * * return cost */ - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_path_lst, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 101, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_path_lst, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 101, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; (__pyx_v_path[__pyx_v_i]).y_idx = __pyx_t_12; } - /* "fastdtw/_fastdtw.pyx":103 + /* "fastdtw/_fastdtw.pyx":110 * path[i].y_idx = path_lst[i][1] * * return cost # <<<<<<<<<<<<<< @@ -2358,7 +2533,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject __pyx_r = __pyx_v_cost; goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":96 + /* "fastdtw/_fastdtw.pyx":103 * min_time_size = radius + 2 * * if len(x) < min_time_size or len(y) < min_time_size: # <<<<<<<<<<<<<< @@ -2367,63 +2542,63 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject */ } - /* "fastdtw/_fastdtw.pyx":105 + /* "fastdtw/_fastdtw.pyx":112 * return cost * * x_shrinked = __reduce_by_half(x) # <<<<<<<<<<<<<< * y_shrinked = __reduce_by_half(y) * distance = __fastdtw(x_shrinked, y_shrinked, radius, dist, path, path_len) */ - __pyx_t_7 = __pyx_f_7fastdtw_8_fastdtw___reduce_by_half(__pyx_v_x); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_7 = __pyx_f_7fastdtw_8_fastdtw___reduce_by_half(__pyx_v_x); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_x_shrinked = __pyx_t_7; __pyx_t_7 = 0; - /* "fastdtw/_fastdtw.pyx":106 + /* "fastdtw/_fastdtw.pyx":113 * * x_shrinked = __reduce_by_half(x) * y_shrinked = __reduce_by_half(y) # <<<<<<<<<<<<<< * distance = __fastdtw(x_shrinked, y_shrinked, radius, dist, path, path_len) * */ - __pyx_t_7 = __pyx_f_7fastdtw_8_fastdtw___reduce_by_half(__pyx_v_y); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_7 = __pyx_f_7fastdtw_8_fastdtw___reduce_by_half(__pyx_v_y); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_y_shrinked = __pyx_t_7; __pyx_t_7 = 0; - /* "fastdtw/_fastdtw.pyx":107 + /* "fastdtw/_fastdtw.pyx":114 * x_shrinked = __reduce_by_half(x) * y_shrinked = __reduce_by_half(y) * distance = __fastdtw(x_shrinked, y_shrinked, radius, dist, path, path_len) # <<<<<<<<<<<<<< * * cdef vector[WindowElement] window */ - __pyx_t_9 = __pyx_f_7fastdtw_8_fastdtw___fastdtw(__pyx_v_x_shrinked, __pyx_v_y_shrinked, __pyx_v_radius, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_9 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_9 = __pyx_f_7fastdtw_8_fastdtw___fastdtw(__pyx_v_x_shrinked, __pyx_v_y_shrinked, __pyx_v_radius, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_9 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) __pyx_v_distance = __pyx_t_9; - /* "fastdtw/_fastdtw.pyx":110 + /* "fastdtw/_fastdtw.pyx":117 * * cdef vector[WindowElement] window * __expand_window(path, path_len, x, y, radius, dist, window) # <<<<<<<<<<<<<< * return __dtw(x, y, window, dist, path, path_len) * */ - __pyx_t_7 = __pyx_f_7fastdtw_8_fastdtw___expand_window(__pyx_v_path, __pyx_v_path_len, __pyx_v_x, __pyx_v_y, __pyx_v_radius, __pyx_v_dist, __pyx_v_window); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_7 = __pyx_f_7fastdtw_8_fastdtw___expand_window(__pyx_v_path, __pyx_v_path_len, __pyx_v_x, __pyx_v_y, __pyx_v_radius, __pyx_v_dist, __pyx_v_window); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "fastdtw/_fastdtw.pyx":111 + /* "fastdtw/_fastdtw.pyx":118 * cdef vector[WindowElement] window * __expand_window(path, path_len, x, y, radius, dist, window) * return __dtw(x, y, window, dist, path, path_len) # <<<<<<<<<<<<<< * * */ - __pyx_t_9 = __pyx_f_7fastdtw_8_fastdtw___dtw(__pyx_v_x, __pyx_v_y, __pyx_v_window, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_9 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 111, __pyx_L1_error) + __pyx_t_9 = __pyx_f_7fastdtw_8_fastdtw___dtw(__pyx_v_x, __pyx_v_y, __pyx_v_window, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_9 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L1_error) __pyx_r = __pyx_t_9; goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":89 + /* "fastdtw/_fastdtw.pyx":96 * * * cdef double __fastdtw(x, y, int radius, dist, # <<<<<<<<<<<<<< @@ -2447,7 +2622,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___fastdtw(PyObject *__pyx_v_x, PyObject return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":114 +/* "fastdtw/_fastdtw.pyx":121 * * * def dtw(x, y, dist=None): # <<<<<<<<<<<<<< @@ -2488,7 +2663,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_3dtw(PyObject *__pyx_self, PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("dtw", 0, 2, 3, 1); __PYX_ERR(0, 114, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("dtw", 0, 2, 3, 1); __PYX_ERR(0, 121, __pyx_L3_error) } case 2: if (kw_args > 0) { @@ -2497,7 +2672,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_3dtw(PyObject *__pyx_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dtw") < 0)) __PYX_ERR(0, 114, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dtw") < 0)) __PYX_ERR(0, 121, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -2514,7 +2689,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_3dtw(PyObject *__pyx_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("dtw", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 114, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("dtw", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 121, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("fastdtw._fastdtw.dtw", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2545,11 +2720,11 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - Py_ssize_t __pyx_t_4; + int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); Py_ssize_t __pyx_t_7; - int __pyx_t_8; + Py_ssize_t __pyx_t_8; int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; @@ -2562,18 +2737,18 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __Pyx_INCREF(__pyx_v_x); __Pyx_INCREF(__pyx_v_y); - /* "fastdtw/_fastdtw.pyx":155 + /* "fastdtw/_fastdtw.pyx":162 * cdef int len_x, len_y, x_idx, y_idx, idx * cdef double cost * x, y = __prep_inputs(x, y, dist) # <<<<<<<<<<<<<< * len_x, len_y = len(x), len(y) * idx = 0 */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_prep_inputs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_prep_inputs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); @@ -2583,27 +2758,45 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_4 = 1; } } - __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 155, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_x, __pyx_v_y, __pyx_v_dist}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_x, __pyx_v_y, __pyx_v_dist}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 3+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_INCREF(__pyx_v_x); + __Pyx_GIVEREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_x); + __Pyx_INCREF(__pyx_v_y); + __Pyx_GIVEREF(__pyx_v_y); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_y); + __Pyx_INCREF(__pyx_v_dist); + __Pyx_GIVEREF(__pyx_v_dist); + PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_dist); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } - __Pyx_INCREF(__pyx_v_x); - __Pyx_GIVEREF(__pyx_v_x); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_x); - __Pyx_INCREF(__pyx_v_y); - __Pyx_GIVEREF(__pyx_v_y); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_y); - __Pyx_INCREF(__pyx_v_dist); - __Pyx_GIVEREF(__pyx_v_dist); - PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_dist); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -2611,9 +2804,9 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 155, __pyx_L1_error) + __PYX_ERR(0, 162, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); @@ -2624,15 +2817,15 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 155, __pyx_L1_error) + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; - __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error) + __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; @@ -2640,7 +2833,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) __PYX_ERR(0, 155, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) __PYX_ERR(0, 162, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L4_unpacking_done; @@ -2648,7 +2841,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 155, __pyx_L1_error) + __PYX_ERR(0, 162, __pyx_L1_error) __pyx_L4_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_2); @@ -2656,19 +2849,19 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_5); __pyx_t_5 = 0; - /* "fastdtw/_fastdtw.pyx":156 + /* "fastdtw/_fastdtw.pyx":163 * cdef double cost * x, y = __prep_inputs(x, y, dist) * len_x, len_y = len(x), len(y) # <<<<<<<<<<<<<< * idx = 0 * cdef WindowElement we */ - __pyx_t_4 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) - __pyx_t_7 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) - __pyx_v_len_x = __pyx_t_4; - __pyx_v_len_y = __pyx_t_7; + __pyx_t_7 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_v_len_x = __pyx_t_7; + __pyx_v_len_y = __pyx_t_8; - /* "fastdtw/_fastdtw.pyx":157 + /* "fastdtw/_fastdtw.pyx":164 * x, y = __prep_inputs(x, y, dist) * len_x, len_y = len(x), len(y) * idx = 0 # <<<<<<<<<<<<<< @@ -2677,7 +2870,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_idx = 0; - /* "fastdtw/_fastdtw.pyx":160 + /* "fastdtw/_fastdtw.pyx":167 * cdef WindowElement we * cdef vector[WindowElement] window * window.resize(len_x * len_y) # <<<<<<<<<<<<<< @@ -2688,21 +2881,21 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_v_window.resize((__pyx_v_len_x * __pyx_v_len_y)); } catch(...) { __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 160, __pyx_L1_error) + __PYX_ERR(0, 167, __pyx_L1_error) } - /* "fastdtw/_fastdtw.pyx":162 + /* "fastdtw/_fastdtw.pyx":169 * window.resize(len_x * len_y) * * for x_idx in range(len_x): # <<<<<<<<<<<<<< * for y_idx in range(len_y): * we.x_idx = x_idx */ - __pyx_t_8 = __pyx_v_len_x; - for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_t_4 = __pyx_v_len_x; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_4; __pyx_t_9+=1) { __pyx_v_x_idx = __pyx_t_9; - /* "fastdtw/_fastdtw.pyx":163 + /* "fastdtw/_fastdtw.pyx":170 * * for x_idx in range(len_x): * for y_idx in range(len_y): # <<<<<<<<<<<<<< @@ -2713,7 +2906,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_y_idx = __pyx_t_11; - /* "fastdtw/_fastdtw.pyx":164 + /* "fastdtw/_fastdtw.pyx":171 * for x_idx in range(len_x): * for y_idx in range(len_y): * we.x_idx = x_idx # <<<<<<<<<<<<<< @@ -2722,7 +2915,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.x_idx = __pyx_v_x_idx; - /* "fastdtw/_fastdtw.pyx":165 + /* "fastdtw/_fastdtw.pyx":172 * for y_idx in range(len_y): * we.x_idx = x_idx * we.y_idx = y_idx # <<<<<<<<<<<<<< @@ -2731,7 +2924,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.y_idx = __pyx_v_y_idx; - /* "fastdtw/_fastdtw.pyx":167 + /* "fastdtw/_fastdtw.pyx":174 * we.y_idx = y_idx * * if x_idx == y_idx == 0: # <<<<<<<<<<<<<< @@ -2745,7 +2938,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_13 = (__pyx_t_12 != 0); if (__pyx_t_13) { - /* "fastdtw/_fastdtw.pyx":168 + /* "fastdtw/_fastdtw.pyx":175 * * if x_idx == y_idx == 0: * we.cost_idx_left = -1 # <<<<<<<<<<<<<< @@ -2754,7 +2947,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_left = -1; - /* "fastdtw/_fastdtw.pyx":169 + /* "fastdtw/_fastdtw.pyx":176 * if x_idx == y_idx == 0: * we.cost_idx_left = -1 * we.cost_idx_up = -1 # <<<<<<<<<<<<<< @@ -2763,7 +2956,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_up = -1; - /* "fastdtw/_fastdtw.pyx":170 + /* "fastdtw/_fastdtw.pyx":177 * we.cost_idx_left = -1 * we.cost_idx_up = -1 * we.cost_idx_corner = 0 # <<<<<<<<<<<<<< @@ -2772,7 +2965,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_corner = 0; - /* "fastdtw/_fastdtw.pyx":167 + /* "fastdtw/_fastdtw.pyx":174 * we.y_idx = y_idx * * if x_idx == y_idx == 0: # <<<<<<<<<<<<<< @@ -2782,7 +2975,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ goto __pyx_L9; } - /* "fastdtw/_fastdtw.pyx":172 + /* "fastdtw/_fastdtw.pyx":179 * we.cost_idx_corner = 0 * else: * we.cost_idx_left = -1 \ # <<<<<<<<<<<<<< @@ -2791,7 +2984,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ /*else*/ { - /* "fastdtw/_fastdtw.pyx":173 + /* "fastdtw/_fastdtw.pyx":180 * else: * we.cost_idx_left = -1 \ * if y_idx == 0 and x_idx > 0 \ # <<<<<<<<<<<<<< @@ -2811,7 +3004,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_14 = -1; } else { - /* "fastdtw/_fastdtw.pyx":174 + /* "fastdtw/_fastdtw.pyx":181 * we.cost_idx_left = -1 \ * if y_idx == 0 and x_idx > 0 \ * else idx # <<<<<<<<<<<<<< @@ -2821,7 +3014,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_14 = __pyx_v_idx; } - /* "fastdtw/_fastdtw.pyx":172 + /* "fastdtw/_fastdtw.pyx":179 * we.cost_idx_corner = 0 * else: * we.cost_idx_left = -1 \ # <<<<<<<<<<<<<< @@ -2830,7 +3023,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_left = __pyx_t_14; - /* "fastdtw/_fastdtw.pyx":176 + /* "fastdtw/_fastdtw.pyx":183 * else idx * we.cost_idx_up = -1 \ * if x_idx == 0 and y_idx > 0 \ # <<<<<<<<<<<<<< @@ -2850,7 +3043,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_15 = -1; } else { - /* "fastdtw/_fastdtw.pyx":177 + /* "fastdtw/_fastdtw.pyx":184 * we.cost_idx_up = -1 \ * if x_idx == 0 and y_idx > 0 \ * else idx - len_y + 1 # <<<<<<<<<<<<<< @@ -2860,7 +3053,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_15 = ((__pyx_v_idx - __pyx_v_len_y) + 1); } - /* "fastdtw/_fastdtw.pyx":175 + /* "fastdtw/_fastdtw.pyx":182 * if y_idx == 0 and x_idx > 0 \ * else idx * we.cost_idx_up = -1 \ # <<<<<<<<<<<<<< @@ -2869,7 +3062,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_up = __pyx_t_15; - /* "fastdtw/_fastdtw.pyx":179 + /* "fastdtw/_fastdtw.pyx":186 * else idx - len_y + 1 * we.cost_idx_corner = -1 \ * if we.cost_idx_left == -1 or we.cost_idx_up == -1 \ # <<<<<<<<<<<<<< @@ -2889,7 +3082,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_15 = -1; } else { - /* "fastdtw/_fastdtw.pyx":180 + /* "fastdtw/_fastdtw.pyx":187 * we.cost_idx_corner = -1 \ * if we.cost_idx_left == -1 or we.cost_idx_up == -1 \ * else we.cost_idx_up - 1 # <<<<<<<<<<<<<< @@ -2899,7 +3092,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_15 = (__pyx_v_we.cost_idx_up - 1); } - /* "fastdtw/_fastdtw.pyx":178 + /* "fastdtw/_fastdtw.pyx":185 * if x_idx == 0 and y_idx > 0 \ * else idx - len_y + 1 * we.cost_idx_corner = -1 \ # <<<<<<<<<<<<<< @@ -2908,7 +3101,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_corner = __pyx_t_15; - /* "fastdtw/_fastdtw.pyx":182 + /* "fastdtw/_fastdtw.pyx":189 * else we.cost_idx_up - 1 * * if we.cost_idx_left == 0: # <<<<<<<<<<<<<< @@ -2918,7 +3111,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_13 = ((__pyx_v_we.cost_idx_left == 0) != 0); if (__pyx_t_13) { - /* "fastdtw/_fastdtw.pyx":183 + /* "fastdtw/_fastdtw.pyx":190 * * if we.cost_idx_left == 0: * we.cost_idx_left = -1 # <<<<<<<<<<<<<< @@ -2927,7 +3120,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_left = -1; - /* "fastdtw/_fastdtw.pyx":182 + /* "fastdtw/_fastdtw.pyx":189 * else we.cost_idx_up - 1 * * if we.cost_idx_left == 0: # <<<<<<<<<<<<<< @@ -2936,7 +3129,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ } - /* "fastdtw/_fastdtw.pyx":184 + /* "fastdtw/_fastdtw.pyx":191 * if we.cost_idx_left == 0: * we.cost_idx_left = -1 * if we.cost_idx_up == 0: # <<<<<<<<<<<<<< @@ -2946,7 +3139,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_13 = ((__pyx_v_we.cost_idx_up == 0) != 0); if (__pyx_t_13) { - /* "fastdtw/_fastdtw.pyx":185 + /* "fastdtw/_fastdtw.pyx":192 * we.cost_idx_left = -1 * if we.cost_idx_up == 0: * we.cost_idx_up = 0 # <<<<<<<<<<<<<< @@ -2955,7 +3148,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_we.cost_idx_up = 0; - /* "fastdtw/_fastdtw.pyx":184 + /* "fastdtw/_fastdtw.pyx":191 * if we.cost_idx_left == 0: * we.cost_idx_left = -1 * if we.cost_idx_up == 0: # <<<<<<<<<<<<<< @@ -2966,7 +3159,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ } __pyx_L9:; - /* "fastdtw/_fastdtw.pyx":187 + /* "fastdtw/_fastdtw.pyx":194 * we.cost_idx_up = 0 * * window[idx] = we # <<<<<<<<<<<<<< @@ -2975,7 +3168,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ (__pyx_v_window[__pyx_v_idx]) = __pyx_v_we; - /* "fastdtw/_fastdtw.pyx":188 + /* "fastdtw/_fastdtw.pyx":195 * * window[idx] = we * idx += 1 # <<<<<<<<<<<<<< @@ -2986,26 +3179,26 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ } } - /* "fastdtw/_fastdtw.pyx":192 + /* "fastdtw/_fastdtw.pyx":199 * cdef PathElement *path = ( * PyMem_Malloc( * (len(x) + len(y) - 1) * sizeof(PathElement))) # <<<<<<<<<<<<<< * * cdef int path_len = 0 */ - __pyx_t_7 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 192, __pyx_L1_error) - __pyx_t_4 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 192, __pyx_L1_error) + __pyx_t_8 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_7 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 199, __pyx_L1_error) - /* "fastdtw/_fastdtw.pyx":191 + /* "fastdtw/_fastdtw.pyx":198 * * cdef PathElement *path = ( * PyMem_Malloc( # <<<<<<<<<<<<<< * (len(x) + len(y) - 1) * sizeof(PathElement))) * */ - __pyx_v_path = ((struct __pyx_t_7fastdtw_8_fastdtw_PathElement *)PyMem_Malloc((((__pyx_t_7 + __pyx_t_4) - 1) * (sizeof(struct __pyx_t_7fastdtw_8_fastdtw_PathElement))))); + __pyx_v_path = ((struct __pyx_t_7fastdtw_8_fastdtw_PathElement *)PyMem_Malloc((((__pyx_t_8 + __pyx_t_7) - 1) * (sizeof(struct __pyx_t_7fastdtw_8_fastdtw_PathElement))))); - /* "fastdtw/_fastdtw.pyx":194 + /* "fastdtw/_fastdtw.pyx":201 * (len(x) + len(y) - 1) * sizeof(PathElement))) * * cdef int path_len = 0 # <<<<<<<<<<<<<< @@ -3014,29 +3207,29 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ __pyx_v_path_len = 0; - /* "fastdtw/_fastdtw.pyx":195 + /* "fastdtw/_fastdtw.pyx":202 * * cdef int path_len = 0 * cost = __dtw(x, y, window, dist, path, path_len) # <<<<<<<<<<<<<< * * path_lst = [] */ - __pyx_t_16 = __pyx_f_7fastdtw_8_fastdtw___dtw(__pyx_v_x, __pyx_v_y, __pyx_v_window, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_16 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 195, __pyx_L1_error) + __pyx_t_16 = __pyx_f_7fastdtw_8_fastdtw___dtw(__pyx_v_x, __pyx_v_y, __pyx_v_window, __pyx_v_dist, __pyx_v_path, __pyx_v_path_len); if (unlikely(__pyx_t_16 == -1.0 && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L1_error) __pyx_v_cost = __pyx_t_16; - /* "fastdtw/_fastdtw.pyx":197 + /* "fastdtw/_fastdtw.pyx":204 * cost = __dtw(x, y, window, dist, path, path_len) * * path_lst = [] # <<<<<<<<<<<<<< * if path != NULL: * path_lst = [(path[i].x_idx, path[i].y_idx) */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_path_lst = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":198 + /* "fastdtw/_fastdtw.pyx":205 * * path_lst = [] * if path != NULL: # <<<<<<<<<<<<<< @@ -3046,39 +3239,39 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_13 = ((__pyx_v_path != NULL) != 0); if (__pyx_t_13) { - /* "fastdtw/_fastdtw.pyx":199 + /* "fastdtw/_fastdtw.pyx":206 * path_lst = [] * if path != NULL: * path_lst = [(path[i].x_idx, path[i].y_idx) # <<<<<<<<<<<<<< * for i in range(path_len)] * PyMem_Free(path) */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "fastdtw/_fastdtw.pyx":200 + /* "fastdtw/_fastdtw.pyx":207 * if path != NULL: * path_lst = [(path[i].x_idx, path[i].y_idx) * for i in range(path_len)] # <<<<<<<<<<<<<< * PyMem_Free(path) * */ - __pyx_t_8 = __pyx_v_path_len; - for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_t_4 = __pyx_v_path_len; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_4; __pyx_t_9+=1) { __pyx_v_i = __pyx_t_9; - /* "fastdtw/_fastdtw.pyx":199 + /* "fastdtw/_fastdtw.pyx":206 * path_lst = [] * if path != NULL: * path_lst = [(path[i].x_idx, path[i].y_idx) # <<<<<<<<<<<<<< * for i in range(path_len)] * PyMem_Free(path) */ - __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).x_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).x_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).y_idx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_path[__pyx_v_i]).y_idx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); @@ -3086,13 +3279,13 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_5 = 0; __pyx_t_2 = 0; - if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 199, __pyx_L1_error) + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_path_lst, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":201 + /* "fastdtw/_fastdtw.pyx":208 * path_lst = [(path[i].x_idx, path[i].y_idx) * for i in range(path_len)] * PyMem_Free(path) # <<<<<<<<<<<<<< @@ -3101,7 +3294,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ PyMem_Free(__pyx_v_path); - /* "fastdtw/_fastdtw.pyx":198 + /* "fastdtw/_fastdtw.pyx":205 * * path_lst = [] * if path != NULL: # <<<<<<<<<<<<<< @@ -3110,7 +3303,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ */ } - /* "fastdtw/_fastdtw.pyx":203 + /* "fastdtw/_fastdtw.pyx":210 * PyMem_Free(path) * * return cost, path_lst # <<<<<<<<<<<<<< @@ -3118,9 +3311,9 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_cost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_cost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -3132,7 +3325,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ __pyx_t_3 = 0; goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":114 + /* "fastdtw/_fastdtw.pyx":121 * * * def dtw(x, y, dist=None): # <<<<<<<<<<<<<< @@ -3157,7 +3350,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_2dtw(CYTHON_UNUSED PyObject *__pyx_ return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":206 +/* "fastdtw/_fastdtw.pyx":213 * * * cdef inline double __difference(double a, double b): # <<<<<<<<<<<<<< @@ -3170,7 +3363,7 @@ static CYTHON_INLINE double __pyx_f_7fastdtw_8_fastdtw___difference(double __pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__difference", 0); - /* "fastdtw/_fastdtw.pyx":207 + /* "fastdtw/_fastdtw.pyx":214 * * cdef inline double __difference(double a, double b): * return fabs(a - b) # <<<<<<<<<<<<<< @@ -3180,7 +3373,7 @@ static CYTHON_INLINE double __pyx_f_7fastdtw_8_fastdtw___difference(double __pyx __pyx_r = fabs((__pyx_v_a - __pyx_v_b)); goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":206 + /* "fastdtw/_fastdtw.pyx":213 * * * cdef inline double __difference(double a, double b): # <<<<<<<<<<<<<< @@ -3194,7 +3387,7 @@ static CYTHON_INLINE double __pyx_f_7fastdtw_8_fastdtw___difference(double __pyx return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":210 +/* "fastdtw/_fastdtw.pyx":217 * * * def __norm(p): # <<<<<<<<<<<<<< @@ -3216,7 +3409,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_5__norm(PyObject *__pyx_self, PyObj return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":211 +/* "fastdtw/_fastdtw.pyx":218 * * def __norm(p): * return lambda a, b: np.linalg.norm(a - b, p) # <<<<<<<<<<<<<< @@ -3253,11 +3446,11 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_6__norm_lambda(PyObject *__pyx_self case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("lambda", 1, 2, 2, 1); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("lambda", 1, 2, 2, 1); __PYX_ERR(0, 218, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda") < 0)) __PYX_ERR(0, 211, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lambda") < 0)) __PYX_ERR(0, 218, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -3270,7 +3463,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_6__norm_lambda(PyObject *__pyx_self } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("lambda", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 211, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("lambda", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 218, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("fastdtw._fastdtw.__norm.lambda", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3292,26 +3485,26 @@ static PyObject *__pyx_lambda_funcdef_lambda(PyObject *__pyx_self, PyObject *__p PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - Py_ssize_t __pyx_t_5; + int __pyx_t_5; PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("lambda", 0); __pyx_outer_scope = (struct __pyx_obj_7fastdtw_8_fastdtw___pyx_scope_struct____norm *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_norm); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_norm); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Subtract(__pyx_v_a, __pyx_v_b); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_3 = PyNumber_Subtract(__pyx_v_a, __pyx_v_b); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (unlikely(!__pyx_cur_scope->__pyx_v_p)) { __Pyx_RaiseClosureNameError("p"); __PYX_ERR(0, 211, __pyx_L1_error) } + if (unlikely(!__pyx_cur_scope->__pyx_v_p)) { __Pyx_RaiseClosureNameError("p"); __PYX_ERR(0, 218, __pyx_L1_error) } __pyx_t_4 = NULL; __pyx_t_5 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); @@ -3321,20 +3514,40 @@ static PyObject *__pyx_lambda_funcdef_lambda(PyObject *__pyx_self, PyObject *__p __pyx_t_5 = 1; } } - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_cur_scope->__pyx_v_p}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_cur_scope->__pyx_v_p}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_3); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_p); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_p); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_p); + __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_3); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_p); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_p); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_p); - __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3355,7 +3568,7 @@ static PyObject *__pyx_lambda_funcdef_lambda(PyObject *__pyx_self, PyObject *__p return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":210 +/* "fastdtw/_fastdtw.pyx":217 * * * def __norm(p): # <<<<<<<<<<<<<< @@ -3371,15 +3584,17 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_4__norm(CYTHON_UNUSED PyObject *__p __Pyx_RefNannySetupContext("__norm", 0); __pyx_cur_scope = (struct __pyx_obj_7fastdtw_8_fastdtw___pyx_scope_struct____norm *)__pyx_tp_new_7fastdtw_8_fastdtw___pyx_scope_struct____norm(__pyx_ptype_7fastdtw_8_fastdtw___pyx_scope_struct____norm, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { - __Pyx_RefNannyFinishContext(); - return NULL; + __pyx_cur_scope = ((struct __pyx_obj_7fastdtw_8_fastdtw___pyx_scope_struct____norm *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(0, 217, __pyx_L1_error) + } else { + __Pyx_GOTREF(__pyx_cur_scope); } - __Pyx_GOTREF(__pyx_cur_scope); __pyx_cur_scope->__pyx_v_p = __pyx_v_p; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_p); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_p); - /* "fastdtw/_fastdtw.pyx":211 + /* "fastdtw/_fastdtw.pyx":218 * * def __norm(p): * return lambda a, b: np.linalg.norm(a - b, p) # <<<<<<<<<<<<<< @@ -3387,13 +3602,13 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_4__norm(CYTHON_UNUSED PyObject *__p * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_6__norm_lambda, 0, __pyx_n_s_norm_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_fastdtw__fastdtw, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_6__norm_lambda, 0, __pyx_n_s_norm_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_fastdtw__fastdtw, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":210 + /* "fastdtw/_fastdtw.pyx":217 * * * def __norm(p): # <<<<<<<<<<<<<< @@ -3413,7 +3628,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_4__norm(CYTHON_UNUSED PyObject *__p return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":214 +/* "fastdtw/_fastdtw.pyx":221 * * * def __prep_inputs(x, y, dist): # <<<<<<<<<<<<<< @@ -3452,16 +3667,16 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_7__prep_inputs(PyObject *__pyx_self case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__prep_inputs", 1, 3, 3, 1); __PYX_ERR(0, 214, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__prep_inputs", 1, 3, 3, 1); __PYX_ERR(0, 221, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dist)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__prep_inputs", 1, 3, 3, 2); __PYX_ERR(0, 214, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__prep_inputs", 1, 3, 3, 2); __PYX_ERR(0, 221, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__prep_inputs") < 0)) __PYX_ERR(0, 214, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__prep_inputs") < 0)) __PYX_ERR(0, 221, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -3476,7 +3691,7 @@ static PyObject *__pyx_pw_7fastdtw_8_fastdtw_7__prep_inputs(PyObject *__pyx_self } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__prep_inputs", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 214, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__prep_inputs", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 221, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("fastdtw._fastdtw.__prep_inputs", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3503,27 +3718,27 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje __Pyx_INCREF(__pyx_v_x); __Pyx_INCREF(__pyx_v_y); - /* "fastdtw/_fastdtw.pyx":215 + /* "fastdtw/_fastdtw.pyx":222 * * def __prep_inputs(x, y, dist): * x = np.asanyarray(x, dtype='float') # <<<<<<<<<<<<<< * y = np.asanyarray(y, dtype='float') * */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asanyarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asanyarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_x); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_n_s_float) < 0) __PYX_ERR(0, 215, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 215, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_n_s_float) < 0) __PYX_ERR(0, 222, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3531,27 +3746,27 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_4); __pyx_t_4 = 0; - /* "fastdtw/_fastdtw.pyx":216 + /* "fastdtw/_fastdtw.pyx":223 * def __prep_inputs(x, y, dist): * x = np.asanyarray(x, dtype='float') * y = np.asanyarray(y, dtype='float') # <<<<<<<<<<<<<< * * if x.ndim == y.ndim > 1 and x.shape[1] != y.shape[1]: */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asanyarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 216, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asanyarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_y); - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error) + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_n_s_float) < 0) __PYX_ERR(0, 216, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_n_s_float) < 0) __PYX_ERR(0, 223, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -3559,64 +3774,64 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_2); __pyx_t_2 = 0; - /* "fastdtw/_fastdtw.pyx":218 + /* "fastdtw/_fastdtw.pyx":225 * y = np.asanyarray(y, dtype='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') * if isinstance(dist, numbers.Number) and dist <= 0: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_4)) { __Pyx_DECREF(__pyx_t_4); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_5) { - /* "fastdtw/_fastdtw.pyx":219 + /* "fastdtw/_fastdtw.pyx":226 * * 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') # <<<<<<<<<<<<<< * if isinstance(dist, numbers.Number) and dist <= 0: * raise ValueError('dist cannot be a negative integer') */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 219, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 219, __pyx_L1_error) + __PYX_ERR(0, 226, __pyx_L1_error) - /* "fastdtw/_fastdtw.pyx":218 + /* "fastdtw/_fastdtw.pyx":225 * y = np.asanyarray(y, dtype='float') * * if x.ndim == y.ndim > 1 and x.shape[1] != y.shape[1]: # <<<<<<<<<<<<<< @@ -3625,19 +3840,19 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje */ } - /* "fastdtw/_fastdtw.pyx":220 + /* "fastdtw/_fastdtw.pyx":227 * 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') * if isinstance(dist, numbers.Number) and dist <= 0: # <<<<<<<<<<<<<< * raise ValueError('dist cannot be a negative integer') * */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numbers); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numbers); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Number); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Number); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = PyObject_IsInstance(__pyx_v_dist, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 220, __pyx_L1_error) + __pyx_t_6 = PyObject_IsInstance(__pyx_v_dist, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (__pyx_t_6 != 0); if (__pyx_t_7) { @@ -3645,27 +3860,27 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje __pyx_t_5 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } - __pyx_t_2 = PyObject_RichCompare(__pyx_v_dist, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 220, __pyx_L1_error) + __pyx_t_2 = PyObject_RichCompare(__pyx_v_dist, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __pyx_t_7; __pyx_L7_bool_binop_done:; if (__pyx_t_5) { - /* "fastdtw/_fastdtw.pyx":221 + /* "fastdtw/_fastdtw.pyx":228 * raise ValueError('second dimension of x and y must be the same') * if isinstance(dist, numbers.Number) and dist <= 0: * raise ValueError('dist cannot be a negative integer') # <<<<<<<<<<<<<< * * return x, y */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 221, __pyx_L1_error) + __PYX_ERR(0, 228, __pyx_L1_error) - /* "fastdtw/_fastdtw.pyx":220 + /* "fastdtw/_fastdtw.pyx":227 * 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') * if isinstance(dist, numbers.Number) and dist <= 0: # <<<<<<<<<<<<<< @@ -3674,7 +3889,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje */ } - /* "fastdtw/_fastdtw.pyx":223 + /* "fastdtw/_fastdtw.pyx":230 * raise ValueError('dist cannot be a negative integer') * * return x, y # <<<<<<<<<<<<<< @@ -3682,7 +3897,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); @@ -3694,7 +3909,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje __pyx_t_2 = 0; goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":214 + /* "fastdtw/_fastdtw.pyx":221 * * * def __prep_inputs(x, y, dist): # <<<<<<<<<<<<<< @@ -3718,7 +3933,7 @@ static PyObject *__pyx_pf_7fastdtw_8_fastdtw_6__prep_inputs(CYTHON_UNUSED PyObje return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":226 +/* "fastdtw/_fastdtw.pyx":233 * * * cdef double __dtw(x, y, vector[WindowElement] &window, dist, # <<<<<<<<<<<<<< @@ -3760,26 +3975,26 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; - Py_ssize_t __pyx_t_11; + int __pyx_t_11; PyObject *__pyx_t_12 = NULL; __Pyx_memviewslice __pyx_t_13 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_t_14 = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_t_15; - int __pyx_t_16; + Py_ssize_t __pyx_t_16; Py_ssize_t __pyx_t_17; - Py_ssize_t __pyx_t_18; + int __pyx_t_18; int __pyx_t_19; - int __pyx_t_20; + Py_ssize_t __pyx_t_20; Py_ssize_t __pyx_t_21; Py_ssize_t __pyx_t_22; Py_ssize_t __pyx_t_23; - Py_ssize_t __pyx_t_24; + long double __pyx_t_24; int *__pyx_t_25; long __pyx_t_26; __Pyx_RefNannySetupContext("__dtw", 0); __Pyx_INCREF(__pyx_v_dist); - /* "fastdtw/_fastdtw.pyx":231 + /* "fastdtw/_fastdtw.pyx":238 * time series can only be in window. * ''' * cdef int window_len = window.size() # <<<<<<<<<<<<<< @@ -3788,7 +4003,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_window_len = __pyx_v_window.size(); - /* "fastdtw/_fastdtw.pyx":238 + /* "fastdtw/_fastdtw.pyx":245 * # initializing to avoid compiler warnings although if these variables are * # used they will always be set below * cdef int use_1d = 0, use_2d = 0, width = 0 # <<<<<<<<<<<<<< @@ -3799,29 +4014,29 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_v_use_2d = 0; __pyx_v_width = 0; - /* "fastdtw/_fastdtw.pyx":248 + /* "fastdtw/_fastdtw.pyx":255 * # if it is numpy array we can get an order of magnitude improvement * # by calculating the p-norm ourselves. * cdef double pnorm = -1.0 if not isinstance(dist, numbers.Number) else dist # <<<<<<<<<<<<<< * if ((dist is None or pnorm > 0) and * (isinstance(x, np.ndarray) and isinstance(y, np.ndarray) and */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numbers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numbers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Number); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Number); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = PyObject_IsInstance(__pyx_v_dist, __pyx_t_3); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_t_4 = PyObject_IsInstance(__pyx_v_dist, __pyx_t_3); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 255, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (((!(__pyx_t_4 != 0)) != 0)) { __pyx_t_1 = -1.0; } else { - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_dist); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_dist); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L1_error) __pyx_t_1 = __pyx_t_5; } __pyx_v_pnorm = __pyx_t_1; - /* "fastdtw/_fastdtw.pyx":249 + /* "fastdtw/_fastdtw.pyx":256 * # by calculating the p-norm ourselves. * cdef double pnorm = -1.0 if not isinstance(dist, numbers.Number) else dist * if ((dist is None or pnorm > 0) and # <<<<<<<<<<<<<< @@ -3842,19 +4057,19 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ } __pyx_L5_next_and:; - /* "fastdtw/_fastdtw.pyx":250 + /* "fastdtw/_fastdtw.pyx":257 * cdef double pnorm = -1.0 if not isinstance(dist, numbers.Number) else dist * if ((dist is None or pnorm > 0) and * (isinstance(x, np.ndarray) and isinstance(y, np.ndarray) and # <<<<<<<<<<<<<< * np.issubdtype(x.dtype, np.float) and * np.issubdtype(y.dtype, np.float))): */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_7 = PyObject_IsInstance(__pyx_v_x, __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_7 = PyObject_IsInstance(__pyx_v_x, __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = (__pyx_t_7 != 0); if (__pyx_t_6) { @@ -3862,12 +4077,12 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_4 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_6 = PyObject_IsInstance(__pyx_v_y, __pyx_t_3); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_6 = PyObject_IsInstance(__pyx_v_y, __pyx_t_3); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = (__pyx_t_6 != 0); if (__pyx_t_7) { @@ -3876,28 +4091,28 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L4_bool_binop_done; } - /* "fastdtw/_fastdtw.pyx":251 + /* "fastdtw/_fastdtw.pyx":258 * if ((dist is None or pnorm > 0) and * (isinstance(x, np.ndarray) and isinstance(y, np.ndarray) and * np.issubdtype(x.dtype, np.float) and # <<<<<<<<<<<<<< * np.issubdtype(y.dtype, np.float))): * */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_issubdtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_issubdtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_float); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_float); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_11 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); @@ -3907,22 +4122,44 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_11 = 1; } } - __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_8)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_2, __pyx_t_10}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_2, __pyx_t_10}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10); + __pyx_t_2 = 0; + __pyx_t_10 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10); - __pyx_t_2 = 0; - __pyx_t_10 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_7) { } else { @@ -3930,28 +4167,28 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L4_bool_binop_done; } - /* "fastdtw/_fastdtw.pyx":252 + /* "fastdtw/_fastdtw.pyx":259 * (isinstance(x, np.ndarray) and isinstance(y, np.ndarray) and * np.issubdtype(x.dtype, np.float) and * np.issubdtype(y.dtype, np.float))): # <<<<<<<<<<<<<< * * if x.ndim == 1: */ - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_issubdtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_issubdtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_float); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_float); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_11 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); @@ -3961,27 +4198,49 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_11 = 1; } } - __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_12)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_8, __pyx_t_2}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_8, __pyx_t_2}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_10) { + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_2); + __pyx_t_8 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_2); - __pyx_t_8 = 0; - __pyx_t_2 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __pyx_t_7; __pyx_L4_bool_binop_done:; - /* "fastdtw/_fastdtw.pyx":249 + /* "fastdtw/_fastdtw.pyx":256 * # by calculating the p-norm ourselves. * cdef double pnorm = -1.0 if not isinstance(dist, numbers.Number) else dist * if ((dist is None or pnorm > 0) and # <<<<<<<<<<<<<< @@ -3990,23 +4249,23 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ if (__pyx_t_4) { - /* "fastdtw/_fastdtw.pyx":254 + /* "fastdtw/_fastdtw.pyx":261 * np.issubdtype(y.dtype, np.float))): * * if x.ndim == 1: # <<<<<<<<<<<<<< * if dist is None: * pnorm = 1 */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_12 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_4) { - /* "fastdtw/_fastdtw.pyx":255 + /* "fastdtw/_fastdtw.pyx":262 * * if x.ndim == 1: * if dist is None: # <<<<<<<<<<<<<< @@ -4017,7 +4276,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_7 = (__pyx_t_4 != 0); if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":256 + /* "fastdtw/_fastdtw.pyx":263 * if x.ndim == 1: * if dist is None: * pnorm = 1 # <<<<<<<<<<<<<< @@ -4026,7 +4285,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_pnorm = 1.0; - /* "fastdtw/_fastdtw.pyx":255 + /* "fastdtw/_fastdtw.pyx":262 * * if x.ndim == 1: * if dist is None: # <<<<<<<<<<<<<< @@ -4035,7 +4294,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ } - /* "fastdtw/_fastdtw.pyx":257 + /* "fastdtw/_fastdtw.pyx":264 * if dist is None: * pnorm = 1 * use_1d = 1 # <<<<<<<<<<<<<< @@ -4044,7 +4303,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_use_1d = 1; - /* "fastdtw/_fastdtw.pyx":258 + /* "fastdtw/_fastdtw.pyx":265 * pnorm = 1 * use_1d = 1 * x_arr1d = x # <<<<<<<<<<<<<< @@ -4052,12 +4311,12 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ * elif x.ndim == 2: */ __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_x); - if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 258, __pyx_L1_error) + if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 265, __pyx_L1_error) __pyx_v_x_arr1d = __pyx_t_13; __pyx_t_13.memview = NULL; __pyx_t_13.data = NULL; - /* "fastdtw/_fastdtw.pyx":259 + /* "fastdtw/_fastdtw.pyx":266 * use_1d = 1 * x_arr1d = x * y_arr1d = y # <<<<<<<<<<<<<< @@ -4065,12 +4324,12 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ * if dist is None: */ __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_y); - if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 259, __pyx_L1_error) + if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 266, __pyx_L1_error) __pyx_v_y_arr1d = __pyx_t_13; __pyx_t_13.memview = NULL; __pyx_t_13.data = NULL; - /* "fastdtw/_fastdtw.pyx":254 + /* "fastdtw/_fastdtw.pyx":261 * np.issubdtype(y.dtype, np.float))): * * if x.ndim == 1: # <<<<<<<<<<<<<< @@ -4080,23 +4339,23 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L10; } - /* "fastdtw/_fastdtw.pyx":260 + /* "fastdtw/_fastdtw.pyx":267 * x_arr1d = x * y_arr1d = y * elif x.ndim == 2: # <<<<<<<<<<<<<< * if dist is None: * pnorm = 1 */ - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_ndim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_ndim); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); - __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":261 + /* "fastdtw/_fastdtw.pyx":268 * y_arr1d = y * elif x.ndim == 2: * if dist is None: # <<<<<<<<<<<<<< @@ -4107,7 +4366,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_4 = (__pyx_t_7 != 0); if (__pyx_t_4) { - /* "fastdtw/_fastdtw.pyx":262 + /* "fastdtw/_fastdtw.pyx":269 * elif x.ndim == 2: * if dist is None: * pnorm = 1 # <<<<<<<<<<<<<< @@ -4116,7 +4375,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_pnorm = 1.0; - /* "fastdtw/_fastdtw.pyx":261 + /* "fastdtw/_fastdtw.pyx":268 * y_arr1d = y * elif x.ndim == 2: * if dist is None: # <<<<<<<<<<<<<< @@ -4125,7 +4384,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ } - /* "fastdtw/_fastdtw.pyx":263 + /* "fastdtw/_fastdtw.pyx":270 * if dist is None: * pnorm = 1 * use_2d = 1 # <<<<<<<<<<<<<< @@ -4134,7 +4393,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_use_2d = 1; - /* "fastdtw/_fastdtw.pyx":264 + /* "fastdtw/_fastdtw.pyx":271 * pnorm = 1 * use_2d = 1 * x_arr2d = x # <<<<<<<<<<<<<< @@ -4142,12 +4401,12 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ * width = x.shape[1] */ __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_v_x); - if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(0, 264, __pyx_L1_error) + if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(0, 271, __pyx_L1_error) __pyx_v_x_arr2d = __pyx_t_14; __pyx_t_14.memview = NULL; __pyx_t_14.data = NULL; - /* "fastdtw/_fastdtw.pyx":265 + /* "fastdtw/_fastdtw.pyx":272 * use_2d = 1 * x_arr2d = x * y_arr2d = y # <<<<<<<<<<<<<< @@ -4155,28 +4414,28 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ * */ __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_v_y); - if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(0, 265, __pyx_L1_error) + if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(0, 272, __pyx_L1_error) __pyx_v_y_arr2d = __pyx_t_14; __pyx_t_14.memview = NULL; __pyx_t_14.data = NULL; - /* "fastdtw/_fastdtw.pyx":266 + /* "fastdtw/_fastdtw.pyx":273 * x_arr2d = x * y_arr2d = y * width = x.shape[1] # <<<<<<<<<<<<<< * * if not use_1d and not use_2d: */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_v_width = __pyx_t_15; + __pyx_v_width = __pyx_t_11; - /* "fastdtw/_fastdtw.pyx":260 + /* "fastdtw/_fastdtw.pyx":267 * x_arr1d = x * y_arr1d = y * elif x.ndim == 2: # <<<<<<<<<<<<<< @@ -4186,7 +4445,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ } __pyx_L10:; - /* "fastdtw/_fastdtw.pyx":249 + /* "fastdtw/_fastdtw.pyx":256 * # by calculating the p-norm ourselves. * cdef double pnorm = -1.0 if not isinstance(dist, numbers.Number) else dist * if ((dist is None or pnorm > 0) and # <<<<<<<<<<<<<< @@ -4195,7 +4454,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ } - /* "fastdtw/_fastdtw.pyx":268 + /* "fastdtw/_fastdtw.pyx":275 * width = x.shape[1] * * if not use_1d and not use_2d: # <<<<<<<<<<<<<< @@ -4213,7 +4472,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_L14_bool_binop_done:; if (__pyx_t_4) { - /* "fastdtw/_fastdtw.pyx":269 + /* "fastdtw/_fastdtw.pyx":276 * * if not use_1d and not use_2d: * if dist is None: # <<<<<<<<<<<<<< @@ -4224,19 +4483,19 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_7 = (__pyx_t_4 != 0); if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":270 + /* "fastdtw/_fastdtw.pyx":277 * if not use_1d and not use_2d: * if dist is None: * dist = __difference # <<<<<<<<<<<<<< * elif pnorm > 0: * dist = __norm(pnorm) */ - __pyx_t_12 = __Pyx_CFunc_double____double____double___to_py(__pyx_f_7fastdtw_8_fastdtw___difference); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 270, __pyx_L1_error) + __pyx_t_12 = __Pyx_CFunc_double____double____double___to_py(__pyx_f_7fastdtw_8_fastdtw___difference); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF_SET(__pyx_v_dist, __pyx_t_12); __pyx_t_12 = 0; - /* "fastdtw/_fastdtw.pyx":269 + /* "fastdtw/_fastdtw.pyx":276 * * if not use_1d and not use_2d: * if dist is None: # <<<<<<<<<<<<<< @@ -4246,7 +4505,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L16; } - /* "fastdtw/_fastdtw.pyx":271 + /* "fastdtw/_fastdtw.pyx":278 * if dist is None: * dist = __difference * elif pnorm > 0: # <<<<<<<<<<<<<< @@ -4256,19 +4515,19 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_7 = ((__pyx_v_pnorm > 0.0) != 0); if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":272 + /* "fastdtw/_fastdtw.pyx":279 * dist = __difference * elif pnorm > 0: * dist = __norm(pnorm) # <<<<<<<<<<<<<< * * # loop over the window. Note from __expand_window that if we loop over its */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_norm_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_norm_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = PyFloat_FromDouble(__pyx_v_pnorm); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_9 = PyFloat_FromDouble(__pyx_v_pnorm); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); @@ -4278,25 +4537,45 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ } } if (!__pyx_t_2) { - __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_12); } else { - __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 272, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL; - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_9}; + __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 279, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_9}; + __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 279, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL; + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_dist, __pyx_t_12); __pyx_t_12 = 0; - /* "fastdtw/_fastdtw.pyx":271 + /* "fastdtw/_fastdtw.pyx":278 * if dist is None: * dist = __difference * elif pnorm > 0: # <<<<<<<<<<<<<< @@ -4306,7 +4585,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ } __pyx_L16:; - /* "fastdtw/_fastdtw.pyx":268 + /* "fastdtw/_fastdtw.pyx":275 * width = x.shape[1] * * if not use_1d and not use_2d: # <<<<<<<<<<<<<< @@ -4315,7 +4594,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ } - /* "fastdtw/_fastdtw.pyx":278 + /* "fastdtw/_fastdtw.pyx":285 * # Note further that the cost vector has the same indices as window with an * # offset of 1. * cost_len = window_len + 1 # <<<<<<<<<<<<<< @@ -4324,7 +4603,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_cost_len = (__pyx_v_window_len + 1); - /* "fastdtw/_fastdtw.pyx":280 + /* "fastdtw/_fastdtw.pyx":287 * cost_len = window_len + 1 * cdef vector[CostElement] cost * cost.resize(cost_len) # <<<<<<<<<<<<<< @@ -4335,10 +4614,10 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_v_cost.resize(__pyx_v_cost_len); } catch(...) { __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 280, __pyx_L1_error) + __PYX_ERR(0, 287, __pyx_L1_error) } - /* "fastdtw/_fastdtw.pyx":281 + /* "fastdtw/_fastdtw.pyx":288 * cdef vector[CostElement] cost * cost.resize(cost_len) * cost[0].cost = 0 # <<<<<<<<<<<<<< @@ -4347,7 +4626,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ (__pyx_v_cost[0]).cost = 0.0; - /* "fastdtw/_fastdtw.pyx":282 + /* "fastdtw/_fastdtw.pyx":289 * cost.resize(cost_len) * cost[0].cost = 0 * cost[0].prev_idx = -1 # <<<<<<<<<<<<<< @@ -4356,18 +4635,18 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ (__pyx_v_cost[0]).prev_idx = -1; - /* "fastdtw/_fastdtw.pyx":284 + /* "fastdtw/_fastdtw.pyx":291 * cost[0].prev_idx = -1 * * for idx in range(window_len): # <<<<<<<<<<<<<< * * we = window[idx] */ - __pyx_t_15 = __pyx_v_window_len; - for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { - __pyx_v_idx = __pyx_t_16; + __pyx_t_11 = __pyx_v_window_len; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_11; __pyx_t_15+=1) { + __pyx_v_idx = __pyx_t_15; - /* "fastdtw/_fastdtw.pyx":286 + /* "fastdtw/_fastdtw.pyx":293 * for idx in range(window_len): * * we = window[idx] # <<<<<<<<<<<<<< @@ -4376,7 +4655,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_we = (__pyx_v_window[__pyx_v_idx]); - /* "fastdtw/_fastdtw.pyx":287 + /* "fastdtw/_fastdtw.pyx":294 * * we = window[idx] * if use_1d: # <<<<<<<<<<<<<< @@ -4386,20 +4665,20 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_7 = (__pyx_v_use_1d != 0); if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":288 + /* "fastdtw/_fastdtw.pyx":295 * we = window[idx] * if use_1d: * dt = abs(x_arr1d[we.x_idx] - y_arr1d[we.y_idx]) # <<<<<<<<<<<<<< * elif use_2d: * sm = 0 */ - if (unlikely(!__pyx_v_x_arr1d.memview)) { __Pyx_RaiseUnboundLocalError("x_arr1d"); __PYX_ERR(0, 288, __pyx_L1_error) } - __pyx_t_17 = __pyx_v_we.x_idx; - if (unlikely(!__pyx_v_y_arr1d.memview)) { __Pyx_RaiseUnboundLocalError("y_arr1d"); __PYX_ERR(0, 288, __pyx_L1_error) } - __pyx_t_18 = __pyx_v_we.y_idx; - __pyx_v_dt = fabs(((*((double *) ( /* dim=0 */ (__pyx_v_x_arr1d.data + __pyx_t_17 * __pyx_v_x_arr1d.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_y_arr1d.data + __pyx_t_18 * __pyx_v_y_arr1d.strides[0]) ))))); + if (unlikely(!__pyx_v_x_arr1d.memview)) { __Pyx_RaiseUnboundLocalError("x_arr1d"); __PYX_ERR(0, 295, __pyx_L1_error) } + __pyx_t_16 = __pyx_v_we.x_idx; + if (unlikely(!__pyx_v_y_arr1d.memview)) { __Pyx_RaiseUnboundLocalError("y_arr1d"); __PYX_ERR(0, 295, __pyx_L1_error) } + __pyx_t_17 = __pyx_v_we.y_idx; + __pyx_v_dt = fabs(((*((double *) ( /* dim=0 */ (__pyx_v_x_arr1d.data + __pyx_t_16 * __pyx_v_x_arr1d.strides[0]) ))) - (*((double *) ( /* dim=0 */ (__pyx_v_y_arr1d.data + __pyx_t_17 * __pyx_v_y_arr1d.strides[0]) ))))); - /* "fastdtw/_fastdtw.pyx":287 + /* "fastdtw/_fastdtw.pyx":294 * * we = window[idx] * if use_1d: # <<<<<<<<<<<<<< @@ -4409,7 +4688,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L19; } - /* "fastdtw/_fastdtw.pyx":289 + /* "fastdtw/_fastdtw.pyx":296 * if use_1d: * dt = abs(x_arr1d[we.x_idx] - y_arr1d[we.y_idx]) * elif use_2d: # <<<<<<<<<<<<<< @@ -4419,7 +4698,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_7 = (__pyx_v_use_2d != 0); if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":290 + /* "fastdtw/_fastdtw.pyx":297 * dt = abs(x_arr1d[we.x_idx] - y_arr1d[we.y_idx]) * elif use_2d: * sm = 0 # <<<<<<<<<<<<<< @@ -4428,33 +4707,33 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_sm = 0.0; - /* "fastdtw/_fastdtw.pyx":291 + /* "fastdtw/_fastdtw.pyx":298 * elif use_2d: * sm = 0 * for i in range(width): # <<<<<<<<<<<<<< * diff = abs(x_arr2d[we.x_idx, i] - y_arr2d[we.y_idx, i]) * sm += pow(diff, pnorm) */ - __pyx_t_19 = __pyx_v_width; - for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { - __pyx_v_i = __pyx_t_20; + __pyx_t_18 = __pyx_v_width; + for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { + __pyx_v_i = __pyx_t_19; - /* "fastdtw/_fastdtw.pyx":292 + /* "fastdtw/_fastdtw.pyx":299 * sm = 0 * for i in range(width): * diff = abs(x_arr2d[we.x_idx, i] - y_arr2d[we.y_idx, i]) # <<<<<<<<<<<<<< * sm += pow(diff, pnorm) * dt = pow(sm, 1 / pnorm) */ - if (unlikely(!__pyx_v_x_arr2d.memview)) { __Pyx_RaiseUnboundLocalError("x_arr2d"); __PYX_ERR(0, 292, __pyx_L1_error) } - __pyx_t_21 = __pyx_v_we.x_idx; - __pyx_t_22 = __pyx_v_i; - if (unlikely(!__pyx_v_y_arr2d.memview)) { __Pyx_RaiseUnboundLocalError("y_arr2d"); __PYX_ERR(0, 292, __pyx_L1_error) } - __pyx_t_23 = __pyx_v_we.y_idx; - __pyx_t_24 = __pyx_v_i; - __pyx_v_diff = fabs(((*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x_arr2d.data + __pyx_t_21 * __pyx_v_x_arr2d.strides[0]) ) + __pyx_t_22 * __pyx_v_x_arr2d.strides[1]) ))) - (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_y_arr2d.data + __pyx_t_23 * __pyx_v_y_arr2d.strides[0]) ) + __pyx_t_24 * __pyx_v_y_arr2d.strides[1]) ))))); + if (unlikely(!__pyx_v_x_arr2d.memview)) { __Pyx_RaiseUnboundLocalError("x_arr2d"); __PYX_ERR(0, 299, __pyx_L1_error) } + __pyx_t_20 = __pyx_v_we.x_idx; + __pyx_t_21 = __pyx_v_i; + if (unlikely(!__pyx_v_y_arr2d.memview)) { __Pyx_RaiseUnboundLocalError("y_arr2d"); __PYX_ERR(0, 299, __pyx_L1_error) } + __pyx_t_22 = __pyx_v_we.y_idx; + __pyx_t_23 = __pyx_v_i; + __pyx_v_diff = fabs(((*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_x_arr2d.data + __pyx_t_20 * __pyx_v_x_arr2d.strides[0]) ) + __pyx_t_21 * __pyx_v_x_arr2d.strides[1]) ))) - (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_y_arr2d.data + __pyx_t_22 * __pyx_v_y_arr2d.strides[0]) ) + __pyx_t_23 * __pyx_v_y_arr2d.strides[1]) ))))); - /* "fastdtw/_fastdtw.pyx":293 + /* "fastdtw/_fastdtw.pyx":300 * for i in range(width): * diff = abs(x_arr2d[we.x_idx, i] - y_arr2d[we.y_idx, i]) * sm += pow(diff, pnorm) # <<<<<<<<<<<<<< @@ -4464,7 +4743,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_v_sm = (__pyx_v_sm + pow(__pyx_v_diff, __pyx_v_pnorm)); } - /* "fastdtw/_fastdtw.pyx":294 + /* "fastdtw/_fastdtw.pyx":301 * diff = abs(x_arr2d[we.x_idx, i] - y_arr2d[we.y_idx, i]) * sm += pow(diff, pnorm) * dt = pow(sm, 1 / pnorm) # <<<<<<<<<<<<<< @@ -4473,7 +4752,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_dt = pow(__pyx_v_sm, (1.0 / __pyx_v_pnorm)); - /* "fastdtw/_fastdtw.pyx":289 + /* "fastdtw/_fastdtw.pyx":296 * if use_1d: * dt = abs(x_arr1d[we.x_idx] - y_arr1d[we.y_idx]) * elif use_2d: # <<<<<<<<<<<<<< @@ -4483,7 +4762,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L19; } - /* "fastdtw/_fastdtw.pyx":296 + /* "fastdtw/_fastdtw.pyx":303 * dt = pow(sm, 1 / pnorm) * else: * dt = dist(x[we.x_idx], y[we.y_idx]) # <<<<<<<<<<<<<< @@ -4491,45 +4770,67 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ * d_left = cost[we.cost_idx_left].cost \ */ /*else*/ { - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_we.x_idx, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_we.x_idx, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_y, __pyx_v_we.y_idx, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_y, __pyx_v_we.y_idx, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_dist); __pyx_t_9 = __pyx_v_dist; __pyx_t_2 = NULL; - __pyx_t_11 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_18 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); - __pyx_t_11 = 1; + __pyx_t_18 = 1; } } - __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - if (__pyx_t_2) { - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_9)) { + PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_3, __pyx_t_8}; + __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 303, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { + PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_3, __pyx_t_8}; + __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_18, 2+__pyx_t_18); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 303, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else + #endif + { + __pyx_t_10 = PyTuple_New(2+__pyx_t_18); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 303, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_2) { + __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_18, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_18, __pyx_t_8); + __pyx_t_3 = 0; + __pyx_t_8 = 0; + __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 303, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_8); - __pyx_t_3 = 0; - __pyx_t_8 = 0; - __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_t_12); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_t_12); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_v_dt = __pyx_t_1; } __pyx_L19:; - /* "fastdtw/_fastdtw.pyx":299 + /* "fastdtw/_fastdtw.pyx":306 * * d_left = cost[we.cost_idx_left].cost \ * if we.cost_idx_left != -1 else INFINITY # <<<<<<<<<<<<<< @@ -4538,28 +4839,28 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ if (((__pyx_v_we.cost_idx_left != -1L) != 0)) { - /* "fastdtw/_fastdtw.pyx":298 + /* "fastdtw/_fastdtw.pyx":305 * dt = dist(x[we.x_idx], y[we.y_idx]) * * d_left = cost[we.cost_idx_left].cost \ # <<<<<<<<<<<<<< * if we.cost_idx_left != -1 else INFINITY * d_up = cost[we.cost_idx_up].cost \ */ - __pyx_t_1 = (__pyx_v_cost[__pyx_v_we.cost_idx_left]).cost; + __pyx_t_24 = (__pyx_v_cost[__pyx_v_we.cost_idx_left]).cost; } else { - /* "fastdtw/_fastdtw.pyx":299 + /* "fastdtw/_fastdtw.pyx":306 * * d_left = cost[we.cost_idx_left].cost \ * if we.cost_idx_left != -1 else INFINITY # <<<<<<<<<<<<<< * d_up = cost[we.cost_idx_up].cost \ * if we.cost_idx_up != -1 else INFINITY */ - __pyx_t_1 = INFINITY; + __pyx_t_24 = NPY_INFINITY; } - __pyx_v_d_left = __pyx_t_1; + __pyx_v_d_left = __pyx_t_24; - /* "fastdtw/_fastdtw.pyx":301 + /* "fastdtw/_fastdtw.pyx":308 * if we.cost_idx_left != -1 else INFINITY * d_up = cost[we.cost_idx_up].cost \ * if we.cost_idx_up != -1 else INFINITY # <<<<<<<<<<<<<< @@ -4568,28 +4869,28 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ if (((__pyx_v_we.cost_idx_up != -1L) != 0)) { - /* "fastdtw/_fastdtw.pyx":300 + /* "fastdtw/_fastdtw.pyx":307 * d_left = cost[we.cost_idx_left].cost \ * if we.cost_idx_left != -1 else INFINITY * d_up = cost[we.cost_idx_up].cost \ # <<<<<<<<<<<<<< * if we.cost_idx_up != -1 else INFINITY * d_corner = cost[we.cost_idx_corner].cost \ */ - __pyx_t_1 = (__pyx_v_cost[__pyx_v_we.cost_idx_up]).cost; + __pyx_t_24 = (__pyx_v_cost[__pyx_v_we.cost_idx_up]).cost; } else { - /* "fastdtw/_fastdtw.pyx":301 + /* "fastdtw/_fastdtw.pyx":308 * if we.cost_idx_left != -1 else INFINITY * d_up = cost[we.cost_idx_up].cost \ * if we.cost_idx_up != -1 else INFINITY # <<<<<<<<<<<<<< * d_corner = cost[we.cost_idx_corner].cost \ * if we.cost_idx_corner != -1 else INFINITY */ - __pyx_t_1 = INFINITY; + __pyx_t_24 = NPY_INFINITY; } - __pyx_v_d_up = __pyx_t_1; + __pyx_v_d_up = __pyx_t_24; - /* "fastdtw/_fastdtw.pyx":303 + /* "fastdtw/_fastdtw.pyx":310 * if we.cost_idx_up != -1 else INFINITY * d_corner = cost[we.cost_idx_corner].cost \ * if we.cost_idx_corner != -1 else INFINITY # <<<<<<<<<<<<<< @@ -4598,28 +4899,28 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ if (((__pyx_v_we.cost_idx_corner != -1L) != 0)) { - /* "fastdtw/_fastdtw.pyx":302 + /* "fastdtw/_fastdtw.pyx":309 * d_up = cost[we.cost_idx_up].cost \ * if we.cost_idx_up != -1 else INFINITY * d_corner = cost[we.cost_idx_corner].cost \ # <<<<<<<<<<<<<< * if we.cost_idx_corner != -1 else INFINITY * */ - __pyx_t_1 = (__pyx_v_cost[__pyx_v_we.cost_idx_corner]).cost; + __pyx_t_24 = (__pyx_v_cost[__pyx_v_we.cost_idx_corner]).cost; } else { - /* "fastdtw/_fastdtw.pyx":303 + /* "fastdtw/_fastdtw.pyx":310 * if we.cost_idx_up != -1 else INFINITY * d_corner = cost[we.cost_idx_corner].cost \ * if we.cost_idx_corner != -1 else INFINITY # <<<<<<<<<<<<<< * * if d_up < d_left and d_up < d_corner: */ - __pyx_t_1 = INFINITY; + __pyx_t_24 = NPY_INFINITY; } - __pyx_v_d_corner = __pyx_t_1; + __pyx_v_d_corner = __pyx_t_24; - /* "fastdtw/_fastdtw.pyx":305 + /* "fastdtw/_fastdtw.pyx":312 * if we.cost_idx_corner != -1 else INFINITY * * if d_up < d_left and d_up < d_corner: # <<<<<<<<<<<<<< @@ -4637,7 +4938,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_L23_bool_binop_done:; if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":306 + /* "fastdtw/_fastdtw.pyx":313 * * if d_up < d_left and d_up < d_corner: * cost[idx + 1].cost = d_up + dt # <<<<<<<<<<<<<< @@ -4646,17 +4947,17 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ (__pyx_v_cost[(__pyx_v_idx + 1)]).cost = (__pyx_v_d_up + __pyx_v_dt); - /* "fastdtw/_fastdtw.pyx":307 + /* "fastdtw/_fastdtw.pyx":314 * if d_up < d_left and d_up < d_corner: * cost[idx + 1].cost = d_up + dt * cost[idx + 1].prev_idx = we.cost_idx_up # <<<<<<<<<<<<<< * elif d_left < d_corner: * cost[idx + 1].cost = d_left + dt */ - __pyx_t_19 = __pyx_v_we.cost_idx_up; - (__pyx_v_cost[(__pyx_v_idx + 1)]).prev_idx = __pyx_t_19; + __pyx_t_18 = __pyx_v_we.cost_idx_up; + (__pyx_v_cost[(__pyx_v_idx + 1)]).prev_idx = __pyx_t_18; - /* "fastdtw/_fastdtw.pyx":305 + /* "fastdtw/_fastdtw.pyx":312 * if we.cost_idx_corner != -1 else INFINITY * * if d_up < d_left and d_up < d_corner: # <<<<<<<<<<<<<< @@ -4666,7 +4967,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L22; } - /* "fastdtw/_fastdtw.pyx":308 + /* "fastdtw/_fastdtw.pyx":315 * cost[idx + 1].cost = d_up + dt * cost[idx + 1].prev_idx = we.cost_idx_up * elif d_left < d_corner: # <<<<<<<<<<<<<< @@ -4676,7 +4977,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_7 = ((__pyx_v_d_left < __pyx_v_d_corner) != 0); if (__pyx_t_7) { - /* "fastdtw/_fastdtw.pyx":309 + /* "fastdtw/_fastdtw.pyx":316 * cost[idx + 1].prev_idx = we.cost_idx_up * elif d_left < d_corner: * cost[idx + 1].cost = d_left + dt # <<<<<<<<<<<<<< @@ -4685,17 +4986,17 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ (__pyx_v_cost[(__pyx_v_idx + 1)]).cost = (__pyx_v_d_left + __pyx_v_dt); - /* "fastdtw/_fastdtw.pyx":310 + /* "fastdtw/_fastdtw.pyx":317 * elif d_left < d_corner: * cost[idx + 1].cost = d_left + dt * cost[idx + 1].prev_idx = we.cost_idx_left # <<<<<<<<<<<<<< * else: * cost[idx + 1].cost = d_corner + dt */ - __pyx_t_19 = __pyx_v_we.cost_idx_left; - (__pyx_v_cost[(__pyx_v_idx + 1)]).prev_idx = __pyx_t_19; + __pyx_t_18 = __pyx_v_we.cost_idx_left; + (__pyx_v_cost[(__pyx_v_idx + 1)]).prev_idx = __pyx_t_18; - /* "fastdtw/_fastdtw.pyx":308 + /* "fastdtw/_fastdtw.pyx":315 * cost[idx + 1].cost = d_up + dt * cost[idx + 1].prev_idx = we.cost_idx_up * elif d_left < d_corner: # <<<<<<<<<<<<<< @@ -4705,7 +5006,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ goto __pyx_L22; } - /* "fastdtw/_fastdtw.pyx":312 + /* "fastdtw/_fastdtw.pyx":319 * cost[idx + 1].prev_idx = we.cost_idx_left * else: * cost[idx + 1].cost = d_corner + dt # <<<<<<<<<<<<<< @@ -4715,20 +5016,20 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ /*else*/ { (__pyx_v_cost[(__pyx_v_idx + 1)]).cost = (__pyx_v_d_corner + __pyx_v_dt); - /* "fastdtw/_fastdtw.pyx":313 + /* "fastdtw/_fastdtw.pyx":320 * else: * cost[idx + 1].cost = d_corner + dt * cost[idx + 1].prev_idx = we.cost_idx_corner # <<<<<<<<<<<<<< * * # recreate the path */ - __pyx_t_19 = __pyx_v_we.cost_idx_corner; - (__pyx_v_cost[(__pyx_v_idx + 1)]).prev_idx = __pyx_t_19; + __pyx_t_18 = __pyx_v_we.cost_idx_corner; + (__pyx_v_cost[(__pyx_v_idx + 1)]).prev_idx = __pyx_t_18; } __pyx_L22:; } - /* "fastdtw/_fastdtw.pyx":316 + /* "fastdtw/_fastdtw.pyx":323 * * # recreate the path * idx = cost_len - 1 # <<<<<<<<<<<<<< @@ -4737,7 +5038,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_idx = (__pyx_v_cost_len - 1); - /* "fastdtw/_fastdtw.pyx":317 + /* "fastdtw/_fastdtw.pyx":324 * # recreate the path * idx = cost_len - 1 * (&path_len)[0] = 0 # <<<<<<<<<<<<<< @@ -4746,7 +5047,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ ((&__pyx_v_path_len)[0]) = 0; - /* "fastdtw/_fastdtw.pyx":318 + /* "fastdtw/_fastdtw.pyx":325 * idx = cost_len - 1 * (&path_len)[0] = 0 * while idx != 0: # <<<<<<<<<<<<<< @@ -4757,7 +5058,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_7 = ((__pyx_v_idx != 0) != 0); if (!__pyx_t_7) break; - /* "fastdtw/_fastdtw.pyx":319 + /* "fastdtw/_fastdtw.pyx":326 * (&path_len)[0] = 0 * while idx != 0: * we = window[idx - 1] # <<<<<<<<<<<<<< @@ -4766,27 +5067,27 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_we = (__pyx_v_window[(__pyx_v_idx - 1)]); - /* "fastdtw/_fastdtw.pyx":320 + /* "fastdtw/_fastdtw.pyx":327 * while idx != 0: * we = window[idx - 1] * path[path_len].x_idx = we.x_idx # <<<<<<<<<<<<<< * path[path_len].y_idx = we.y_idx * (&path_len)[0] += 1 */ - __pyx_t_15 = __pyx_v_we.x_idx; - (__pyx_v_path[__pyx_v_path_len]).x_idx = __pyx_t_15; + __pyx_t_11 = __pyx_v_we.x_idx; + (__pyx_v_path[__pyx_v_path_len]).x_idx = __pyx_t_11; - /* "fastdtw/_fastdtw.pyx":321 + /* "fastdtw/_fastdtw.pyx":328 * we = window[idx - 1] * path[path_len].x_idx = we.x_idx * path[path_len].y_idx = we.y_idx # <<<<<<<<<<<<<< * (&path_len)[0] += 1 * idx = cost[idx].prev_idx */ - __pyx_t_15 = __pyx_v_we.y_idx; - (__pyx_v_path[__pyx_v_path_len]).y_idx = __pyx_t_15; + __pyx_t_11 = __pyx_v_we.y_idx; + (__pyx_v_path[__pyx_v_path_len]).y_idx = __pyx_t_11; - /* "fastdtw/_fastdtw.pyx":322 + /* "fastdtw/_fastdtw.pyx":329 * path[path_len].x_idx = we.x_idx * path[path_len].y_idx = we.y_idx * (&path_len)[0] += 1 # <<<<<<<<<<<<<< @@ -4797,18 +5098,18 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_t_26 = 0; (__pyx_t_25[__pyx_t_26]) = ((__pyx_t_25[__pyx_t_26]) + 1); - /* "fastdtw/_fastdtw.pyx":323 + /* "fastdtw/_fastdtw.pyx":330 * path[path_len].y_idx = we.y_idx * (&path_len)[0] += 1 * idx = cost[idx].prev_idx # <<<<<<<<<<<<<< * * # reverse path */ - __pyx_t_15 = (__pyx_v_cost[__pyx_v_idx]).prev_idx; - __pyx_v_idx = __pyx_t_15; + __pyx_t_11 = (__pyx_v_cost[__pyx_v_idx]).prev_idx; + __pyx_v_idx = __pyx_t_11; } - /* "fastdtw/_fastdtw.pyx":326 + /* "fastdtw/_fastdtw.pyx":333 * * # reverse path * for i in range(path_len / 2): # using c division to round down # <<<<<<<<<<<<<< @@ -4816,10 +5117,10 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ * path[path_len - 1 - i] = path[i] */ __pyx_t_26 = (((long)__pyx_v_path_len) / 2); - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_26; __pyx_t_15+=1) { - __pyx_v_i = __pyx_t_15; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_26; __pyx_t_11+=1) { + __pyx_v_i = __pyx_t_11; - /* "fastdtw/_fastdtw.pyx":327 + /* "fastdtw/_fastdtw.pyx":334 * # reverse path * for i in range(path_len / 2): # using c division to round down * temp = path[path_len - 1 - i] # <<<<<<<<<<<<<< @@ -4828,7 +5129,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ __pyx_v_temp = (__pyx_v_path[((__pyx_v_path_len - 1) - __pyx_v_i)]); - /* "fastdtw/_fastdtw.pyx":328 + /* "fastdtw/_fastdtw.pyx":335 * for i in range(path_len / 2): # using c division to round down * temp = path[path_len - 1 - i] * path[path_len - 1 - i] = path[i] # <<<<<<<<<<<<<< @@ -4837,7 +5138,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ */ (__pyx_v_path[((__pyx_v_path_len - 1) - __pyx_v_i)]) = (__pyx_v_path[__pyx_v_i]); - /* "fastdtw/_fastdtw.pyx":329 + /* "fastdtw/_fastdtw.pyx":336 * temp = path[path_len - 1 - i] * path[path_len - 1 - i] = path[i] * path[i] = temp # <<<<<<<<<<<<<< @@ -4847,7 +5148,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ (__pyx_v_path[__pyx_v_i]) = __pyx_v_temp; } - /* "fastdtw/_fastdtw.pyx":331 + /* "fastdtw/_fastdtw.pyx":338 * path[i] = temp * * return cost[cost_len - 1].cost # <<<<<<<<<<<<<< @@ -4857,7 +5158,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ __pyx_r = (__pyx_v_cost[(__pyx_v_cost_len - 1)]).cost; goto __pyx_L0; - /* "fastdtw/_fastdtw.pyx":226 + /* "fastdtw/_fastdtw.pyx":233 * * * cdef double __dtw(x, y, vector[WindowElement] &window, dist, # <<<<<<<<<<<<<< @@ -4887,7 +5188,7 @@ static double __pyx_f_7fastdtw_8_fastdtw___dtw(PyObject *__pyx_v_x, PyObject *__ return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":334 +/* "fastdtw/_fastdtw.pyx":341 * * * cdef __reduce_by_half(x): # <<<<<<<<<<<<<< @@ -4917,7 +5218,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x PyObject *__pyx_t_15 = NULL; __Pyx_RefNannySetupContext("__reduce_by_half", 0); - /* "fastdtw/_fastdtw.pyx":339 + /* "fastdtw/_fastdtw.pyx":346 * ''' * cdef int i, mx * try: # <<<<<<<<<<<<<< @@ -4933,35 +5234,35 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "fastdtw/_fastdtw.pyx":340 + /* "fastdtw/_fastdtw.pyx":347 * cdef int i, mx * try: * mx = x.shape[0] - x.shape[0] % 2 # <<<<<<<<<<<<<< * return (x[:mx:2] + x[1:mx:2]) / 2 * except AttributeError: */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L3_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 340, __pyx_L3_error) + __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 347, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L3_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 340, __pyx_L3_error) + __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 347, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_RemainderObjC(__pyx_t_6, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L3_error) + __pyx_t_4 = __Pyx_PyInt_RemainderObjC(__pyx_t_6, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Subtract(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 340, __pyx_L3_error) + __pyx_t_6 = PyNumber_Subtract(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 347, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L3_error) + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L3_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_mx = __pyx_t_7; - /* "fastdtw/_fastdtw.pyx":341 + /* "fastdtw/_fastdtw.pyx":348 * try: * mx = x.shape[0] - x.shape[0] % 2 * return (x[:mx:2] + x[1:mx:2]) / 2 # <<<<<<<<<<<<<< @@ -4969,34 +5270,34 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x * return [(x[i] + x[1+i]) / 2 for i in range(0, len(x) - len(x) % 2, 2)] */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_mx); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_mx); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PySlice_New(Py_None, __pyx_t_6, __pyx_int_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_4 = PySlice_New(Py_None, __pyx_t_6, __pyx_int_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_v_x, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_6 = PyObject_GetItem(__pyx_v_x, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_mx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_mx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PySlice_New(__pyx_int_1, __pyx_t_4, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_5 = PySlice_New(__pyx_int_1, __pyx_t_4, __pyx_int_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_GetItem(__pyx_v_x, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_4 = PyObject_GetItem(__pyx_v_x, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Add(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_5 = PyNumber_Add(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_5, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 341, __pyx_L3_error) + __pyx_t_4 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_5, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L7_try_return; - /* "fastdtw/_fastdtw.pyx":339 + /* "fastdtw/_fastdtw.pyx":346 * ''' * cdef int i, mx * try: # <<<<<<<<<<<<<< @@ -5010,7 +5311,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "fastdtw/_fastdtw.pyx":342 + /* "fastdtw/_fastdtw.pyx":349 * mx = x.shape[0] - x.shape[0] % 2 * return (x[:mx:2] + x[1:mx:2]) / 2 * except AttributeError: # <<<<<<<<<<<<<< @@ -5020,12 +5321,12 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_7) { __Pyx_AddTraceback("fastdtw._fastdtw.__reduce_by_half", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 342, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 349, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); - /* "fastdtw/_fastdtw.pyx":343 + /* "fastdtw/_fastdtw.pyx":350 * return (x[:mx:2] + x[1:mx:2]) / 2 * except AttributeError: * return [(x[i] + x[1+i]) / 2 for i in range(0, len(x) - len(x) % 2, 2)] # <<<<<<<<<<<<<< @@ -5033,26 +5334,26 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 343, __pyx_L5_except_error) + __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 350, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 343, __pyx_L5_except_error) - __pyx_t_10 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 343, __pyx_L5_except_error) + __pyx_t_9 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 350, __pyx_L5_except_error) + __pyx_t_10 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 350, __pyx_L5_except_error) __pyx_t_11 = (__pyx_t_9 - (__pyx_t_10 % 2)); for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_11; __pyx_t_7+=2) { __pyx_v_i = __pyx_t_7; - __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 343, __pyx_L5_except_error) + __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 350, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = (1 + __pyx_v_i); - __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_x, __pyx_t_13, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 343, __pyx_L5_except_error) + __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_x, __pyx_t_13, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 350, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_14); - __pyx_t_15 = PyNumber_Add(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 343, __pyx_L5_except_error) + __pyx_t_15 = PyNumber_Add(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 350, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_15, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 343, __pyx_L5_except_error) + __pyx_t_14 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_15, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 350, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 343, __pyx_L5_except_error) + if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 350, __pyx_L5_except_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __pyx_r = __pyx_t_8; @@ -5065,7 +5366,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "fastdtw/_fastdtw.pyx":339 + /* "fastdtw/_fastdtw.pyx":346 * ''' * cdef int i, mx * try: # <<<<<<<<<<<<<< @@ -5094,7 +5395,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x goto __pyx_L0; } - /* "fastdtw/_fastdtw.pyx":334 + /* "fastdtw/_fastdtw.pyx":341 * * * cdef __reduce_by_half(x): # <<<<<<<<<<<<<< @@ -5119,7 +5420,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___reduce_by_half(PyObject *__pyx_v_x return __pyx_r; } -/* "fastdtw/_fastdtw.pyx":346 +/* "fastdtw/_fastdtw.pyx":353 * * * cdef __expand_window(PathElement *path, int path_len, # <<<<<<<<<<<<<< @@ -5164,19 +5465,19 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast int __pyx_t_12; __Pyx_RefNannySetupContext("__expand_window", 0); - /* "fastdtw/_fastdtw.pyx":367 + /* "fastdtw/_fastdtw.pyx":374 * * cdef int len_x, len_y * len_x, len_y = len(x), len(y) # <<<<<<<<<<<<<< * * # step 1 */ - __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 367, __pyx_L1_error) - __pyx_t_2 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 374, __pyx_L1_error) + __pyx_t_2 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 374, __pyx_L1_error) __pyx_v_len_x = __pyx_t_1; __pyx_v_len_y = __pyx_t_2; - /* "fastdtw/_fastdtw.pyx":370 + /* "fastdtw/_fastdtw.pyx":377 * * # step 1 * max_x_idx = path[path_len - 1].x_idx # <<<<<<<<<<<<<< @@ -5186,7 +5487,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_3 = (__pyx_v_path[(__pyx_v_path_len - 1)]).x_idx; __pyx_v_max_x_idx = __pyx_t_3; - /* "fastdtw/_fastdtw.pyx":371 + /* "fastdtw/_fastdtw.pyx":378 * # step 1 * max_x_idx = path[path_len - 1].x_idx * max_y_idx = path[path_len - 1].y_idx # <<<<<<<<<<<<<< @@ -5196,7 +5497,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_3 = (__pyx_v_path[(__pyx_v_path_len - 1)]).y_idx; __pyx_v_max_y_idx = __pyx_t_3; - /* "fastdtw/_fastdtw.pyx":373 + /* "fastdtw/_fastdtw.pyx":380 * max_y_idx = path[path_len - 1].y_idx * * prv_y_idx = 0 # <<<<<<<<<<<<<< @@ -5205,7 +5506,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_prv_y_idx = 0; - /* "fastdtw/_fastdtw.pyx":374 + /* "fastdtw/_fastdtw.pyx":381 * * prv_y_idx = 0 * cur_x_idx = -1 # <<<<<<<<<<<<<< @@ -5214,7 +5515,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_cur_x_idx = -1; - /* "fastdtw/_fastdtw.pyx":377 + /* "fastdtw/_fastdtw.pyx":384 * * cdef vector[LowHigh] ybounds1 * ybounds1.resize(max_x_idx + 1) # <<<<<<<<<<<<<< @@ -5225,10 +5526,10 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_v_ybounds1.resize((__pyx_v_max_x_idx + 1)); } catch(...) { __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 377, __pyx_L1_error) + __PYX_ERR(0, 384, __pyx_L1_error) } - /* "fastdtw/_fastdtw.pyx":379 + /* "fastdtw/_fastdtw.pyx":386 * ybounds1.resize(max_x_idx + 1) * * for idx in range(path_len): # <<<<<<<<<<<<<< @@ -5239,7 +5540,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_idx = __pyx_t_4; - /* "fastdtw/_fastdtw.pyx":380 + /* "fastdtw/_fastdtw.pyx":387 * * for idx in range(path_len): * x_idx = path[idx].x_idx # <<<<<<<<<<<<<< @@ -5249,7 +5550,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_5 = (__pyx_v_path[__pyx_v_idx]).x_idx; __pyx_v_x_idx = __pyx_t_5; - /* "fastdtw/_fastdtw.pyx":381 + /* "fastdtw/_fastdtw.pyx":388 * for idx in range(path_len): * x_idx = path[idx].x_idx * y_idx = path[idx].y_idx # <<<<<<<<<<<<<< @@ -5259,7 +5560,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_5 = (__pyx_v_path[__pyx_v_idx]).y_idx; __pyx_v_y_idx = __pyx_t_5; - /* "fastdtw/_fastdtw.pyx":383 + /* "fastdtw/_fastdtw.pyx":390 * y_idx = path[idx].y_idx * * if x_idx != cur_x_idx: # <<<<<<<<<<<<<< @@ -5269,7 +5570,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_6 = ((__pyx_v_x_idx != __pyx_v_cur_x_idx) != 0); if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":384 + /* "fastdtw/_fastdtw.pyx":391 * * if x_idx != cur_x_idx: * cur_x_idx = x_idx # <<<<<<<<<<<<<< @@ -5278,7 +5579,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_cur_x_idx = __pyx_v_x_idx; - /* "fastdtw/_fastdtw.pyx":385 + /* "fastdtw/_fastdtw.pyx":392 * if x_idx != cur_x_idx: * cur_x_idx = x_idx * ybounds1[x_idx].low = y_idx # <<<<<<<<<<<<<< @@ -5287,7 +5588,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds1[__pyx_v_x_idx]).low = __pyx_v_y_idx; - /* "fastdtw/_fastdtw.pyx":387 + /* "fastdtw/_fastdtw.pyx":394 * ybounds1[x_idx].low = y_idx * * if cur_x_idx > 0: # <<<<<<<<<<<<<< @@ -5297,7 +5598,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_6 = ((__pyx_v_cur_x_idx > 0) != 0); if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":388 + /* "fastdtw/_fastdtw.pyx":395 * * if cur_x_idx > 0: * ybounds1[x_idx - 1].high = prv_y_idx # <<<<<<<<<<<<<< @@ -5306,7 +5607,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds1[(__pyx_v_x_idx - 1)]).high = __pyx_v_prv_y_idx; - /* "fastdtw/_fastdtw.pyx":387 + /* "fastdtw/_fastdtw.pyx":394 * ybounds1[x_idx].low = y_idx * * if cur_x_idx > 0: # <<<<<<<<<<<<<< @@ -5315,7 +5616,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ } - /* "fastdtw/_fastdtw.pyx":383 + /* "fastdtw/_fastdtw.pyx":390 * y_idx = path[idx].y_idx * * if x_idx != cur_x_idx: # <<<<<<<<<<<<<< @@ -5324,7 +5625,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ } - /* "fastdtw/_fastdtw.pyx":390 + /* "fastdtw/_fastdtw.pyx":397 * ybounds1[x_idx - 1].high = prv_y_idx * * prv_y_idx = y_idx # <<<<<<<<<<<<<< @@ -5334,7 +5635,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_v_prv_y_idx = __pyx_v_y_idx; } - /* "fastdtw/_fastdtw.pyx":392 + /* "fastdtw/_fastdtw.pyx":399 * prv_y_idx = y_idx * * ybounds1[max_x_idx].high = prv_y_idx # <<<<<<<<<<<<<< @@ -5343,7 +5644,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds1[__pyx_v_max_x_idx]).high = __pyx_v_prv_y_idx; - /* "fastdtw/_fastdtw.pyx":395 + /* "fastdtw/_fastdtw.pyx":402 * * # step 2 * cdef int len_ybounds2 = max_x_idx + radius + 1 # <<<<<<<<<<<<<< @@ -5352,7 +5653,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_len_ybounds2 = ((__pyx_v_max_x_idx + __pyx_v_radius) + 1); - /* "fastdtw/_fastdtw.pyx":397 + /* "fastdtw/_fastdtw.pyx":404 * cdef int len_ybounds2 = max_x_idx + radius + 1 * cdef vector[LowHigh] ybounds2 * ybounds2.resize(len_ybounds2) # <<<<<<<<<<<<<< @@ -5363,10 +5664,10 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_v_ybounds2.resize(__pyx_v_len_ybounds2); } catch(...) { __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 397, __pyx_L1_error) + __PYX_ERR(0, 404, __pyx_L1_error) } - /* "fastdtw/_fastdtw.pyx":399 + /* "fastdtw/_fastdtw.pyx":406 * ybounds2.resize(len_ybounds2) * * for x_idx in range(max_x_idx + 1): # <<<<<<<<<<<<<< @@ -5377,7 +5678,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_7; __pyx_t_3+=1) { __pyx_v_x_idx = __pyx_t_3; - /* "fastdtw/_fastdtw.pyx":400 + /* "fastdtw/_fastdtw.pyx":407 * * for x_idx in range(max_x_idx + 1): * temp_min_x_idx = max(0, x_idx - radius) # <<<<<<<<<<<<<< @@ -5393,7 +5694,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } __pyx_v_temp_min_x_idx = __pyx_t_9; - /* "fastdtw/_fastdtw.pyx":402 + /* "fastdtw/_fastdtw.pyx":409 * temp_min_x_idx = max(0, x_idx - radius) * ybounds2[x_idx].low = \ * max(0, ybounds1[temp_min_x_idx].low - radius) # <<<<<<<<<<<<<< @@ -5408,7 +5709,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_8 = __pyx_t_9; } - /* "fastdtw/_fastdtw.pyx":401 + /* "fastdtw/_fastdtw.pyx":408 * for x_idx in range(max_x_idx + 1): * temp_min_x_idx = max(0, x_idx - radius) * ybounds2[x_idx].low = \ # <<<<<<<<<<<<<< @@ -5417,7 +5718,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds2[__pyx_v_x_idx]).low = __pyx_t_8; - /* "fastdtw/_fastdtw.pyx":404 + /* "fastdtw/_fastdtw.pyx":411 * max(0, ybounds1[temp_min_x_idx].low - radius) * * temp_max_x_idx = min(max_x_idx, x_idx + radius) # <<<<<<<<<<<<<< @@ -5433,7 +5734,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } __pyx_v_temp_max_x_idx = __pyx_t_10; - /* "fastdtw/_fastdtw.pyx":406 + /* "fastdtw/_fastdtw.pyx":413 * temp_max_x_idx = min(max_x_idx, x_idx + radius) * ybounds2[x_idx].high = \ * min(max_y_idx + radius, ybounds1[temp_max_x_idx].high + radius) # <<<<<<<<<<<<<< @@ -5448,7 +5749,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_5 = __pyx_t_4; } - /* "fastdtw/_fastdtw.pyx":405 + /* "fastdtw/_fastdtw.pyx":412 * * temp_max_x_idx = min(max_x_idx, x_idx + radius) * ybounds2[x_idx].high = \ # <<<<<<<<<<<<<< @@ -5458,7 +5759,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast (__pyx_v_ybounds2[__pyx_v_x_idx]).high = __pyx_t_5; } - /* "fastdtw/_fastdtw.pyx":408 + /* "fastdtw/_fastdtw.pyx":415 * min(max_y_idx + radius, ybounds1[temp_max_x_idx].high + radius) * * for x_idx in range(max_x_idx + 1, max_x_idx + radius + 1): # <<<<<<<<<<<<<< @@ -5469,7 +5770,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast for (__pyx_t_3 = (__pyx_v_max_x_idx + 1); __pyx_t_3 < __pyx_t_7; __pyx_t_3+=1) { __pyx_v_x_idx = __pyx_t_3; - /* "fastdtw/_fastdtw.pyx":409 + /* "fastdtw/_fastdtw.pyx":416 * * for x_idx in range(max_x_idx + 1, max_x_idx + radius + 1): * ybounds2[x_idx].low = ybounds2[x_idx - 1].low # <<<<<<<<<<<<<< @@ -5479,7 +5780,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_5 = (__pyx_v_ybounds2[(__pyx_v_x_idx - 1)]).low; (__pyx_v_ybounds2[__pyx_v_x_idx]).low = __pyx_t_5; - /* "fastdtw/_fastdtw.pyx":410 + /* "fastdtw/_fastdtw.pyx":417 * for x_idx in range(max_x_idx + 1, max_x_idx + radius + 1): * ybounds2[x_idx].low = ybounds2[x_idx - 1].low * ybounds2[x_idx].high = ybounds2[x_idx - 1].high # <<<<<<<<<<<<<< @@ -5490,7 +5791,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast (__pyx_v_ybounds2[__pyx_v_x_idx]).high = __pyx_t_5; } - /* "fastdtw/_fastdtw.pyx":413 + /* "fastdtw/_fastdtw.pyx":420 * * # step 3 * cdef int len_ybounds3 = min(len_x, 2 * len_ybounds2) # <<<<<<<<<<<<<< @@ -5506,7 +5807,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } __pyx_v_len_ybounds3 = __pyx_t_8; - /* "fastdtw/_fastdtw.pyx":415 + /* "fastdtw/_fastdtw.pyx":422 * cdef int len_ybounds3 = min(len_x, 2 * len_ybounds2) * cdef vector[LowHigh] ybounds3 * ybounds3.resize(len_ybounds3) # <<<<<<<<<<<<<< @@ -5517,10 +5818,10 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_v_ybounds3.resize(__pyx_v_len_ybounds3); } catch(...) { __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 415, __pyx_L1_error) + __PYX_ERR(0, 422, __pyx_L1_error) } - /* "fastdtw/_fastdtw.pyx":417 + /* "fastdtw/_fastdtw.pyx":424 * ybounds3.resize(len_ybounds3) * * cdef int window_size = 0 # <<<<<<<<<<<<<< @@ -5529,7 +5830,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_window_size = 0; - /* "fastdtw/_fastdtw.pyx":419 + /* "fastdtw/_fastdtw.pyx":426 * cdef int window_size = 0 * * for x_idx in range(max_x_idx + radius + 1): # <<<<<<<<<<<<<< @@ -5540,7 +5841,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_8; __pyx_t_3+=1) { __pyx_v_x_idx = __pyx_t_3; - /* "fastdtw/_fastdtw.pyx":420 + /* "fastdtw/_fastdtw.pyx":427 * * for x_idx in range(max_x_idx + radius + 1): * if 2 * x_idx < len_x: # <<<<<<<<<<<<<< @@ -5550,7 +5851,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_6 = (((2 * __pyx_v_x_idx) < __pyx_v_len_x) != 0); if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":421 + /* "fastdtw/_fastdtw.pyx":428 * for x_idx in range(max_x_idx + radius + 1): * if 2 * x_idx < len_x: * ybounds3[2 * x_idx].low = 2 * ybounds2[x_idx].low # <<<<<<<<<<<<<< @@ -5559,7 +5860,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds3[(2 * __pyx_v_x_idx)]).low = (2 * (__pyx_v_ybounds2[__pyx_v_x_idx]).low); - /* "fastdtw/_fastdtw.pyx":423 + /* "fastdtw/_fastdtw.pyx":430 * ybounds3[2 * x_idx].low = 2 * ybounds2[x_idx].low * ybounds3[2 * x_idx].high = \ * min(len_y - 1, 2 * ybounds2[x_idx].high + 1) # <<<<<<<<<<<<<< @@ -5574,7 +5875,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_11 = __pyx_t_9; } - /* "fastdtw/_fastdtw.pyx":422 + /* "fastdtw/_fastdtw.pyx":429 * if 2 * x_idx < len_x: * ybounds3[2 * x_idx].low = 2 * ybounds2[x_idx].low * ybounds3[2 * x_idx].high = \ # <<<<<<<<<<<<<< @@ -5583,7 +5884,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds3[(2 * __pyx_v_x_idx)]).high = __pyx_t_11; - /* "fastdtw/_fastdtw.pyx":425 + /* "fastdtw/_fastdtw.pyx":432 * min(len_y - 1, 2 * ybounds2[x_idx].high + 1) * * window_size += \ # <<<<<<<<<<<<<< @@ -5592,7 +5893,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_window_size = (__pyx_v_window_size + (((__pyx_v_ybounds3[(2 * __pyx_v_x_idx)]).high - (__pyx_v_ybounds3[(2 * __pyx_v_x_idx)]).low) + 1)); - /* "fastdtw/_fastdtw.pyx":420 + /* "fastdtw/_fastdtw.pyx":427 * * for x_idx in range(max_x_idx + radius + 1): * if 2 * x_idx < len_x: # <<<<<<<<<<<<<< @@ -5601,7 +5902,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ } - /* "fastdtw/_fastdtw.pyx":428 + /* "fastdtw/_fastdtw.pyx":435 * ybounds3[2 * x_idx].high - ybounds3[2 * x_idx].low + 1 * * if 2 * x_idx + 1 < len_x: # <<<<<<<<<<<<<< @@ -5611,7 +5912,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_6 = ((((2 * __pyx_v_x_idx) + 1) < __pyx_v_len_x) != 0); if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":429 + /* "fastdtw/_fastdtw.pyx":436 * * if 2 * x_idx + 1 < len_x: * ybounds3[2 * x_idx + 1].low = 2 * ybounds2[x_idx].low # <<<<<<<<<<<<<< @@ -5620,7 +5921,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds3[((2 * __pyx_v_x_idx) + 1)]).low = (2 * (__pyx_v_ybounds2[__pyx_v_x_idx]).low); - /* "fastdtw/_fastdtw.pyx":431 + /* "fastdtw/_fastdtw.pyx":438 * ybounds3[2 * x_idx + 1].low = 2 * ybounds2[x_idx].low * ybounds3[2 * x_idx + 1].high = \ * min(len_y - 1, 2 * ybounds2[x_idx].high + 1) # <<<<<<<<<<<<<< @@ -5635,7 +5936,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_9 = __pyx_t_7; } - /* "fastdtw/_fastdtw.pyx":430 + /* "fastdtw/_fastdtw.pyx":437 * if 2 * x_idx + 1 < len_x: * ybounds3[2 * x_idx + 1].low = 2 * ybounds2[x_idx].low * ybounds3[2 * x_idx + 1].high = \ # <<<<<<<<<<<<<< @@ -5644,7 +5945,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_ybounds3[((2 * __pyx_v_x_idx) + 1)]).high = __pyx_t_9; - /* "fastdtw/_fastdtw.pyx":433 + /* "fastdtw/_fastdtw.pyx":440 * min(len_y - 1, 2 * ybounds2[x_idx].high + 1) * * window_size += \ # <<<<<<<<<<<<<< @@ -5653,7 +5954,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_window_size = (__pyx_v_window_size + (((__pyx_v_ybounds3[((2 * __pyx_v_x_idx) + 1)]).high - (__pyx_v_ybounds3[((2 * __pyx_v_x_idx) + 1)]).low) + 1)); - /* "fastdtw/_fastdtw.pyx":428 + /* "fastdtw/_fastdtw.pyx":435 * ybounds3[2 * x_idx].high - ybounds3[2 * x_idx].low + 1 * * if 2 * x_idx + 1 < len_x: # <<<<<<<<<<<<<< @@ -5663,7 +5964,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } } - /* "fastdtw/_fastdtw.pyx":437 + /* "fastdtw/_fastdtw.pyx":444 * * # step 4 * window.resize(window_size) # <<<<<<<<<<<<<< @@ -5674,10 +5975,10 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_v_window.resize(__pyx_v_window_size); } catch(...) { __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 437, __pyx_L1_error) + __PYX_ERR(0, 444, __pyx_L1_error) } - /* "fastdtw/_fastdtw.pyx":439 + /* "fastdtw/_fastdtw.pyx":446 * window.resize(window_size) * * idx = 0 # <<<<<<<<<<<<<< @@ -5686,7 +5987,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_idx = 0; - /* "fastdtw/_fastdtw.pyx":440 + /* "fastdtw/_fastdtw.pyx":447 * * idx = 0 * for x_idx in range(len_ybounds3): # <<<<<<<<<<<<<< @@ -5697,7 +5998,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { __pyx_v_x_idx = __pyx_t_5; - /* "fastdtw/_fastdtw.pyx":442 + /* "fastdtw/_fastdtw.pyx":449 * for x_idx in range(len_ybounds3): * * low_y_idx = ybounds3[x_idx].low # <<<<<<<<<<<<<< @@ -5707,7 +6008,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_10 = (__pyx_v_ybounds3[__pyx_v_x_idx]).low; __pyx_v_low_y_idx = __pyx_t_10; - /* "fastdtw/_fastdtw.pyx":443 + /* "fastdtw/_fastdtw.pyx":450 * * low_y_idx = ybounds3[x_idx].low * hgh_y_idx = ybounds3[x_idx].high # <<<<<<<<<<<<<< @@ -5717,7 +6018,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_10 = (__pyx_v_ybounds3[__pyx_v_x_idx]).high; __pyx_v_hgh_y_idx = __pyx_t_10; - /* "fastdtw/_fastdtw.pyx":445 + /* "fastdtw/_fastdtw.pyx":452 * hgh_y_idx = ybounds3[x_idx].high * * for y_idx in range(low_y_idx, hgh_y_idx + 1): # <<<<<<<<<<<<<< @@ -5728,7 +6029,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast for (__pyx_t_10 = __pyx_v_low_y_idx; __pyx_t_10 < __pyx_t_8; __pyx_t_10+=1) { __pyx_v_y_idx = __pyx_t_10; - /* "fastdtw/_fastdtw.pyx":447 + /* "fastdtw/_fastdtw.pyx":454 * for y_idx in range(low_y_idx, hgh_y_idx + 1): * * we.x_idx = x_idx # <<<<<<<<<<<<<< @@ -5737,7 +6038,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.x_idx = __pyx_v_x_idx; - /* "fastdtw/_fastdtw.pyx":448 + /* "fastdtw/_fastdtw.pyx":455 * * we.x_idx = x_idx * we.y_idx = y_idx # <<<<<<<<<<<<<< @@ -5746,7 +6047,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.y_idx = __pyx_v_y_idx; - /* "fastdtw/_fastdtw.pyx":450 + /* "fastdtw/_fastdtw.pyx":457 * we.y_idx = y_idx * * if x_idx == 0 and y_idx == 0: # <<<<<<<<<<<<<< @@ -5764,7 +6065,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_L20_bool_binop_done:; if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":451 + /* "fastdtw/_fastdtw.pyx":458 * * if x_idx == 0 and y_idx == 0: * we.cost_idx_up = -1 # <<<<<<<<<<<<<< @@ -5773,7 +6074,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_up = -1; - /* "fastdtw/_fastdtw.pyx":452 + /* "fastdtw/_fastdtw.pyx":459 * if x_idx == 0 and y_idx == 0: * we.cost_idx_up = -1 * we.cost_idx_left = -1 # <<<<<<<<<<<<<< @@ -5782,7 +6083,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_left = -1; - /* "fastdtw/_fastdtw.pyx":453 + /* "fastdtw/_fastdtw.pyx":460 * we.cost_idx_up = -1 * we.cost_idx_left = -1 * we.cost_idx_corner = 0 # <<<<<<<<<<<<<< @@ -5791,7 +6092,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_corner = 0; - /* "fastdtw/_fastdtw.pyx":454 + /* "fastdtw/_fastdtw.pyx":461 * we.cost_idx_left = -1 * we.cost_idx_corner = 0 * window[idx] = we # <<<<<<<<<<<<<< @@ -5800,7 +6101,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_window[__pyx_v_idx]) = __pyx_v_we; - /* "fastdtw/_fastdtw.pyx":455 + /* "fastdtw/_fastdtw.pyx":462 * we.cost_idx_corner = 0 * window[idx] = we * idx += 1 # <<<<<<<<<<<<<< @@ -5809,7 +6110,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_idx = (__pyx_v_idx + 1); - /* "fastdtw/_fastdtw.pyx":456 + /* "fastdtw/_fastdtw.pyx":463 * window[idx] = we * idx += 1 * continue # <<<<<<<<<<<<<< @@ -5818,7 +6119,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ goto __pyx_L17_continue; - /* "fastdtw/_fastdtw.pyx":450 + /* "fastdtw/_fastdtw.pyx":457 * we.y_idx = y_idx * * if x_idx == 0 and y_idx == 0: # <<<<<<<<<<<<<< @@ -5827,7 +6128,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ } - /* "fastdtw/_fastdtw.pyx":458 + /* "fastdtw/_fastdtw.pyx":465 * continue * * if y_idx == low_y_idx: # <<<<<<<<<<<<<< @@ -5837,7 +6138,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_6 = ((__pyx_v_y_idx == __pyx_v_low_y_idx) != 0); if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":459 + /* "fastdtw/_fastdtw.pyx":466 * * if y_idx == low_y_idx: * we.cost_idx_left = -1 # <<<<<<<<<<<<<< @@ -5846,7 +6147,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_left = -1; - /* "fastdtw/_fastdtw.pyx":458 + /* "fastdtw/_fastdtw.pyx":465 * continue * * if y_idx == low_y_idx: # <<<<<<<<<<<<<< @@ -5856,7 +6157,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast goto __pyx_L22; } - /* "fastdtw/_fastdtw.pyx":461 + /* "fastdtw/_fastdtw.pyx":468 * we.cost_idx_left = -1 * else: * we.cost_idx_left = idx # <<<<<<<<<<<<<< @@ -5868,7 +6169,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } __pyx_L22:; - /* "fastdtw/_fastdtw.pyx":463 + /* "fastdtw/_fastdtw.pyx":470 * we.cost_idx_left = idx * * if x_idx == 0 or y_idx > ybounds3[x_idx - 1].high: # <<<<<<<<<<<<<< @@ -5886,7 +6187,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_L24_bool_binop_done:; if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":464 + /* "fastdtw/_fastdtw.pyx":471 * * if x_idx == 0 or y_idx > ybounds3[x_idx - 1].high: * we.cost_idx_up = -1 # <<<<<<<<<<<<<< @@ -5895,7 +6196,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_up = -1; - /* "fastdtw/_fastdtw.pyx":463 + /* "fastdtw/_fastdtw.pyx":470 * we.cost_idx_left = idx * * if x_idx == 0 or y_idx > ybounds3[x_idx - 1].high: # <<<<<<<<<<<<<< @@ -5905,7 +6206,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast goto __pyx_L23; } - /* "fastdtw/_fastdtw.pyx":466 + /* "fastdtw/_fastdtw.pyx":473 * we.cost_idx_up = -1 * else: * we.cost_idx_up = \ # <<<<<<<<<<<<<< @@ -5914,7 +6215,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ /*else*/ { - /* "fastdtw/_fastdtw.pyx":468 + /* "fastdtw/_fastdtw.pyx":475 * we.cost_idx_up = \ * (idx - * (min(len_y - 1, ybounds3[x_idx - 1].high) - # <<<<<<<<<<<<<< @@ -5929,7 +6230,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_11 = __pyx_t_9; } - /* "fastdtw/_fastdtw.pyx":466 + /* "fastdtw/_fastdtw.pyx":473 * we.cost_idx_up = -1 * else: * we.cost_idx_up = \ # <<<<<<<<<<<<<< @@ -5938,7 +6239,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_up = ((__pyx_v_idx - ((__pyx_t_11 - (__pyx_v_ybounds3[__pyx_v_x_idx]).low) + 1)) + 1); - /* "fastdtw/_fastdtw.pyx":471 + /* "fastdtw/_fastdtw.pyx":478 * ybounds3[x_idx].low + 1)) + 1 * * if we.cost_idx_up == 0: # <<<<<<<<<<<<<< @@ -5948,7 +6249,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_6 = ((__pyx_v_we.cost_idx_up == 0) != 0); if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":472 + /* "fastdtw/_fastdtw.pyx":479 * * if we.cost_idx_up == 0: * we.cost_idx_up = -1 # <<<<<<<<<<<<<< @@ -5957,7 +6258,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_up = -1; - /* "fastdtw/_fastdtw.pyx":471 + /* "fastdtw/_fastdtw.pyx":478 * ybounds3[x_idx].low + 1)) + 1 * * if we.cost_idx_up == 0: # <<<<<<<<<<<<<< @@ -5968,7 +6269,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } __pyx_L23:; - /* "fastdtw/_fastdtw.pyx":474 + /* "fastdtw/_fastdtw.pyx":481 * we.cost_idx_up = -1 * * if (x_idx == 0 or # <<<<<<<<<<<<<< @@ -5982,7 +6283,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast goto __pyx_L28_bool_binop_done; } - /* "fastdtw/_fastdtw.pyx":475 + /* "fastdtw/_fastdtw.pyx":482 * * if (x_idx == 0 or * y_idx < ybounds3[x_idx - 1].low + 1 or # <<<<<<<<<<<<<< @@ -5996,7 +6297,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast goto __pyx_L28_bool_binop_done; } - /* "fastdtw/_fastdtw.pyx":476 + /* "fastdtw/_fastdtw.pyx":483 * if (x_idx == 0 or * y_idx < ybounds3[x_idx - 1].low + 1 or * y_idx > ybounds3[x_idx - 1].high): # <<<<<<<<<<<<<< @@ -6007,7 +6308,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast __pyx_t_6 = __pyx_t_12; __pyx_L28_bool_binop_done:; - /* "fastdtw/_fastdtw.pyx":474 + /* "fastdtw/_fastdtw.pyx":481 * we.cost_idx_up = -1 * * if (x_idx == 0 or # <<<<<<<<<<<<<< @@ -6016,7 +6317,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ if (__pyx_t_6) { - /* "fastdtw/_fastdtw.pyx":478 + /* "fastdtw/_fastdtw.pyx":485 * y_idx > ybounds3[x_idx - 1].high): * * we.cost_idx_corner = -1 # <<<<<<<<<<<<<< @@ -6025,7 +6326,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ __pyx_v_we.cost_idx_corner = -1; - /* "fastdtw/_fastdtw.pyx":474 + /* "fastdtw/_fastdtw.pyx":481 * we.cost_idx_up = -1 * * if (x_idx == 0 or # <<<<<<<<<<<<<< @@ -6035,7 +6336,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast goto __pyx_L27; } - /* "fastdtw/_fastdtw.pyx":480 + /* "fastdtw/_fastdtw.pyx":487 * we.cost_idx_corner = -1 * else: * we.cost_idx_corner = we.cost_idx_up - 1 # <<<<<<<<<<<<<< @@ -6047,7 +6348,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } __pyx_L27:; - /* "fastdtw/_fastdtw.pyx":482 + /* "fastdtw/_fastdtw.pyx":489 * we.cost_idx_corner = we.cost_idx_up - 1 * * window[idx] = we # <<<<<<<<<<<<<< @@ -6055,7 +6356,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast */ (__pyx_v_window[__pyx_v_idx]) = __pyx_v_we; - /* "fastdtw/_fastdtw.pyx":483 + /* "fastdtw/_fastdtw.pyx":490 * * window[idx] = we * idx += 1 # <<<<<<<<<<<<<< @@ -6065,7 +6366,7 @@ static PyObject *__pyx_f_7fastdtw_8_fastdtw___expand_window(struct __pyx_t_7fast } } - /* "fastdtw/_fastdtw.pyx":346 + /* "fastdtw/_fastdtw.pyx":353 * * * cdef __expand_window(PathElement *path, int path_len, # <<<<<<<<<<<<<< @@ -6215,10 +6516,12 @@ static PyObject *__Pyx_CFunc_double____double____double___to_py(double (*__pyx_v __Pyx_RefNannySetupContext("__Pyx_CFunc_double____double____double___to_py", 0); __pyx_cur_scope = (struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____double____double___to_py *)__pyx_tp_new___pyx_scope_struct____Pyx_CFunc_double____double____double___to_py(__pyx_ptype___pyx_scope_struct____Pyx_CFunc_double____double____double___to_py, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { - __Pyx_RefNannyFinishContext(); - return 0; + __pyx_cur_scope = ((struct __pyx_obj___pyx_scope_struct____Pyx_CFunc_double____double____double___to_py *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(1, 64, __pyx_L1_error) + } else { + __Pyx_GOTREF(__pyx_cur_scope); } - __Pyx_GOTREF(__pyx_cur_scope); __pyx_cur_scope->__pyx_v_f = __pyx_v_f; /* "cfunc.to_py":65 @@ -6620,7 +6923,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0; for (;;) { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 149, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 149, __pyx_L1_error) @@ -8757,7 +9060,7 @@ static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__py if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 389, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 389, __pyx_L1_error) @@ -8765,7 +9068,7 @@ static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__py #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 389, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 389, __pyx_L1_error) @@ -8918,7 +9221,7 @@ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4_ __Pyx_GOTREF(__pyx_t_3); if (likely(__pyx_t_3 != Py_None)) { PyObject* sequence = __pyx_t_3; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -8928,7 +9231,7 @@ static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4_ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(1, 399, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_4); @@ -9074,7 +9377,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit __Pyx_GOTREF(__pyx_t_1); if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); @@ -9084,7 +9387,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(1, 409, __pyx_L1_error) } - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_2); @@ -9886,11 +10189,10 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; - Py_ssize_t __pyx_t_8; + int __pyx_t_8; PyObject *__pyx_t_9 = NULL; size_t __pyx_t_10; int __pyx_t_11; - int __pyx_t_12; __Pyx_RefNannySetupContext("convert_item_to_object", 0); /* "View.MemoryView":477 @@ -9946,7 +10248,7 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); @@ -9956,20 +10258,40 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview __pyx_t_8 = 1; } } - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 482, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 482, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); + __Pyx_INCREF(__pyx_v_bytesitem); + __Pyx_GIVEREF(__pyx_v_bytesitem); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); + __pyx_t_6 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 482, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); - __Pyx_INCREF(__pyx_v_bytesitem); - __Pyx_GIVEREF(__pyx_v_bytesitem); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 482, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_result = __pyx_t_1; __pyx_t_1 = 0; @@ -10047,9 +10369,9 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 483, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1); + __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_12) { + if (__pyx_t_8) { __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(1, 483, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_1); @@ -10141,13 +10463,14 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; - Py_ssize_t __pyx_t_7; + int __pyx_t_7; PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - char *__pyx_t_10; + Py_ssize_t __pyx_t_9; + PyObject *__pyx_t_10 = NULL; char *__pyx_t_11; char *__pyx_t_12; char *__pyx_t_13; + char *__pyx_t_14; __Pyx_RefNannySetupContext("assign_item_from_object", 0); /* "View.MemoryView":493 @@ -10227,7 +10550,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_7 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) { + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); @@ -10237,20 +10560,40 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie __pyx_t_7 = 1; } } - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 501, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 501, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); + __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); - __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 501, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 501, __pyx_L1_error) __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); @@ -10265,18 +10608,18 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie * itemp[i] = c * */ - __pyx_t_7 = 0; + __pyx_t_9 = 0; if (unlikely(__pyx_v_bytesvalue == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); __PYX_ERR(1, 503, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_bytesvalue); - __pyx_t_9 = __pyx_v_bytesvalue; - __pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9); - __pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9)); - for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) { - __pyx_t_10 = __pyx_t_13; - __pyx_v_c = (__pyx_t_10[0]); + __pyx_t_10 = __pyx_v_bytesvalue; + __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10); + __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10)); + for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) { + __pyx_t_11 = __pyx_t_14; + __pyx_v_c = (__pyx_t_11[0]); /* "View.MemoryView":504 * @@ -10285,7 +10628,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie * * @cname('getbuffer') */ - __pyx_v_i = __pyx_t_7; + __pyx_v_i = __pyx_t_9; /* "View.MemoryView":503 * bytesvalue = struct.pack(self.view.format, value) @@ -10294,7 +10637,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie * itemp[i] = c * */ - __pyx_t_7 = (__pyx_t_7 + 1); + __pyx_t_9 = (__pyx_t_9 + 1); /* "View.MemoryView":504 * @@ -10305,7 +10648,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie */ (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c; } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "View.MemoryView":490 * return result @@ -10324,7 +10667,7 @@ static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryvie __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; @@ -12231,7 +12574,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 665, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 665, __pyx_L1_error) @@ -12239,7 +12582,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 665, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 665, __pyx_L1_error) @@ -12842,7 +13185,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 732, __pyx_L1_error) #else __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 732, __pyx_L1_error) @@ -12850,7 +13193,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ #endif } else { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 732, __pyx_L1_error) #else __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 732, __pyx_L1_error) @@ -16589,7 +16932,7 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_error); __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); @@ -16603,15 +16946,35 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1242, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1242, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); @@ -16687,7 +17050,7 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_error); __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); @@ -16701,15 +17064,35 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1247, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1247, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1247, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); @@ -18042,10 +18425,11 @@ static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { p->__pyx_vtab = __pyx_vtabptr_array; p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; - } + if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad; return o; + bad: + Py_DECREF(o); o = 0; + return NULL; } static void __pyx_tp_dealloc_array(PyObject *o) { @@ -18325,10 +18709,11 @@ static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject p->_size = Py_None; Py_INCREF(Py_None); p->_array_interface = Py_None; Py_INCREF(Py_None); p->view.obj = NULL; - if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; - } + if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad; return o; + bad: + Py_DECREF(o); o = 0; + return NULL; } static void __pyx_tp_dealloc_memoryview(PyObject *o) { @@ -18732,6 +19117,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_Pyx_CFunc_double____double, __pyx_k_Pyx_CFunc_double____double, sizeof(__pyx_k_Pyx_CFunc_double____double), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, + {&__pyx_kp_s_Users_kazuaki_tanida_dev_myproj, __pyx_k_Users_kazuaki_tanida_dev_myproj, sizeof(__pyx_k_Users_kazuaki_tanida_dev_myproj), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1}, {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, @@ -18748,7 +19134,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_dist, __pyx_k_dist, sizeof(__pyx_k_dist), 0, 0, 1, 1}, {&__pyx_kp_s_dist_cannot_be_a_negative_intege, __pyx_k_dist_cannot_be_a_negative_intege, sizeof(__pyx_k_dist_cannot_be_a_negative_intege), 0, 0, 1, 0}, {&__pyx_n_s_dtw, __pyx_k_dtw, sizeof(__pyx_k_dtw), 0, 0, 1, 1}, - {&__pyx_kp_u_dtw_line_114, __pyx_k_dtw_line_114, sizeof(__pyx_k_dtw_line_114), 0, 1, 0, 0}, + {&__pyx_kp_u_dtw_line_121, __pyx_k_dtw_line_121, sizeof(__pyx_k_dtw_line_121), 0, 1, 0, 0}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, @@ -18756,14 +19142,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_n_s_fastdtw, __pyx_k_fastdtw, sizeof(__pyx_k_fastdtw), 0, 0, 1, 1}, {&__pyx_n_s_fastdtw__fastdtw, __pyx_k_fastdtw__fastdtw, sizeof(__pyx_k_fastdtw__fastdtw), 0, 0, 1, 1}, - {&__pyx_kp_u_fastdtw_line_27, __pyx_k_fastdtw_line_27, sizeof(__pyx_k_fastdtw_line_27), 0, 1, 0, 0}, + {&__pyx_kp_u_fastdtw_line_34, __pyx_k_fastdtw_line_34, sizeof(__pyx_k_fastdtw_line_34), 0, 1, 0, 0}, {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1}, {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, - {&__pyx_kp_s_home_esquires_repos_temp_fastdt, __pyx_k_home_esquires_repos_temp_fastdt, sizeof(__pyx_k_home_esquires_repos_temp_fastdt), 0, 0, 1, 0}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_idx, __pyx_k_idx, sizeof(__pyx_k_idx), 0, 0, 1, 1}, @@ -18825,9 +19210,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 83, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 219, __pyx_L1_error) - __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 342, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 226, __pyx_L1_error) + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 349, __pyx_L1_error) __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 146, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 149, __pyx_L1_error) __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 396, __pyx_L1_error) @@ -18843,25 +19228,25 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "fastdtw/_fastdtw.pyx":219 + /* "fastdtw/_fastdtw.pyx":226 * * 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') # <<<<<<<<<<<<<< * if isinstance(dist, numbers.Number) and dist <= 0: * raise ValueError('dist cannot be a negative integer') */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_second_dimension_of_x_and_y_must); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 219, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_second_dimension_of_x_and_y_must); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "fastdtw/_fastdtw.pyx":221 + /* "fastdtw/_fastdtw.pyx":228 * raise ValueError('second dimension of x and y must be the same') * if isinstance(dist, numbers.Number) and dist <= 0: * raise ValueError('dist cannot be a negative integer') # <<<<<<<<<<<<<< * * return x, y */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_dist_cannot_be_a_negative_intege); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 221, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_dist_cannot_be_a_negative_intege); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); @@ -19023,53 +19408,53 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17); - /* "fastdtw/_fastdtw.pyx":27 + /* "fastdtw/_fastdtw.pyx":34 * * * def fastdtw(x, y, int radius=1, dist=None): # <<<<<<<<<<<<<< * ''' return the approximate distance between 2 time series with O(N) * time and memory complexity */ - __pyx_tuple__18 = PyTuple_Pack(9, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_radius, __pyx_n_s_dist, __pyx_n_s_path, __pyx_n_s_path_len, __pyx_n_s_i, __pyx_n_s_cost, __pyx_n_s_path_lst); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 27, __pyx_L1_error) + __pyx_tuple__18 = PyTuple_Pack(9, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_radius, __pyx_n_s_dist, __pyx_n_s_path, __pyx_n_s_path_len, __pyx_n_s_i, __pyx_n_s_cost, __pyx_n_s_path_lst); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); - __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_esquires_repos_temp_fastdt, __pyx_n_s_fastdtw, 27, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 27, __pyx_L1_error) + __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_kazuaki_tanida_dev_myproj, __pyx_n_s_fastdtw, 34, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 34, __pyx_L1_error) - /* "fastdtw/_fastdtw.pyx":114 + /* "fastdtw/_fastdtw.pyx":121 * * * def dtw(x, y, dist=None): # <<<<<<<<<<<<<< * ''' return the distance between 2 time series without approximation * */ - __pyx_tuple__20 = PyTuple_Pack(15, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_dist, __pyx_n_s_len_x, __pyx_n_s_len_y, __pyx_n_s_x_idx, __pyx_n_s_y_idx, __pyx_n_s_idx, __pyx_n_s_cost, __pyx_n_s_we, __pyx_n_s_window, __pyx_n_s_path, __pyx_n_s_path_len, __pyx_n_s_path_lst, __pyx_n_s_i); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_tuple__20 = PyTuple_Pack(15, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_dist, __pyx_n_s_len_x, __pyx_n_s_len_y, __pyx_n_s_x_idx, __pyx_n_s_y_idx, __pyx_n_s_idx, __pyx_n_s_cost, __pyx_n_s_we, __pyx_n_s_window, __pyx_n_s_path, __pyx_n_s_path_len, __pyx_n_s_path_lst, __pyx_n_s_i); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); - __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_esquires_repos_temp_fastdt, __pyx_n_s_dtw, 114, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_kazuaki_tanida_dev_myproj, __pyx_n_s_dtw, 121, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 121, __pyx_L1_error) - /* "fastdtw/_fastdtw.pyx":210 + /* "fastdtw/_fastdtw.pyx":217 * * * def __norm(p): # <<<<<<<<<<<<<< * return lambda a, b: np.linalg.norm(a - b, p) * */ - __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_p); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_p); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); - __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_esquires_repos_temp_fastdt, __pyx_n_s_norm_2, 210, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_kazuaki_tanida_dev_myproj, __pyx_n_s_norm_2, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 217, __pyx_L1_error) - /* "fastdtw/_fastdtw.pyx":214 + /* "fastdtw/_fastdtw.pyx":221 * * * def __prep_inputs(x, y, dist): # <<<<<<<<<<<<<< * x = np.asanyarray(x, dtype='float') * y = np.asanyarray(y, dtype='float') */ - __pyx_tuple__24 = PyTuple_Pack(3, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_dist); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_tuple__24 = PyTuple_Pack(3, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_dist); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); - __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_esquires_repos_temp_fastdt, __pyx_n_s_prep_inputs, 214, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_kazuaki_tanida_dev_myproj, __pyx_n_s_prep_inputs, 221, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 221, __pyx_L1_error) /* "View.MemoryView":282 * return self.name @@ -19152,7 +19537,10 @@ PyMODINIT_FUNC PyInit__fastdtw(void) #endif { PyObject *__pyx_t_1 = NULL; - static PyThread_type_lock __pyx_t_2[8]; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + static PyThread_type_lock __pyx_t_5[8]; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); @@ -19233,7 +19621,7 @@ PyMODINIT_FUNC PyInit__fastdtw(void) /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_7fastdtw_8_fastdtw___pyx_scope_struct____norm) < 0) __PYX_ERR(0, 210, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_7fastdtw_8_fastdtw___pyx_scope_struct____norm) < 0) __PYX_ERR(0, 217, __pyx_L1_error) __pyx_type_7fastdtw_8_fastdtw___pyx_scope_struct____norm.tp_print = 0; __pyx_ptype_7fastdtw_8_fastdtw___pyx_scope_struct____norm = &__pyx_type_7fastdtw_8_fastdtw___pyx_scope_struct____norm; if (PyType_Ready(&__pyx_scope_struct____Pyx_CFunc_double____double____double___to_py) < 0) __PYX_ERR(1, 64, __pyx_L1_error) @@ -19277,21 +19665,9 @@ PyMODINIT_FUNC PyInit__fastdtw(void) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif - /* "fastdtw/_fastdtw.pyx":5 - * - * from __future__ import absolute_import, division - * import numpy as np # <<<<<<<<<<<<<< - * import numbers - * - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":6 * from __future__ import absolute_import, division - * import numpy as np + * * import numbers # <<<<<<<<<<<<<< * * from cpython.mem cimport PyMem_Malloc, PyMem_Free @@ -19301,52 +19677,77 @@ PyMODINIT_FUNC PyInit__fastdtw(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_numbers, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":27 + /* "fastdtw/_fastdtw.pyx":12 + * from libcpp.vector cimport vector + * + * import numpy as np # <<<<<<<<<<<<<< + * + * try: + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "fastdtw/_fastdtw.pyx":14 + * import numpy as np + * + * try: # <<<<<<<<<<<<<< + * from libc.math cimport INFINITY + * except: + */ + { + if (__pyx_t_2||__pyx_t_3||__pyx_t_4); else {/*mark used*/} + /*try:*/ { + } + } + + /* "fastdtw/_fastdtw.pyx":34 * * * def fastdtw(x, y, int radius=1, dist=None): # <<<<<<<<<<<<<< * ''' return the approximate distance between 2 time series with O(N) * time and memory complexity */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_1fastdtw, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_1fastdtw, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fastdtw, __pyx_t_1) < 0) __PYX_ERR(0, 27, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_fastdtw, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":114 + /* "fastdtw/_fastdtw.pyx":121 * * * def dtw(x, y, dist=None): # <<<<<<<<<<<<<< * ''' return the distance between 2 time series without approximation * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_3dtw, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_3dtw, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_dtw, __pyx_t_1) < 0) __PYX_ERR(0, 114, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_dtw, __pyx_t_1) < 0) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":210 + /* "fastdtw/_fastdtw.pyx":217 * * * def __norm(p): # <<<<<<<<<<<<<< * return lambda a, b: np.linalg.norm(a - b, p) * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_5__norm, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_5__norm, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_norm_2, __pyx_t_1) < 0) __PYX_ERR(0, 210, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_norm_2, __pyx_t_1) < 0) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "fastdtw/_fastdtw.pyx":214 + /* "fastdtw/_fastdtw.pyx":221 * * * def __prep_inputs(x, y, dist): # <<<<<<<<<<<<<< * x = np.asanyarray(x, dtype='float') * y = np.asanyarray(y, dtype='float') */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_7__prep_inputs, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7fastdtw_8_fastdtw_7__prep_inputs, NULL, __pyx_n_s_fastdtw__fastdtw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_prep_inputs, __pyx_t_1) < 0) __PYX_ERR(0, 214, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_prep_inputs, __pyx_t_1) < 0) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "fastdtw/_fastdtw.pyx":1 @@ -19356,8 +19757,8 @@ PyMODINIT_FUNC PyInit__fastdtw(void) */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_fastdtw_line_27, __pyx_kp_u_return_the_approximate_distance) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_dtw_line_114, __pyx_kp_u_return_the_distance_between_2_t) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_fastdtw_line_34, __pyx_kp_u_return_the_approximate_distance) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_dtw_line_121, __pyx_kp_u_return_the_distance_between_2_t) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -19460,15 +19861,15 @@ PyMODINIT_FUNC PyInit__fastdtw(void) * PyThread_allocate_lock(), * PyThread_allocate_lock(), */ - __pyx_t_2[0] = PyThread_allocate_lock(); - __pyx_t_2[1] = PyThread_allocate_lock(); - __pyx_t_2[2] = PyThread_allocate_lock(); - __pyx_t_2[3] = PyThread_allocate_lock(); - __pyx_t_2[4] = PyThread_allocate_lock(); - __pyx_t_2[5] = PyThread_allocate_lock(); - __pyx_t_2[6] = PyThread_allocate_lock(); - __pyx_t_2[7] = PyThread_allocate_lock(); - memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_2, sizeof(__pyx_memoryview_thread_locks[0]) * (8)); + __pyx_t_5[0] = PyThread_allocate_lock(); + __pyx_t_5[1] = PyThread_allocate_lock(); + __pyx_t_5[2] = PyThread_allocate_lock(); + __pyx_t_5[3] = PyThread_allocate_lock(); + __pyx_t_5[4] = PyThread_allocate_lock(); + __pyx_t_5[5] = PyThread_allocate_lock(); + __pyx_t_5[6] = PyThread_allocate_lock(); + __pyx_t_5[7] = PyThread_allocate_lock(); + memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_5, sizeof(__pyx_memoryview_thread_locks[0]) * (8)); /* "View.MemoryView":535 * info.obj = self @@ -19703,7 +20104,7 @@ static int __Pyx_ParseOptionalKeywords( /* GetModuleGlobalName */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_AVOID_BORROWED_REFS result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); @@ -19718,6 +20119,146 @@ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { return result; } +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = PyThreadState_GET(); + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif // CPython < 3.6 +#endif // CYTHON_FAST_PYCALL + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + PyObject *result; + int flags; + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); +} +#endif // CYTHON_FAST_PYCCALL + /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { @@ -19753,7 +20294,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE PyThreadState *tstate = PyThreadState_GET(); PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { @@ -19809,7 +20350,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, i); @@ -19824,7 +20365,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, i); @@ -19839,7 +20380,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { @@ -20081,7 +20622,7 @@ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); @@ -20340,11 +20881,9 @@ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) PyString_AsString(op->func_qualname), (void *)op); #endif } -#if CYTHON_COMPILING_IN_PYPY -static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { +static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; - PyObject *self = f->m_self; Py_ssize_t size; switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: @@ -20390,11 +20929,32 @@ static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject f->m_ml->ml_name); return NULL; } -#else -static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { - return PyCFunction_Call(func, arg, kw); +static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); +} +static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { + PyObject *result; + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + Py_ssize_t argc; + PyObject *new_args; + PyObject *self; + argc = PyTuple_GET_SIZE(args); + new_args = PyTuple_GetSlice(args, 1, argc); + if (unlikely(!new_args)) + return NULL; + self = PyTuple_GetItem(args, 0); + if (unlikely(!self)) { + Py_DECREF(new_args); + return NULL; + } + result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); + Py_DECREF(new_args); + } else { + result = __Pyx_CyFunction_Call(func, args, kw); + } + return result; } -#endif static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) "cython_function_or_method", @@ -20414,7 +20974,7 @@ static PyTypeObject __pyx_CyFunctionType_type = { 0, 0, 0, - __Pyx_CyFunction_Call, + __Pyx_CyFunction_CallAsMethod, 0, 0, 0, @@ -20456,9 +21016,6 @@ static PyTypeObject __pyx_CyFunctionType_type = { #endif }; static int __pyx_CyFunction_init(void) { -#if !CYTHON_COMPILING_IN_PYPY - __pyx_CyFunctionType_type.tp_call = PyCFunction_Call; -#endif __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); if (__pyx_CyFunctionType == NULL) { return -1; @@ -20491,7 +21048,7 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py } /* PyErrFetchRestore */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; @@ -20678,7 +21235,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* PyIntBinop */ - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { if (op1 == op2) { Py_RETURN_TRUE; @@ -20694,7 +21251,7 @@ static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED } } #endif - #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a; @@ -20795,6 +21352,11 @@ static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else @@ -20802,6 +21364,10 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif } } return __Pyx__PyObject_CallOneArg(func, arg); @@ -21508,7 +22074,7 @@ static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, } /* PyIntBinop */ - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { @@ -21520,12 +22086,14 @@ static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_ return PyInt_FromLong(x); } #endif - #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; +#ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; +#endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { @@ -21537,49 +22105,61 @@ static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_ if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } default: return PyLong_Type.tp_as_number->nb_remainder(op1, op2); } @@ -21587,10 +22167,14 @@ static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_ x = a % b; x += ((x != 0) & ((x ^ b) < 0)) * b; return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG long_long: llx = lla % llb; llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb; return PyLong_FromLongLong(llx); +#endif + + } #endif return (inplace ? PyNumber_InPlaceRemainder : PyNumber_Remainder)(op1, op2); @@ -21598,7 +22182,7 @@ static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_ #endif /* PyIntBinop */ - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { @@ -21610,7 +22194,7 @@ static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON return PyInt_Type.tp_as_number->nb_true_divide(op1, op2); } #endif - #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; @@ -21660,6 +22244,7 @@ static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON } return PyLong_Type.tp_as_number->nb_true_divide(op1, op2); return PyLong_FromLong(x); + } #endif if (PyFloat_CheckExact(op1)) { @@ -21676,7 +22261,7 @@ static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON #endif /* SaveResetException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; @@ -21700,7 +22285,7 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* PyErrExceptionMatches */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { PyObject *exc_type = tstate->curexc_type; if (exc_type == err) return 1; @@ -21710,13 +22295,13 @@ static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tsta #endif /* GetException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { #endif PyObject *local_type, *local_value, *local_tb; -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; local_type = tstate->curexc_type; local_value = tstate->curexc_value; @@ -21728,7 +22313,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) @@ -21746,7 +22331,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) *type = local_type; *value = local_value; *tb = local_tb; -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; @@ -21984,7 +22569,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* SwapException */ - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; @@ -22083,7 +22668,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, } /* PyIntBinop */ - #if CYTHON_COMPILING_IN_CPYTHON + #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { @@ -22096,12 +22681,14 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif - #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; +#ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; +#endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { @@ -22113,58 +22700,74 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; +#ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; +#endif } default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); +#endif + + } #endif if (PyFloat_CheckExact(op1)) { @@ -22394,7 +22997,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; - py_frame->f_lineno = py_line; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); @@ -22525,14 +23128,18 @@ __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif } } { @@ -22552,14 +23159,18 @@ __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif } } { @@ -22705,8 +23316,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -22773,8 +23386,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -22890,8 +23505,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(char) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -22958,8 +23575,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(char) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -23075,8 +23694,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -23143,8 +23764,10 @@ __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -23579,7 +24202,9 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; +#endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 @@ -23588,8 +24213,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; -#if PY_MAJOR_VERSION < 3 + #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); @@ -23598,11 +24224,14 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { name = "long"; res = PyNumber_Long(x); } -#else + #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } + #endif +#else + res = PyNumber_Int(x); #endif if (res) { #if PY_MAJOR_VERSION < 3 diff --git a/fastdtw/_fastdtw.pyx b/fastdtw/_fastdtw.pyx index 4dfa3a3..db7c2c9 100644 --- a/fastdtw/_fastdtw.pyx +++ b/fastdtw/_fastdtw.pyx @@ -2,13 +2,20 @@ #cython: boundscheck=False, cdivision=True, wraparound=False from __future__ import absolute_import, division -import numpy as np + import numbers from cpython.mem cimport PyMem_Malloc, PyMem_Free -from libc.math cimport INFINITY, pow, fabs +from libc.math cimport pow, fabs from libcpp.vector cimport vector +import numpy as np + +try: + from libc.math cimport INFINITY +except: + from numpy.math cimport INFINITY + cdef struct LowHigh: int low, high diff --git a/setup.py b/setup.py index 4ccbc94..3fbb2ca 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,14 @@ -from setuptools import setup, find_packages, Extension import os.path +from setuptools import setup, find_packages, Extension +from setuptools.command.build_ext import build_ext as _build_ext import warnings +try: + from Cython.Build import cythonize + USE_CYTHON = True +except ImportError: + USE_CYTHON = False + classifiers = [ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', @@ -10,17 +17,32 @@ 'Topic :: Scientific/Engineering' ] + +class build_ext(_build_ext): + def finalize_options(self): + _build_ext.finalize_options(self) + # Prevent numpy from thinking it is still in its setup process: + __builtins__.__NUMPY_SETUP__ = False + import numpy + self.include_dirs.append(numpy.get_include()) + + +ext = '.pyx' if USE_CYTHON else '.cpp' + extensions = [Extension( 'fastdtw._fastdtw', - [os.path.join('fastdtw', "_fastdtw.pyx")], + [os.path.join('fastdtw', '_fastdtw' + ext)], language="c++", include_dirs=[], libraries=["stdc++"] )] +if USE_CYTHON: + extensions = cythonize(extensions) + kwargs = { 'name': 'fastdtw', - 'version': '0.3.0', + 'version': '0.2.2', 'author': 'Kazuaki Tanida', 'url': 'https://github.com/slaypni/fastdtw', 'description': 'Dynamic Time Warping (DTW) algorithm with an O(N) time and memory complexity.', @@ -35,6 +57,7 @@ 'classifiers': classifiers } + try: setup(**kwargs) except SystemExit: