1 /* Generated by Cython 0.29.14 */
3 #define PY_SSIZE_T_CLEAN
6 #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
8 #error Cython requires Python 2.6+ or Python 3.3+.
10 #define CYTHON_ABI "0_29_14"
11 #define CYTHON_HEX_VERSION 0x001D0EF0
12 #define CYTHON_FUTURE_DIVISION 1
15 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
17 #if !defined(WIN32) && !defined(MS_WINDOWS)
29 #define DL_IMPORT(t) t
32 #define DL_EXPORT(t) t
35 #ifndef HAVE_LONG_LONG
36 #if PY_VERSION_HEX >= 0x02070000
37 #define HAVE_LONG_LONG
41 #define PY_LONG_LONG LONG_LONG
44 #define Py_HUGE_VAL HUGE_VAL
47 #define CYTHON_COMPILING_IN_PYPY 1
48 #define CYTHON_COMPILING_IN_PYSTON 0
49 #define CYTHON_COMPILING_IN_CPYTHON 0
50 #undef CYTHON_USE_TYPE_SLOTS
51 #define CYTHON_USE_TYPE_SLOTS 0
52 #undef CYTHON_USE_PYTYPE_LOOKUP
53 #define CYTHON_USE_PYTYPE_LOOKUP 0
54 #if PY_VERSION_HEX < 0x03050000
55 #undef CYTHON_USE_ASYNC_SLOTS
56 #define CYTHON_USE_ASYNC_SLOTS 0
57 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
58 #define CYTHON_USE_ASYNC_SLOTS 1
60 #undef CYTHON_USE_PYLIST_INTERNALS
61 #define CYTHON_USE_PYLIST_INTERNALS 0
62 #undef CYTHON_USE_UNICODE_INTERNALS
63 #define CYTHON_USE_UNICODE_INTERNALS 0
64 #undef CYTHON_USE_UNICODE_WRITER
65 #define CYTHON_USE_UNICODE_WRITER 0
66 #undef CYTHON_USE_PYLONG_INTERNALS
67 #define CYTHON_USE_PYLONG_INTERNALS 0
68 #undef CYTHON_AVOID_BORROWED_REFS
69 #define CYTHON_AVOID_BORROWED_REFS 1
70 #undef CYTHON_ASSUME_SAFE_MACROS
71 #define CYTHON_ASSUME_SAFE_MACROS 0
72 #undef CYTHON_UNPACK_METHODS
73 #define CYTHON_UNPACK_METHODS 0
74 #undef CYTHON_FAST_THREAD_STATE
75 #define CYTHON_FAST_THREAD_STATE 0
76 #undef CYTHON_FAST_PYCALL
77 #define CYTHON_FAST_PYCALL 0
78 #undef CYTHON_PEP489_MULTI_PHASE_INIT
79 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
80 #undef CYTHON_USE_TP_FINALIZE
81 #define CYTHON_USE_TP_FINALIZE 0
82 #undef CYTHON_USE_DICT_VERSIONS
83 #define CYTHON_USE_DICT_VERSIONS 0
84 #undef CYTHON_USE_EXC_INFO_STACK
85 #define CYTHON_USE_EXC_INFO_STACK 0
86 #elif defined(PYSTON_VERSION)
87 #define CYTHON_COMPILING_IN_PYPY 0
88 #define CYTHON_COMPILING_IN_PYSTON 1
89 #define CYTHON_COMPILING_IN_CPYTHON 0
90 #ifndef CYTHON_USE_TYPE_SLOTS
91 #define CYTHON_USE_TYPE_SLOTS 1
93 #undef CYTHON_USE_PYTYPE_LOOKUP
94 #define CYTHON_USE_PYTYPE_LOOKUP 0
95 #undef CYTHON_USE_ASYNC_SLOTS
96 #define CYTHON_USE_ASYNC_SLOTS 0
97 #undef CYTHON_USE_PYLIST_INTERNALS
98 #define CYTHON_USE_PYLIST_INTERNALS 0
99 #ifndef CYTHON_USE_UNICODE_INTERNALS
100 #define CYTHON_USE_UNICODE_INTERNALS 1
102 #undef CYTHON_USE_UNICODE_WRITER
103 #define CYTHON_USE_UNICODE_WRITER 0
104 #undef CYTHON_USE_PYLONG_INTERNALS
105 #define CYTHON_USE_PYLONG_INTERNALS 0
106 #ifndef CYTHON_AVOID_BORROWED_REFS
107 #define CYTHON_AVOID_BORROWED_REFS 0
109 #ifndef CYTHON_ASSUME_SAFE_MACROS
110 #define CYTHON_ASSUME_SAFE_MACROS 1
112 #ifndef CYTHON_UNPACK_METHODS
113 #define CYTHON_UNPACK_METHODS 1
115 #undef CYTHON_FAST_THREAD_STATE
116 #define CYTHON_FAST_THREAD_STATE 0
117 #undef CYTHON_FAST_PYCALL
118 #define CYTHON_FAST_PYCALL 0
119 #undef CYTHON_PEP489_MULTI_PHASE_INIT
120 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
121 #undef CYTHON_USE_TP_FINALIZE
122 #define CYTHON_USE_TP_FINALIZE 0
123 #undef CYTHON_USE_DICT_VERSIONS
124 #define CYTHON_USE_DICT_VERSIONS 0
125 #undef CYTHON_USE_EXC_INFO_STACK
126 #define CYTHON_USE_EXC_INFO_STACK 0
128 #define CYTHON_COMPILING_IN_PYPY 0
129 #define CYTHON_COMPILING_IN_PYSTON 0
130 #define CYTHON_COMPILING_IN_CPYTHON 1
131 #ifndef CYTHON_USE_TYPE_SLOTS
132 #define CYTHON_USE_TYPE_SLOTS 1
134 #if PY_VERSION_HEX < 0x02070000
135 #undef CYTHON_USE_PYTYPE_LOOKUP
136 #define CYTHON_USE_PYTYPE_LOOKUP 0
137 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
138 #define CYTHON_USE_PYTYPE_LOOKUP 1
140 #if PY_MAJOR_VERSION < 3
141 #undef CYTHON_USE_ASYNC_SLOTS
142 #define CYTHON_USE_ASYNC_SLOTS 0
143 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
144 #define CYTHON_USE_ASYNC_SLOTS 1
146 #if PY_VERSION_HEX < 0x02070000
147 #undef CYTHON_USE_PYLONG_INTERNALS
148 #define CYTHON_USE_PYLONG_INTERNALS 0
149 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
150 #define CYTHON_USE_PYLONG_INTERNALS 1
152 #ifndef CYTHON_USE_PYLIST_INTERNALS
153 #define CYTHON_USE_PYLIST_INTERNALS 1
155 #ifndef CYTHON_USE_UNICODE_INTERNALS
156 #define CYTHON_USE_UNICODE_INTERNALS 1
158 #if PY_VERSION_HEX < 0x030300F0
159 #undef CYTHON_USE_UNICODE_WRITER
160 #define CYTHON_USE_UNICODE_WRITER 0
161 #elif !defined(CYTHON_USE_UNICODE_WRITER)
162 #define CYTHON_USE_UNICODE_WRITER 1
164 #ifndef CYTHON_AVOID_BORROWED_REFS
165 #define CYTHON_AVOID_BORROWED_REFS 0
167 #ifndef CYTHON_ASSUME_SAFE_MACROS
168 #define CYTHON_ASSUME_SAFE_MACROS 1
170 #ifndef CYTHON_UNPACK_METHODS
171 #define CYTHON_UNPACK_METHODS 1
173 #ifndef CYTHON_FAST_THREAD_STATE
174 #define CYTHON_FAST_THREAD_STATE 1
176 #ifndef CYTHON_FAST_PYCALL
177 #define CYTHON_FAST_PYCALL 1
179 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
180 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
182 #ifndef CYTHON_USE_TP_FINALIZE
183 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
185 #ifndef CYTHON_USE_DICT_VERSIONS
186 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
188 #ifndef CYTHON_USE_EXC_INFO_STACK
189 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192 #if !defined(CYTHON_FAST_PYCCALL)
193 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
195 #if CYTHON_USE_PYLONG_INTERNALS
196 #include "longintrepr.h"
201 enum { __pyx_check_sizeof_voidp
= 1 / (int)(SIZEOF_VOID_P
== sizeof(void*)) };
204 #ifndef __has_attribute
205 #define __has_attribute(x) 0
207 #ifndef __has_cpp_attribute
208 #define __has_cpp_attribute(x) 0
210 #ifndef CYTHON_RESTRICT
211 #if defined(__GNUC__)
212 #define CYTHON_RESTRICT __restrict__
213 #elif defined(_MSC_VER) && _MSC_VER >= 1400
214 #define CYTHON_RESTRICT __restrict
215 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
216 #define CYTHON_RESTRICT restrict
218 #define CYTHON_RESTRICT
221 #ifndef CYTHON_UNUSED
222 # if defined(__GNUC__)
223 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
224 # define CYTHON_UNUSED __attribute__ ((__unused__))
226 # define CYTHON_UNUSED
228 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
229 # define CYTHON_UNUSED __attribute__ ((__unused__))
231 # define CYTHON_UNUSED
234 #ifndef CYTHON_MAYBE_UNUSED_VAR
235 # if defined(__cplusplus)
236 template<class T
> void CYTHON_MAYBE_UNUSED_VAR( const T
& ) { }
238 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
241 #ifndef CYTHON_NCP_UNUSED
242 # if CYTHON_COMPILING_IN_CPYTHON
243 # define CYTHON_NCP_UNUSED
245 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
248 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
250 #ifndef _MSC_STDINT_H_
252 typedef unsigned char uint8_t;
253 typedef unsigned int uint32_t;
255 typedef unsigned __int8
uint8_t;
256 typedef unsigned __int32
uint32_t;
262 #ifndef CYTHON_FALLTHROUGH
263 #if defined(__cplusplus) && __cplusplus >= 201103L
264 #if __has_cpp_attribute(fallthrough)
265 #define CYTHON_FALLTHROUGH [[fallthrough]]
266 #elif __has_cpp_attribute(clang::fallthrough)
267 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
268 #elif __has_cpp_attribute(gnu::fallthrough)
269 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
272 #ifndef CYTHON_FALLTHROUGH
273 #if __has_attribute(fallthrough)
274 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
276 #define CYTHON_FALLTHROUGH
279 #if defined(__clang__ ) && defined(__apple_build_version__)
280 #if __apple_build_version__ < 7000000
281 #undef CYTHON_FALLTHROUGH
282 #define CYTHON_FALLTHROUGH
287 #ifndef CYTHON_INLINE
288 #if defined(__clang__)
289 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
290 #elif defined(__GNUC__)
291 #define CYTHON_INLINE __inline__
292 #elif defined(_MSC_VER)
293 #define CYTHON_INLINE __inline
294 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
295 #define CYTHON_INLINE inline
297 #define CYTHON_INLINE
301 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
302 #define Py_OptimizeFlag 0
304 #define __PYX_BUILD_PY_SSIZE_T "n"
305 #define CYTHON_FORMAT_SSIZE_T "z"
306 #if PY_MAJOR_VERSION < 3
307 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
308 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
309 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
310 #define __Pyx_DefaultClassType PyClass_Type
312 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
313 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
314 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
315 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
317 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
318 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
320 #define __Pyx_DefaultClassType PyType_Type
322 #ifndef Py_TPFLAGS_CHECKTYPES
323 #define Py_TPFLAGS_CHECKTYPES 0
325 #ifndef Py_TPFLAGS_HAVE_INDEX
326 #define Py_TPFLAGS_HAVE_INDEX 0
328 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
329 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
331 #ifndef Py_TPFLAGS_HAVE_FINALIZE
332 #define Py_TPFLAGS_HAVE_FINALIZE 0
334 #ifndef METH_STACKLESS
335 #define METH_STACKLESS 0
337 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
338 #ifndef METH_FASTCALL
339 #define METH_FASTCALL 0x80
341 typedef PyObject
*(*__Pyx_PyCFunctionFast
) (PyObject
*self
, PyObject
*const *args
, Py_ssize_t nargs
);
342 typedef PyObject
*(*__Pyx_PyCFunctionFastWithKeywords
) (PyObject
*self
, PyObject
*const *args
,
343 Py_ssize_t nargs
, PyObject
*kwnames
);
345 #define __Pyx_PyCFunctionFast _PyCFunctionFast
346 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
348 #if CYTHON_FAST_PYCCALL
349 #define __Pyx_PyFastCFunction_Check(func)\
350 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
352 #define __Pyx_PyFastCFunction_Check(func) 0
354 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
355 #define PyObject_Malloc(s) PyMem_Malloc(s)
356 #define PyObject_Free(p) PyMem_Free(p)
357 #define PyObject_Realloc(p) PyMem_Realloc(p)
359 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
360 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
361 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
362 #define PyMem_RawFree(p) PyMem_Free(p)
364 #if CYTHON_COMPILING_IN_PYSTON
365 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
366 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
368 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
369 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
371 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
372 #define __Pyx_PyThreadState_Current PyThreadState_GET()
373 #elif PY_VERSION_HEX >= 0x03060000
374 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
375 #elif PY_VERSION_HEX >= 0x03000000
376 #define __Pyx_PyThreadState_Current PyThreadState_GET()
378 #define __Pyx_PyThreadState_Current _PyThreadState_Current
380 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
381 #include "pythread.h"
382 #define Py_tss_NEEDS_INIT 0
383 typedef int Py_tss_t
;
384 static CYTHON_INLINE
int PyThread_tss_create(Py_tss_t
*key
) {
385 *key
= PyThread_create_key();
388 static CYTHON_INLINE Py_tss_t
* PyThread_tss_alloc(void) {
389 Py_tss_t
*key
= (Py_tss_t
*)PyObject_Malloc(sizeof(Py_tss_t
));
390 *key
= Py_tss_NEEDS_INIT
;
393 static CYTHON_INLINE
void PyThread_tss_free(Py_tss_t
*key
) {
396 static CYTHON_INLINE
int PyThread_tss_is_created(Py_tss_t
*key
) {
397 return *key
!= Py_tss_NEEDS_INIT
;
399 static CYTHON_INLINE
void PyThread_tss_delete(Py_tss_t
*key
) {
400 PyThread_delete_key(*key
);
401 *key
= Py_tss_NEEDS_INIT
;
403 static CYTHON_INLINE
int PyThread_tss_set(Py_tss_t
*key
, void *value
) {
404 return PyThread_set_key_value(*key
, value
);
406 static CYTHON_INLINE
void * PyThread_tss_get(Py_tss_t
*key
) {
407 return PyThread_get_key_value(*key
);
410 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
411 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
413 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
415 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
416 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
417 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
419 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
420 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
423 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
425 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
427 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
428 #define CYTHON_PEP393_ENABLED 1
429 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
430 0 : _PyUnicode_Ready((PyObject *)(op)))
431 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
432 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
433 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
434 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
435 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
436 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
437 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
438 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
440 #define CYTHON_PEP393_ENABLED 0
441 #define PyUnicode_1BYTE_KIND 1
442 #define PyUnicode_2BYTE_KIND 2
443 #define PyUnicode_4BYTE_KIND 4
444 #define __Pyx_PyUnicode_READY(op) (0)
445 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
446 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
447 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
448 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
449 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
450 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
451 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
452 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
454 #if CYTHON_COMPILING_IN_PYPY
455 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
456 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
458 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
459 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
460 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
462 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
463 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
465 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
466 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
468 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
469 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
471 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
472 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
473 #if PY_MAJOR_VERSION >= 3
474 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
476 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
478 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
479 #define PyObject_ASCII(o) PyObject_Repr(o)
481 #if PY_MAJOR_VERSION >= 3
482 #define PyBaseString_Type PyUnicode_Type
483 #define PyStringObject PyUnicodeObject
484 #define PyString_Type PyUnicode_Type
485 #define PyString_Check PyUnicode_Check
486 #define PyString_CheckExact PyUnicode_CheckExact
487 #define PyObject_Unicode PyObject_Str
489 #if PY_MAJOR_VERSION >= 3
490 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
491 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
493 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
494 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
496 #ifndef PySet_CheckExact
497 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
499 #if CYTHON_ASSUME_SAFE_MACROS
500 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
502 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
504 #if PY_MAJOR_VERSION >= 3
505 #define PyIntObject PyLongObject
506 #define PyInt_Type PyLong_Type
507 #define PyInt_Check(op) PyLong_Check(op)
508 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
509 #define PyInt_FromString PyLong_FromString
510 #define PyInt_FromUnicode PyLong_FromUnicode
511 #define PyInt_FromLong PyLong_FromLong
512 #define PyInt_FromSize_t PyLong_FromSize_t
513 #define PyInt_FromSsize_t PyLong_FromSsize_t
514 #define PyInt_AsLong PyLong_AsLong
515 #define PyInt_AS_LONG PyLong_AS_LONG
516 #define PyInt_AsSsize_t PyLong_AsSsize_t
517 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
518 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
519 #define PyNumber_Int PyNumber_Long
521 #if PY_MAJOR_VERSION >= 3
522 #define PyBoolObject PyLongObject
524 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
525 #ifndef PyUnicode_InternFromString
526 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
529 #if PY_VERSION_HEX < 0x030200A4
530 typedef long Py_hash_t
;
531 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
532 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
534 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
535 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
537 #if PY_MAJOR_VERSION >= 3
538 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
540 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
542 #if CYTHON_USE_ASYNC_SLOTS
543 #if PY_VERSION_HEX >= 0x030500B1
544 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
545 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
547 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
550 #define __Pyx_PyType_AsAsync(obj) NULL
552 #ifndef __Pyx_PyAsyncMethodsStruct
557 } __Pyx_PyAsyncMethodsStruct
;
560 #if defined(WIN32) || defined(MS_WINDOWS)
561 #define _USE_MATH_DEFINES
565 #define __PYX_NAN() ((float) NAN)
567 static CYTHON_INLINE
float __PYX_NAN() {
569 memset(&value
, 0xFF, sizeof(value
));
573 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
574 #define __Pyx_truncl trunc
576 #define __Pyx_truncl truncl
580 #define __PYX_ERR(f_index, lineno, Ln_error) \
582 __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
585 #ifndef __PYX_EXTERN_C
587 #define __PYX_EXTERN_C extern "C"
589 #define __PYX_EXTERN_C extern
593 #define __PYX_HAVE__MACS2__Signal
594 #define __PYX_HAVE_API__MACS2__Signal
598 #include "numpy/arrayobject.h"
599 #include "numpy/ufuncobject.h"
600 #include "pythread.h"
605 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
606 #define CYTHON_WITHOUT_ASSERTIONS
609 typedef struct {PyObject
**p
; const char *s
; const Py_ssize_t n
; const char* encoding
;
610 const char is_unicode
; const char is_str
; const char intern
; } __Pyx_StringTabEntry
;
612 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
613 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
614 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
615 #define __PYX_DEFAULT_STRING_ENCODING ""
616 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
617 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
618 #define __Pyx_uchar_cast(c) ((unsigned char)c)
619 #define __Pyx_long_cast(x) ((long)x)
620 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
621 (sizeof(type) < sizeof(Py_ssize_t)) ||\
622 (sizeof(type) > sizeof(Py_ssize_t) &&\
623 likely(v < (type)PY_SSIZE_T_MAX ||\
624 v == (type)PY_SSIZE_T_MAX) &&\
625 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
626 v == (type)PY_SSIZE_T_MIN))) ||\
627 (sizeof(type) == sizeof(Py_ssize_t) &&\
628 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
629 v == (type)PY_SSIZE_T_MAX))) )
630 static CYTHON_INLINE
int __Pyx_is_valid_index(Py_ssize_t i
, Py_ssize_t limit
) {
631 return (size_t) i
< (size_t) limit
;
633 #if defined (__cplusplus) && __cplusplus >= 201103L
635 #define __Pyx_sst_abs(value) std::abs(value)
636 #elif SIZEOF_INT >= SIZEOF_SIZE_T
637 #define __Pyx_sst_abs(value) abs(value)
638 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
639 #define __Pyx_sst_abs(value) labs(value)
640 #elif defined (_MSC_VER)
641 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
642 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
643 #define __Pyx_sst_abs(value) llabs(value)
644 #elif defined (__GNUC__)
645 #define __Pyx_sst_abs(value) __builtin_llabs(value)
647 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
649 static CYTHON_INLINE
const char* __Pyx_PyObject_AsString(PyObject
*);
650 static CYTHON_INLINE
const char* __Pyx_PyObject_AsStringAndSize(PyObject
*, Py_ssize_t
* length
);
651 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
652 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
653 #define __Pyx_PyBytes_FromString PyBytes_FromString
654 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
655 static CYTHON_INLINE PyObject
* __Pyx_PyUnicode_FromString(const char*);
656 #if PY_MAJOR_VERSION < 3
657 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
658 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
660 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
661 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
663 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
664 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
665 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
666 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
667 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
668 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
669 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
670 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
671 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
672 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
673 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
674 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
675 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
676 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
677 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
678 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
679 static CYTHON_INLINE
size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE
*u
) {
680 const Py_UNICODE
*u_end
= u
;
682 return (size_t)(u_end
- u
- 1);
684 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
685 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
686 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
687 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
688 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
689 static CYTHON_INLINE PyObject
* __Pyx_PyBool_FromLong(long b
);
690 static CYTHON_INLINE
int __Pyx_PyObject_IsTrue(PyObject
*);
691 static CYTHON_INLINE
int __Pyx_PyObject_IsTrueAndDecref(PyObject
*);
692 static CYTHON_INLINE PyObject
* __Pyx_PyNumber_IntOrLong(PyObject
* x
);
693 #define __Pyx_PySequence_Tuple(obj)\
694 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
695 static CYTHON_INLINE Py_ssize_t
__Pyx_PyIndex_AsSsize_t(PyObject
*);
696 static CYTHON_INLINE PyObject
* __Pyx_PyInt_FromSize_t(size_t);
697 #if CYTHON_ASSUME_SAFE_MACROS
698 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
700 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
702 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
703 #if PY_MAJOR_VERSION >= 3
704 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
706 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
708 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
709 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
710 static int __Pyx_sys_getdefaultencoding_not_ascii
;
711 static int __Pyx_init_sys_getdefaultencoding_params(void) {
713 PyObject
* default_encoding
= NULL
;
714 PyObject
* ascii_chars_u
= NULL
;
715 PyObject
* ascii_chars_b
= NULL
;
716 const char* default_encoding_c
;
717 sys
= PyImport_ImportModule("sys");
719 default_encoding
= PyObject_CallMethod(sys
, (char*) "getdefaultencoding", NULL
);
721 if (!default_encoding
) goto bad
;
722 default_encoding_c
= PyBytes_AsString(default_encoding
);
723 if (!default_encoding_c
) goto bad
;
724 if (strcmp(default_encoding_c
, "ascii") == 0) {
725 __Pyx_sys_getdefaultencoding_not_ascii
= 0;
727 char ascii_chars
[128];
729 for (c
= 0; c
< 128; c
++) {
732 __Pyx_sys_getdefaultencoding_not_ascii
= 1;
733 ascii_chars_u
= PyUnicode_DecodeASCII(ascii_chars
, 128, NULL
);
734 if (!ascii_chars_u
) goto bad
;
735 ascii_chars_b
= PyUnicode_AsEncodedString(ascii_chars_u
, default_encoding_c
, NULL
);
736 if (!ascii_chars_b
|| !PyBytes_Check(ascii_chars_b
) || memcmp(ascii_chars
, PyBytes_AS_STRING(ascii_chars_b
), 128) != 0) {
739 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
743 Py_DECREF(ascii_chars_u
);
744 Py_DECREF(ascii_chars_b
);
746 Py_DECREF(default_encoding
);
749 Py_XDECREF(default_encoding
);
750 Py_XDECREF(ascii_chars_u
);
751 Py_XDECREF(ascii_chars_b
);
755 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
756 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
758 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
759 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
760 static char* __PYX_DEFAULT_STRING_ENCODING
;
761 static int __Pyx_init_sys_getdefaultencoding_params(void) {
763 PyObject
* default_encoding
= NULL
;
764 char* default_encoding_c
;
765 sys
= PyImport_ImportModule("sys");
767 default_encoding
= PyObject_CallMethod(sys
, (char*) (const char*) "getdefaultencoding", NULL
);
769 if (!default_encoding
) goto bad
;
770 default_encoding_c
= PyBytes_AsString(default_encoding
);
771 if (!default_encoding_c
) goto bad
;
772 __PYX_DEFAULT_STRING_ENCODING
= (char*) malloc(strlen(default_encoding_c
) + 1);
773 if (!__PYX_DEFAULT_STRING_ENCODING
) goto bad
;
774 strcpy(__PYX_DEFAULT_STRING_ENCODING
, default_encoding_c
);
775 Py_DECREF(default_encoding
);
778 Py_XDECREF(default_encoding
);
785 /* Test for GCC > 2.95 */
786 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
787 #define likely(x) __builtin_expect(!!(x), 1)
788 #define unlikely(x) __builtin_expect(!!(x), 0)
789 #else /* !__GNUC__ or GCC < 2.95 */
790 #define likely(x) (x)
791 #define unlikely(x) (x)
792 #endif /* __GNUC__ */
793 static CYTHON_INLINE
void __Pyx_pretend_to_initialize(void* ptr
) { (void)ptr
; }
795 static PyObject
*__pyx_m
= NULL
;
796 static PyObject
*__pyx_d
;
797 static PyObject
*__pyx_b
;
798 static PyObject
*__pyx_cython_runtime
= NULL
;
799 static PyObject
*__pyx_empty_tuple
;
800 static PyObject
*__pyx_empty_bytes
;
801 static PyObject
*__pyx_empty_unicode
;
802 static int __pyx_lineno
;
803 static int __pyx_clineno
= 0;
804 static const char * __pyx_cfilenm
= __FILE__
;
805 static const char *__pyx_filename
;
808 #if !defined(CYTHON_CCOMPLEX)
809 #if defined(__cplusplus)
810 #define CYTHON_CCOMPLEX 1
811 #elif defined(_Complex_I)
812 #define CYTHON_CCOMPLEX 1
814 #define CYTHON_CCOMPLEX 0
824 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
826 #define _Complex_I 1.0fj
830 static const char *__pyx_f
[] = {
837 /* BufferFormatStructs.proto */
838 #define IS_UNSIGNED(type) (((type) -1) > 0)
839 struct __Pyx_StructField_
;
840 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
843 struct __Pyx_StructField_
* fields
;
851 typedef struct __Pyx_StructField_
{
852 __Pyx_TypeInfo
* type
;
857 __Pyx_StructField
* field
;
858 size_t parent_offset
;
859 } __Pyx_BufFmt_StackElem
;
861 __Pyx_StructField root
;
862 __Pyx_BufFmt_StackElem
* head
;
864 size_t new_count
, enc_count
;
865 size_t struct_alignment
;
871 } __Pyx_BufFmt_Context
;
874 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":776
875 * # in Cython to enable them only on the right systems.
877 * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<<
878 * ctypedef npy_int16 int16_t
879 * ctypedef npy_int32 int32_t
881 typedef npy_int8 __pyx_t_5numpy_int8_t
;
883 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":777
885 * ctypedef npy_int8 int8_t
886 * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<<
887 * ctypedef npy_int32 int32_t
888 * ctypedef npy_int64 int64_t
890 typedef npy_int16 __pyx_t_5numpy_int16_t
;
892 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":778
893 * ctypedef npy_int8 int8_t
894 * ctypedef npy_int16 int16_t
895 * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<<
896 * ctypedef npy_int64 int64_t
897 * #ctypedef npy_int96 int96_t
899 typedef npy_int32 __pyx_t_5numpy_int32_t
;
901 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":779
902 * ctypedef npy_int16 int16_t
903 * ctypedef npy_int32 int32_t
904 * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<<
905 * #ctypedef npy_int96 int96_t
906 * #ctypedef npy_int128 int128_t
908 typedef npy_int64 __pyx_t_5numpy_int64_t
;
910 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":783
911 * #ctypedef npy_int128 int128_t
913 * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<<
914 * ctypedef npy_uint16 uint16_t
915 * ctypedef npy_uint32 uint32_t
917 typedef npy_uint8 __pyx_t_5numpy_uint8_t
;
919 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":784
921 * ctypedef npy_uint8 uint8_t
922 * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<<
923 * ctypedef npy_uint32 uint32_t
924 * ctypedef npy_uint64 uint64_t
926 typedef npy_uint16 __pyx_t_5numpy_uint16_t
;
928 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":785
929 * ctypedef npy_uint8 uint8_t
930 * ctypedef npy_uint16 uint16_t
931 * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<<
932 * ctypedef npy_uint64 uint64_t
933 * #ctypedef npy_uint96 uint96_t
935 typedef npy_uint32 __pyx_t_5numpy_uint32_t
;
937 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":786
938 * ctypedef npy_uint16 uint16_t
939 * ctypedef npy_uint32 uint32_t
940 * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<<
941 * #ctypedef npy_uint96 uint96_t
942 * #ctypedef npy_uint128 uint128_t
944 typedef npy_uint64 __pyx_t_5numpy_uint64_t
;
946 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":790
947 * #ctypedef npy_uint128 uint128_t
949 * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<<
950 * ctypedef npy_float64 float64_t
951 * #ctypedef npy_float80 float80_t
953 typedef npy_float32 __pyx_t_5numpy_float32_t
;
955 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":791
957 * ctypedef npy_float32 float32_t
958 * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<<
959 * #ctypedef npy_float80 float80_t
960 * #ctypedef npy_float128 float128_t
962 typedef npy_float64 __pyx_t_5numpy_float64_t
;
964 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":800
965 * # The int types are mapped a bit surprising --
966 * # numpy.int corresponds to 'l' and numpy.long to 'q'
967 * ctypedef npy_long int_t # <<<<<<<<<<<<<<
968 * ctypedef npy_longlong long_t
969 * ctypedef npy_longlong longlong_t
971 typedef npy_long __pyx_t_5numpy_int_t
;
973 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":801
974 * # numpy.int corresponds to 'l' and numpy.long to 'q'
975 * ctypedef npy_long int_t
976 * ctypedef npy_longlong long_t # <<<<<<<<<<<<<<
977 * ctypedef npy_longlong longlong_t
980 typedef npy_longlong __pyx_t_5numpy_long_t
;
982 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":802
983 * ctypedef npy_long int_t
984 * ctypedef npy_longlong long_t
985 * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<<
987 * ctypedef npy_ulong uint_t
989 typedef npy_longlong __pyx_t_5numpy_longlong_t
;
991 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":804
992 * ctypedef npy_longlong longlong_t
994 * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<<
995 * ctypedef npy_ulonglong ulong_t
996 * ctypedef npy_ulonglong ulonglong_t
998 typedef npy_ulong __pyx_t_5numpy_uint_t
;
1000 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":805
1002 * ctypedef npy_ulong uint_t
1003 * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<<
1004 * ctypedef npy_ulonglong ulonglong_t
1007 typedef npy_ulonglong __pyx_t_5numpy_ulong_t
;
1009 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":806
1010 * ctypedef npy_ulong uint_t
1011 * ctypedef npy_ulonglong ulong_t
1012 * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<<
1014 * ctypedef npy_intp intp_t
1016 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t
;
1018 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":808
1019 * ctypedef npy_ulonglong ulonglong_t
1021 * ctypedef npy_intp intp_t # <<<<<<<<<<<<<<
1022 * ctypedef npy_uintp uintp_t
1025 typedef npy_intp __pyx_t_5numpy_intp_t
;
1027 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":809
1029 * ctypedef npy_intp intp_t
1030 * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<<
1032 * ctypedef npy_double float_t
1034 typedef npy_uintp __pyx_t_5numpy_uintp_t
;
1036 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":811
1037 * ctypedef npy_uintp uintp_t
1039 * ctypedef npy_double float_t # <<<<<<<<<<<<<<
1040 * ctypedef npy_double double_t
1041 * ctypedef npy_longdouble longdouble_t
1043 typedef npy_double __pyx_t_5numpy_float_t
;
1045 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":812
1047 * ctypedef npy_double float_t
1048 * ctypedef npy_double double_t # <<<<<<<<<<<<<<
1049 * ctypedef npy_longdouble longdouble_t
1052 typedef npy_double __pyx_t_5numpy_double_t
;
1054 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":813
1055 * ctypedef npy_double float_t
1056 * ctypedef npy_double double_t
1057 * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<<
1059 * ctypedef npy_cfloat cfloat_t
1061 typedef npy_longdouble __pyx_t_5numpy_longdouble_t
;
1062 /* Declarations.proto */
1065 typedef ::std::complex< float > __pyx_t_float_complex
;
1067 typedef float _Complex __pyx_t_float_complex
;
1070 typedef struct { float real
, imag
; } __pyx_t_float_complex
;
1072 static CYTHON_INLINE __pyx_t_float_complex
__pyx_t_float_complex_from_parts(float, float);
1074 /* Declarations.proto */
1077 typedef ::std::complex< double > __pyx_t_double_complex
;
1079 typedef double _Complex __pyx_t_double_complex
;
1082 typedef struct { double real
, imag
; } __pyx_t_double_complex
;
1084 static CYTHON_INLINE __pyx_t_double_complex
__pyx_t_double_complex_from_parts(double, double);
1087 /*--- Type declarations ---*/
1089 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":815
1090 * ctypedef npy_longdouble longdouble_t
1092 * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<<
1093 * ctypedef npy_cdouble cdouble_t
1094 * ctypedef npy_clongdouble clongdouble_t
1096 typedef npy_cfloat __pyx_t_5numpy_cfloat_t
;
1098 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":816
1100 * ctypedef npy_cfloat cfloat_t
1101 * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<<
1102 * ctypedef npy_clongdouble clongdouble_t
1105 typedef npy_cdouble __pyx_t_5numpy_cdouble_t
;
1107 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":817
1108 * ctypedef npy_cfloat cfloat_t
1109 * ctypedef npy_cdouble cdouble_t
1110 * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<<
1112 * ctypedef npy_cdouble complex_t
1114 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t
;
1116 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":819
1117 * ctypedef npy_clongdouble clongdouble_t
1119 * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<<
1121 * cdef inline object PyArray_MultiIterNew1(a):
1123 typedef npy_cdouble __pyx_t_5numpy_complex_t
;
1124 struct __pyx_opt_args_5MACS2_6Signal_maxima
;
1125 struct __pyx_opt_args_5MACS2_6Signal_enforce_valleys
;
1126 struct __pyx_opt_args_5MACS2_6Signal_savitzky_golay
;
1128 /* "MACS2/Signal.pyx":20
1129 * from math import factorial as mathfactorial
1131 * cpdef np.ndarray[np.int32_t, ndim=1] maxima(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
1132 * int window_size=51):
1133 * """return the local maxima in a signal after applying a 2nd order
1135 struct __pyx_opt_args_5MACS2_6Signal_maxima
{
1140 /* "MACS2/Signal.pyx":171
1143 * cpdef enforce_valleys(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
1144 * np.ndarray[np.int32_t, ndim=1] summits,
1145 * float min_valley = 0.8):
1147 struct __pyx_opt_args_5MACS2_6Signal_enforce_valleys
{
1152 /* "MACS2/Signal.pyx":267
1154 * # Another modified version from http://www.scipy.org/Cookbook/SavitzkyGolay
1155 * cpdef np.ndarray[np.float32_t, ndim=1] savitzky_golay( np.ndarray[np.float32_t, ndim=1] y, int window_size, # <<<<<<<<<<<<<<
1156 * int order, int deriv = 0, int rate = 1 ):
1157 * """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
1159 struct __pyx_opt_args_5MACS2_6Signal_savitzky_golay
{
1165 /* --- Runtime support code (head) --- */
1166 /* Refnanny.proto */
1167 #ifndef CYTHON_REFNANNY
1168 #define CYTHON_REFNANNY 0
1172 void (*INCREF
)(void*, PyObject
*, int);
1173 void (*DECREF
)(void*, PyObject
*, int);
1174 void (*GOTREF
)(void*, PyObject
*, int);
1175 void (*GIVEREF
)(void*, PyObject
*, int);
1176 void* (*SetupContext
)(const char*, int, const char*);
1177 void (*FinishContext
)(void**);
1178 } __Pyx_RefNannyAPIStruct
;
1179 static __Pyx_RefNannyAPIStruct
*__Pyx_RefNanny
= NULL
;
1180 static __Pyx_RefNannyAPIStruct
*__Pyx_RefNannyImportAPI(const char *modname
);
1181 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1183 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1185 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1186 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1187 PyGILState_Release(__pyx_gilstate_save);\
1189 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1192 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1193 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1195 #define __Pyx_RefNannyFinishContext()\
1196 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1197 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1198 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1199 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1200 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1201 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1202 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1203 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1204 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1206 #define __Pyx_RefNannyDeclarations
1207 #define __Pyx_RefNannySetupContext(name, acquire_gil)
1208 #define __Pyx_RefNannyFinishContext()
1209 #define __Pyx_INCREF(r) Py_INCREF(r)
1210 #define __Pyx_DECREF(r) Py_DECREF(r)
1211 #define __Pyx_GOTREF(r)
1212 #define __Pyx_GIVEREF(r)
1213 #define __Pyx_XINCREF(r) Py_XINCREF(r)
1214 #define __Pyx_XDECREF(r) Py_XDECREF(r)
1215 #define __Pyx_XGOTREF(r)
1216 #define __Pyx_XGIVEREF(r)
1218 #define __Pyx_XDECREF_SET(r, v) do {\
1219 PyObject *tmp = (PyObject *) r;\
1220 r = v; __Pyx_XDECREF(tmp);\
1222 #define __Pyx_DECREF_SET(r, v) do {\
1223 PyObject *tmp = (PyObject *) r;\
1224 r = v; __Pyx_DECREF(tmp);\
1226 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1227 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1229 /* PyObjectGetAttrStr.proto */
1230 #if CYTHON_USE_TYPE_SLOTS
1231 static CYTHON_INLINE PyObject
* __Pyx_PyObject_GetAttrStr(PyObject
* obj
, PyObject
* attr_name
);
1233 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1236 /* GetBuiltinName.proto */
1237 static PyObject
*__Pyx_GetBuiltinName(PyObject
*name
);
1239 /* PyThreadStateGet.proto */
1240 #if CYTHON_FAST_THREAD_STATE
1241 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1242 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1243 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1245 #define __Pyx_PyThreadState_declare
1246 #define __Pyx_PyThreadState_assign
1247 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1250 /* PyErrFetchRestore.proto */
1251 #if CYTHON_FAST_THREAD_STATE
1252 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1253 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1254 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1255 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1256 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1257 static CYTHON_INLINE
void __Pyx_ErrRestoreInState(PyThreadState
*tstate
, PyObject
*type
, PyObject
*value
, PyObject
*tb
);
1258 static CYTHON_INLINE
void __Pyx_ErrFetchInState(PyThreadState
*tstate
, PyObject
**type
, PyObject
**value
, PyObject
**tb
);
1259 #if CYTHON_COMPILING_IN_CPYTHON
1260 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1262 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1265 #define __Pyx_PyErr_Clear() PyErr_Clear()
1266 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1267 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1268 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1269 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1270 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1271 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1272 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1276 #ifndef CYTHON_PROFILE
1277 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
1278 #define CYTHON_PROFILE 0
1280 #define CYTHON_PROFILE 1
1283 #ifndef CYTHON_TRACE_NOGIL
1284 #define CYTHON_TRACE_NOGIL 0
1286 #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
1287 #define CYTHON_TRACE 1
1290 #ifndef CYTHON_TRACE
1291 #define CYTHON_TRACE 0
1294 #undef CYTHON_PROFILE_REUSE_FRAME
1296 #ifndef CYTHON_PROFILE_REUSE_FRAME
1297 #define CYTHON_PROFILE_REUSE_FRAME 0
1299 #if CYTHON_PROFILE || CYTHON_TRACE
1300 #include "compile.h"
1301 #include "frameobject.h"
1302 #include "traceback.h"
1303 #if CYTHON_PROFILE_REUSE_FRAME
1304 #define CYTHON_FRAME_MODIFIER static
1305 #define CYTHON_FRAME_DEL(frame)
1307 #define CYTHON_FRAME_MODIFIER
1308 #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
1310 #define __Pyx_TraceDeclarations\
1311 static PyCodeObject *__pyx_frame_code = NULL;\
1312 CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;\
1313 int __Pyx_use_tracing = 0;
1314 #define __Pyx_TraceFrameInit(codeobj)\
1315 if (codeobj) __pyx_frame_code = (PyCodeObject*) codeobj;
1317 #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
1319 if (CYTHON_TRACE_NOGIL) {\
1320 PyThreadState *tstate;\
1321 PyGILState_STATE state = PyGILState_Ensure();\
1322 tstate = __Pyx_PyThreadState_Current;\
1323 if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
1324 (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
1325 __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
1327 PyGILState_Release(state);\
1328 if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
1331 PyThreadState* tstate = PyThreadState_GET();\
1332 if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
1333 (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
1334 __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
1335 if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
1339 #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
1340 { PyThreadState* tstate = PyThreadState_GET();\
1341 if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
1342 (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
1343 __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
1344 if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
1348 #define __Pyx_TraceException()\
1349 if (likely(!__Pyx_use_tracing)); else {\
1350 PyThreadState* tstate = __Pyx_PyThreadState_Current;\
1351 if (tstate->use_tracing &&\
1352 (tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) {\
1354 tstate->use_tracing = 0;\
1355 PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
1357 if (CYTHON_TRACE && tstate->c_tracefunc)\
1358 tstate->c_tracefunc(\
1359 tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
1360 tstate->c_profilefunc(\
1361 tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
1362 Py_DECREF(exc_info);\
1364 tstate->use_tracing = 1;\
1368 static void __Pyx_call_return_trace_func(PyThreadState
*tstate
, PyFrameObject
*frame
, PyObject
*result
) {
1369 PyObject
*type
, *value
, *traceback
;
1370 __Pyx_ErrFetchInState(tstate
, &type
, &value
, &traceback
);
1372 tstate
->use_tracing
= 0;
1373 if (CYTHON_TRACE
&& tstate
->c_tracefunc
)
1374 tstate
->c_tracefunc(tstate
->c_traceobj
, frame
, PyTrace_RETURN
, result
);
1375 if (tstate
->c_profilefunc
)
1376 tstate
->c_profilefunc(tstate
->c_profileobj
, frame
, PyTrace_RETURN
, result
);
1377 CYTHON_FRAME_DEL(frame
);
1378 tstate
->use_tracing
= 1;
1380 __Pyx_ErrRestoreInState(tstate
, type
, value
, traceback
);
1383 #define __Pyx_TraceReturn(result, nogil)\
1384 if (likely(!__Pyx_use_tracing)); else {\
1386 if (CYTHON_TRACE_NOGIL) {\
1387 PyThreadState *tstate;\
1388 PyGILState_STATE state = PyGILState_Ensure();\
1389 tstate = __Pyx_PyThreadState_Current;\
1390 if (tstate->use_tracing) {\
1391 __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
1393 PyGILState_Release(state);\
1396 PyThreadState* tstate = __Pyx_PyThreadState_Current;\
1397 if (tstate->use_tracing) {\
1398 __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
1403 #define __Pyx_TraceReturn(result, nogil)\
1404 if (likely(!__Pyx_use_tracing)); else {\
1405 PyThreadState* tstate = __Pyx_PyThreadState_Current;\
1406 if (tstate->use_tracing) {\
1407 __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
1411 static PyCodeObject
*__Pyx_createFrameCodeObject(const char *funcname
, const char *srcfile
, int firstlineno
);
1412 static int __Pyx_TraceSetupAndCall(PyCodeObject
** code
, PyFrameObject
** frame
, PyThreadState
* tstate
, const char *funcname
, const char *srcfile
, int firstlineno
);
1414 #define __Pyx_TraceDeclarations
1415 #define __Pyx_TraceFrameInit(codeobj)
1416 #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error) if ((1)); else goto_error;
1417 #define __Pyx_TraceException()
1418 #define __Pyx_TraceReturn(result, nogil)
1421 static int __Pyx_call_line_trace_func(PyThreadState
*tstate
, PyFrameObject
*frame
, int lineno
) {
1423 PyObject
*type
, *value
, *traceback
;
1424 __Pyx_ErrFetchInState(tstate
, &type
, &value
, &traceback
);
1425 __Pyx_PyFrame_SetLineNumber(frame
, lineno
);
1427 tstate
->use_tracing
= 0;
1428 ret
= tstate
->c_tracefunc(tstate
->c_traceobj
, frame
, PyTrace_LINE
, NULL
);
1429 tstate
->use_tracing
= 1;
1432 __Pyx_ErrRestoreInState(tstate
, type
, value
, traceback
);
1436 Py_XDECREF(traceback
);
1441 #define __Pyx_TraceLine(lineno, nogil, goto_error)\
1442 if (likely(!__Pyx_use_tracing)); else {\
1444 if (CYTHON_TRACE_NOGIL) {\
1446 PyThreadState *tstate;\
1447 PyGILState_STATE state = PyGILState_Ensure();\
1448 tstate = __Pyx_PyThreadState_Current;\
1449 if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
1450 ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
1452 PyGILState_Release(state);\
1453 if (unlikely(ret)) goto_error;\
1456 PyThreadState* tstate = __Pyx_PyThreadState_Current;\
1457 if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
1458 int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
1459 if (unlikely(ret)) goto_error;\
1464 #define __Pyx_TraceLine(lineno, nogil, goto_error)\
1465 if (likely(!__Pyx_use_tracing)); else {\
1466 PyThreadState* tstate = __Pyx_PyThreadState_Current;\
1467 if (unlikely(tstate->use_tracing && tstate->c_tracefunc && __pyx_frame->f_trace)) {\
1468 int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
1469 if (unlikely(ret)) goto_error;\
1474 #define __Pyx_TraceLine(lineno, nogil, goto_error) if ((1)); else goto_error;
1477 /* IsLittleEndian.proto */
1478 static CYTHON_INLINE
int __Pyx_Is_Little_Endian(void);
1480 /* BufferFormatCheck.proto */
1481 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context
* ctx
, const char* ts
);
1482 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context
* ctx
,
1483 __Pyx_BufFmt_StackElem
* stack
,
1484 __Pyx_TypeInfo
* type
);
1486 /* BufferGetAndValidate.proto */
1487 #define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
1488 ((obj == Py_None || obj == NULL) ?\
1489 (__Pyx_ZeroBuffer(buf), 0) :\
1490 __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
1491 static int __Pyx__GetBufferAndValidate(Py_buffer
* buf
, PyObject
* obj
,
1492 __Pyx_TypeInfo
* dtype
, int flags
, int nd
, int cast
, __Pyx_BufFmt_StackElem
* stack
);
1493 static void __Pyx_ZeroBuffer(Py_buffer
* buf
);
1494 static CYTHON_INLINE
void __Pyx_SafeReleaseBuffer(Py_buffer
* info
);
1495 static Py_ssize_t __Pyx_minusones
[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
1496 static Py_ssize_t __Pyx_zeros
[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1499 static CYTHON_INLINE
long __Pyx_div_long(long, long);
1501 /* PyCFunctionFastCall.proto */
1502 #if CYTHON_FAST_PYCCALL
1503 static CYTHON_INLINE PyObject
*__Pyx_PyCFunction_FastCall(PyObject
*func
, PyObject
**args
, Py_ssize_t nargs
);
1505 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1508 /* PyFunctionFastCall.proto */
1509 #if CYTHON_FAST_PYCALL
1510 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1511 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1512 #if 1 || PY_VERSION_HEX < 0x030600B1
1513 static PyObject
*__Pyx_PyFunction_FastCallDict(PyObject
*func
, PyObject
**args
, Py_ssize_t nargs
, PyObject
*kwargs
);
1515 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1517 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1518 (sizeof(char [1 - 2*!(cond)]) - 1)
1519 #ifndef Py_MEMBER_SIZE
1520 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1522 static size_t __pyx_pyframe_localsplus_offset
= 0;
1523 #include "frameobject.h"
1524 #define __Pxy_PyFrame_Initialize_Offsets()\
1525 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1526 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1527 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1528 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1531 /* PyObjectCall.proto */
1532 #if CYTHON_COMPILING_IN_CPYTHON
1533 static CYTHON_INLINE PyObject
* __Pyx_PyObject_Call(PyObject
*func
, PyObject
*arg
, PyObject
*kw
);
1535 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1538 /* PyObjectCall2Args.proto */
1539 static CYTHON_UNUSED PyObject
* __Pyx_PyObject_Call2Args(PyObject
* function
, PyObject
* arg1
, PyObject
* arg2
);
1541 /* PyObjectCallMethO.proto */
1542 #if CYTHON_COMPILING_IN_CPYTHON
1543 static CYTHON_INLINE PyObject
* __Pyx_PyObject_CallMethO(PyObject
*func
, PyObject
*arg
);
1546 /* PyObjectCallOneArg.proto */
1547 static CYTHON_INLINE PyObject
* __Pyx_PyObject_CallOneArg(PyObject
*func
, PyObject
*arg
);
1549 /* ExtTypeTest.proto */
1550 static CYTHON_INLINE
int __Pyx_TypeTest(PyObject
*obj
, PyTypeObject
*type
);
1552 /* BufferFallbackError.proto */
1553 static void __Pyx_RaiseBufferFallbackError(void);
1555 /* PyDictVersioning.proto */
1556 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1557 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1558 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1559 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1560 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1561 (cache_var) = (value);
1562 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1563 static PY_UINT64_T __pyx_dict_version = 0;\
1564 static PyObject *__pyx_dict_cached_value = NULL;\
1565 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1566 (VAR) = __pyx_dict_cached_value;\
1568 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1569 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1572 static CYTHON_INLINE PY_UINT64_T
__Pyx_get_tp_dict_version(PyObject
*obj
);
1573 static CYTHON_INLINE PY_UINT64_T
__Pyx_get_object_dict_version(PyObject
*obj
);
1574 static CYTHON_INLINE
int __Pyx_object_dict_version_matches(PyObject
* obj
, PY_UINT64_T tp_dict_version
, PY_UINT64_T obj_dict_version
);
1576 #define __PYX_GET_DICT_VERSION(dict) (0)
1577 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1578 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1581 /* GetModuleGlobalName.proto */
1582 #if CYTHON_USE_DICT_VERSIONS
1583 #define __Pyx_GetModuleGlobalName(var, name) {\
1584 static PY_UINT64_T __pyx_dict_version = 0;\
1585 static PyObject *__pyx_dict_cached_value = NULL;\
1586 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1587 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1588 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1590 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1591 PY_UINT64_T __pyx_dict_version;\
1592 PyObject *__pyx_dict_cached_value;\
1593 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1595 static PyObject
*__Pyx__GetModuleGlobalName(PyObject
*name
, PY_UINT64_T
*dict_version
, PyObject
**dict_cached_value
);
1597 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1598 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1599 static CYTHON_INLINE PyObject
*__Pyx__GetModuleGlobalName(PyObject
*name
);
1602 /* GetItemInt.proto */
1603 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1604 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1605 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1606 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1607 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1608 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1609 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1610 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1611 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1612 static CYTHON_INLINE PyObject
*__Pyx_GetItemInt_List_Fast(PyObject
*o
, Py_ssize_t i
,
1613 int wraparound
, int boundscheck
);
1614 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1615 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1616 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1617 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1618 static CYTHON_INLINE PyObject
*__Pyx_GetItemInt_Tuple_Fast(PyObject
*o
, Py_ssize_t i
,
1619 int wraparound
, int boundscheck
);
1620 static PyObject
*__Pyx_GetItemInt_Generic(PyObject
*o
, PyObject
* j
);
1621 static CYTHON_INLINE PyObject
*__Pyx_GetItemInt_Fast(PyObject
*o
, Py_ssize_t i
,
1622 int is_list
, int wraparound
, int boundscheck
);
1624 /* RaiseDoubleKeywords.proto */
1625 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name
, PyObject
* kw_name
);
1627 /* ParseKeywords.proto */
1628 static int __Pyx_ParseOptionalKeywords(PyObject
*kwds
, PyObject
**argnames
[],\
1629 PyObject
*kwds2
, PyObject
*values
[], Py_ssize_t num_pos_args
,\
1630 const char* function_name
);
1632 /* RaiseArgTupleInvalid.proto */
1633 static void __Pyx_RaiseArgtupleInvalid(const char* func_name
, int exact
,
1634 Py_ssize_t num_min
, Py_ssize_t num_max
, Py_ssize_t num_found
);
1636 /* ArgTypeTest.proto */
1637 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1638 ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1639 __Pyx__ArgTypeTest(obj, type, name, exact))
1640 static int __Pyx__ArgTypeTest(PyObject
*obj
, PyTypeObject
*type
, const char *name
, int exact
);
1642 /* BufferIndexError.proto */
1643 static void __Pyx_RaiseBufferIndexError(int axis
);
1645 #define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
1646 /* ObjectGetItem.proto */
1647 #if CYTHON_USE_TYPE_SLOTS
1648 static CYTHON_INLINE PyObject
*__Pyx_PyObject_GetItem(PyObject
*obj
, PyObject
* key
);
1650 #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
1653 /* PyObjectCallNoArg.proto */
1654 #if CYTHON_COMPILING_IN_CPYTHON
1655 static CYTHON_INLINE PyObject
* __Pyx_PyObject_CallNoArg(PyObject
*func
);
1657 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1660 /* WriteUnraisableException.proto */
1661 static void __Pyx_WriteUnraisable(const char *name
, int clineno
,
1662 int lineno
, const char *filename
,
1663 int full_traceback
, int nogil
);
1665 /* PyIntBinop.proto */
1666 #if !CYTHON_COMPILING_IN_PYPY
1667 static PyObject
* __Pyx_PyInt_AddObjC(PyObject
*op1
, PyObject
*op2
, long intval
, int inplace
, int zerodivision_check
);
1669 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1670 (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1674 static CYTHON_INLINE
long __Pyx_mod_long(long, long);
1676 /* ListCompAppend.proto */
1677 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
1678 static CYTHON_INLINE
int __Pyx_ListComp_Append(PyObject
* list
, PyObject
* x
) {
1679 PyListObject
* L
= (PyListObject
*) list
;
1680 Py_ssize_t len
= Py_SIZE(list
);
1681 if (likely(L
->allocated
> len
)) {
1683 PyList_SET_ITEM(list
, len
, x
);
1684 Py_SIZE(list
) = len
+1;
1687 return PyList_Append(list
, x
);
1690 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1693 /* GetTopmostException.proto */
1694 #if CYTHON_USE_EXC_INFO_STACK
1695 static _PyErr_StackItem
* __Pyx_PyErr_GetTopmostException(PyThreadState
*tstate
);
1698 /* SaveResetException.proto */
1699 #if CYTHON_FAST_THREAD_STATE
1700 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1701 static CYTHON_INLINE
void __Pyx__ExceptionSave(PyThreadState
*tstate
, PyObject
**type
, PyObject
**value
, PyObject
**tb
);
1702 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1703 static CYTHON_INLINE
void __Pyx__ExceptionReset(PyThreadState
*tstate
, PyObject
*type
, PyObject
*value
, PyObject
*tb
);
1705 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1706 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1709 /* PyErrExceptionMatches.proto */
1710 #if CYTHON_FAST_THREAD_STATE
1711 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1712 static CYTHON_INLINE
int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState
* tstate
, PyObject
* err
);
1714 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1717 /* GetException.proto */
1718 #if CYTHON_FAST_THREAD_STATE
1719 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1720 static int __Pyx__GetException(PyThreadState
*tstate
, PyObject
**type
, PyObject
**value
, PyObject
**tb
);
1722 static int __Pyx_GetException(PyObject
**type
, PyObject
**value
, PyObject
**tb
);
1725 /* RaiseException.proto */
1726 static void __Pyx_Raise(PyObject
*type
, PyObject
*value
, PyObject
*tb
, PyObject
*cause
);
1728 /* DictGetItem.proto */
1729 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
1730 static PyObject
*__Pyx_PyDict_GetItem(PyObject
*d
, PyObject
* key
);
1731 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
1732 (likely(PyDict_CheckExact(obj)) ?\
1733 __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
1735 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1736 #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
1739 /* RaiseTooManyValuesToUnpack.proto */
1740 static CYTHON_INLINE
void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected
);
1742 /* RaiseNeedMoreValuesToUnpack.proto */
1743 static CYTHON_INLINE
void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index
);
1745 /* RaiseNoneIterError.proto */
1746 static CYTHON_INLINE
void __Pyx_RaiseNoneNotIterableError(void);
1748 /* TypeImport.proto */
1749 #ifndef __PYX_HAVE_RT_ImportType_proto
1750 #define __PYX_HAVE_RT_ImportType_proto
1751 enum __Pyx_ImportType_CheckSize
{
1752 __Pyx_ImportType_CheckSize_Error
= 0,
1753 __Pyx_ImportType_CheckSize_Warn
= 1,
1754 __Pyx_ImportType_CheckSize_Ignore
= 2
1756 static PyTypeObject
*__Pyx_ImportType(PyObject
* module
, const char *module_name
, const char *class_name
, size_t size
, enum __Pyx_ImportType_CheckSize check_size
);
1760 static PyObject
*__Pyx_Import(PyObject
*name
, PyObject
*from_list
, int level
);
1762 /* ImportFrom.proto */
1763 static PyObject
* __Pyx_ImportFrom(PyObject
* module
, PyObject
* name
);
1765 /* CLineInTraceback.proto */
1766 #ifdef CYTHON_CLINE_IN_TRACEBACK
1767 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1769 static int __Pyx_CLineForTraceback(PyThreadState
*tstate
, int c_line
);
1772 /* CodeObjectCache.proto */
1774 PyCodeObject
* code_object
;
1776 } __Pyx_CodeObjectCacheEntry
;
1777 struct __Pyx_CodeObjectCache
{
1780 __Pyx_CodeObjectCacheEntry
* entries
;
1782 static struct __Pyx_CodeObjectCache __pyx_code_cache
= {0,0,NULL
};
1783 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry
* entries
, int count
, int code_line
);
1784 static PyCodeObject
*__pyx_find_code_object(int code_line
);
1785 static void __pyx_insert_code_object(int code_line
, PyCodeObject
* code_object
);
1787 /* AddTraceback.proto */
1788 static void __Pyx_AddTraceback(const char *funcname
, int c_line
,
1789 int py_line
, const char *filename
);
1791 /* BufferStructDeclare.proto */
1793 Py_ssize_t shape
, strides
, suboffsets
;
1794 } __Pyx_Buf_DimInfo
;
1800 __Pyx_Buffer
*rcbuffer
;
1802 __Pyx_Buf_DimInfo diminfo
[8];
1803 } __Pyx_LocalBuf_ND
;
1805 #if PY_MAJOR_VERSION < 3
1806 static int __Pyx_GetBuffer(PyObject
*obj
, Py_buffer
*view
, int flags
);
1807 static void __Pyx_ReleaseBuffer(Py_buffer
*view
);
1809 #define __Pyx_GetBuffer PyObject_GetBuffer
1810 #define __Pyx_ReleaseBuffer PyBuffer_Release
1814 /* CIntToPy.proto */
1815 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_long(long value
);
1817 /* CIntToPy.proto */
1818 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_npy_int32(npy_int32 value
);
1820 /* CIntToPy.proto */
1821 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_int(int value
);
1824 static CYTHON_INLINE
long __Pyx_pow_long(long, long);
1827 static CYTHON_INLINE
int __Pyx_pow_int(int, int);
1829 /* RealImag.proto */
1832 #define __Pyx_CREAL(z) ((z).real())
1833 #define __Pyx_CIMAG(z) ((z).imag())
1835 #define __Pyx_CREAL(z) (__real__(z))
1836 #define __Pyx_CIMAG(z) (__imag__(z))
1839 #define __Pyx_CREAL(z) ((z).real)
1840 #define __Pyx_CIMAG(z) ((z).imag)
1842 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
1843 && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
1844 #define __Pyx_SET_CREAL(z,x) ((z).real(x))
1845 #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
1847 #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
1848 #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
1851 /* Arithmetic.proto */
1853 #define __Pyx_c_eq_float(a, b) ((a)==(b))
1854 #define __Pyx_c_sum_float(a, b) ((a)+(b))
1855 #define __Pyx_c_diff_float(a, b) ((a)-(b))
1856 #define __Pyx_c_prod_float(a, b) ((a)*(b))
1857 #define __Pyx_c_quot_float(a, b) ((a)/(b))
1858 #define __Pyx_c_neg_float(a) (-(a))
1860 #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
1861 #define __Pyx_c_conj_float(z) (::std::conj(z))
1863 #define __Pyx_c_abs_float(z) (::std::abs(z))
1864 #define __Pyx_c_pow_float(a, b) (::std::pow(a, b))
1867 #define __Pyx_c_is_zero_float(z) ((z)==0)
1868 #define __Pyx_c_conj_float(z) (conjf(z))
1870 #define __Pyx_c_abs_float(z) (cabsf(z))
1871 #define __Pyx_c_pow_float(a, b) (cpowf(a, b))
1875 static CYTHON_INLINE
int __Pyx_c_eq_float(__pyx_t_float_complex
, __pyx_t_float_complex
);
1876 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_sum_float(__pyx_t_float_complex
, __pyx_t_float_complex
);
1877 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_diff_float(__pyx_t_float_complex
, __pyx_t_float_complex
);
1878 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_prod_float(__pyx_t_float_complex
, __pyx_t_float_complex
);
1879 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_quot_float(__pyx_t_float_complex
, __pyx_t_float_complex
);
1880 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_neg_float(__pyx_t_float_complex
);
1881 static CYTHON_INLINE
int __Pyx_c_is_zero_float(__pyx_t_float_complex
);
1882 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_conj_float(__pyx_t_float_complex
);
1884 static CYTHON_INLINE
float __Pyx_c_abs_float(__pyx_t_float_complex
);
1885 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_pow_float(__pyx_t_float_complex
, __pyx_t_float_complex
);
1889 /* Arithmetic.proto */
1891 #define __Pyx_c_eq_double(a, b) ((a)==(b))
1892 #define __Pyx_c_sum_double(a, b) ((a)+(b))
1893 #define __Pyx_c_diff_double(a, b) ((a)-(b))
1894 #define __Pyx_c_prod_double(a, b) ((a)*(b))
1895 #define __Pyx_c_quot_double(a, b) ((a)/(b))
1896 #define __Pyx_c_neg_double(a) (-(a))
1898 #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
1899 #define __Pyx_c_conj_double(z) (::std::conj(z))
1901 #define __Pyx_c_abs_double(z) (::std::abs(z))
1902 #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
1905 #define __Pyx_c_is_zero_double(z) ((z)==0)
1906 #define __Pyx_c_conj_double(z) (conj(z))
1908 #define __Pyx_c_abs_double(z) (cabs(z))
1909 #define __Pyx_c_pow_double(a, b) (cpow(a, b))
1913 static CYTHON_INLINE
int __Pyx_c_eq_double(__pyx_t_double_complex
, __pyx_t_double_complex
);
1914 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_sum_double(__pyx_t_double_complex
, __pyx_t_double_complex
);
1915 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_diff_double(__pyx_t_double_complex
, __pyx_t_double_complex
);
1916 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_prod_double(__pyx_t_double_complex
, __pyx_t_double_complex
);
1917 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_quot_double(__pyx_t_double_complex
, __pyx_t_double_complex
);
1918 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_neg_double(__pyx_t_double_complex
);
1919 static CYTHON_INLINE
int __Pyx_c_is_zero_double(__pyx_t_double_complex
);
1920 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_conj_double(__pyx_t_double_complex
);
1922 static CYTHON_INLINE
double __Pyx_c_abs_double(__pyx_t_double_complex
);
1923 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_pow_double(__pyx_t_double_complex
, __pyx_t_double_complex
);
1927 /* CIntToPy.proto */
1928 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value
);
1930 /* CIntFromPy.proto */
1931 static CYTHON_INLINE
int __Pyx_PyInt_As_int(PyObject
*);
1933 /* CIntFromPy.proto */
1934 static CYTHON_INLINE npy_int32
__Pyx_PyInt_As_npy_int32(PyObject
*);
1936 /* CIntFromPy.proto */
1937 static CYTHON_INLINE
long __Pyx_PyInt_As_long(PyObject
*);
1939 /* FastTypeChecks.proto */
1940 #if CYTHON_COMPILING_IN_CPYTHON
1941 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1942 static CYTHON_INLINE
int __Pyx_IsSubtype(PyTypeObject
*a
, PyTypeObject
*b
);
1943 static CYTHON_INLINE
int __Pyx_PyErr_GivenExceptionMatches(PyObject
*err
, PyObject
*type
);
1944 static CYTHON_INLINE
int __Pyx_PyErr_GivenExceptionMatches2(PyObject
*err
, PyObject
*type1
, PyObject
*type2
);
1946 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1947 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1948 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1950 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1952 /* CheckBinaryVersion.proto */
1953 static int __Pyx_check_binary_version(void);
1955 /* InitStrings.proto */
1956 static int __Pyx_InitStrings(__Pyx_StringTabEntry
*t
);
1959 /* Module declarations from 'cpython.buffer' */
1961 /* Module declarations from 'libc.string' */
1963 /* Module declarations from 'libc.stdio' */
1965 /* Module declarations from '__builtin__' */
1967 /* Module declarations from 'cpython.type' */
1968 static PyTypeObject
*__pyx_ptype_7cpython_4type_type
= 0;
1970 /* Module declarations from 'cpython.version' */
1972 /* Module declarations from 'cpython.exc' */
1974 /* Module declarations from 'cpython.module' */
1976 /* Module declarations from 'cpython.mem' */
1978 /* Module declarations from 'cpython.tuple' */
1980 /* Module declarations from 'cpython.list' */
1982 /* Module declarations from 'cpython.sequence' */
1984 /* Module declarations from 'cpython.mapping' */
1986 /* Module declarations from 'cpython.iterator' */
1988 /* Module declarations from 'cpython.number' */
1990 /* Module declarations from 'cpython.int' */
1992 /* Module declarations from '__builtin__' */
1994 /* Module declarations from 'cpython.bool' */
1995 static PyTypeObject
*__pyx_ptype_7cpython_4bool_bool
= 0;
1997 /* Module declarations from 'cpython.long' */
1999 /* Module declarations from 'cpython.float' */
2001 /* Module declarations from '__builtin__' */
2003 /* Module declarations from 'cpython.complex' */
2004 static PyTypeObject
*__pyx_ptype_7cpython_7complex_complex
= 0;
2006 /* Module declarations from 'cpython.string' */
2008 /* Module declarations from 'cpython.unicode' */
2010 /* Module declarations from 'cpython.dict' */
2012 /* Module declarations from 'cpython.instance' */
2014 /* Module declarations from 'cpython.function' */
2016 /* Module declarations from 'cpython.method' */
2018 /* Module declarations from 'cpython.weakref' */
2020 /* Module declarations from 'cpython.getargs' */
2022 /* Module declarations from 'cpython.pythread' */
2024 /* Module declarations from 'cpython.pystate' */
2026 /* Module declarations from 'cpython.cobject' */
2028 /* Module declarations from 'cpython.oldbuffer' */
2030 /* Module declarations from 'cpython.set' */
2032 /* Module declarations from 'cpython.bytes' */
2034 /* Module declarations from 'cpython.pycapsule' */
2036 /* Module declarations from 'cpython' */
2038 /* Module declarations from 'cpython.object' */
2040 /* Module declarations from 'cpython.ref' */
2042 /* Module declarations from 'numpy' */
2044 /* Module declarations from 'numpy' */
2045 static PyTypeObject
*__pyx_ptype_5numpy_dtype
= 0;
2046 static PyTypeObject
*__pyx_ptype_5numpy_flatiter
= 0;
2047 static PyTypeObject
*__pyx_ptype_5numpy_broadcast
= 0;
2048 static PyTypeObject
*__pyx_ptype_5numpy_ndarray
= 0;
2049 static PyTypeObject
*__pyx_ptype_5numpy_ufunc
= 0;
2050 static CYTHON_INLINE
char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr
*, char *, char *, int *); /*proto*/
2052 /* Module declarations from 'MACS2.Signal' */
2053 static PyArrayObject
*__pyx_f_5MACS2_6Signal_maxima(PyArrayObject
*, int __pyx_skip_dispatch
, struct __pyx_opt_args_5MACS2_6Signal_maxima
*__pyx_optional_args
); /*proto*/
2054 static PyArrayObject
*__pyx_f_5MACS2_6Signal_internal_minima(PyArrayObject
*, PyArrayObject
*); /*proto*/
2055 static CYTHON_INLINE
float __pyx_f_5MACS2_6Signal_sqrt(float); /*proto*/
2056 static PyObject
*__pyx_f_5MACS2_6Signal_enforce_peakyness(PyArrayObject
*, PyArrayObject
*, int __pyx_skip_dispatch
); /*proto*/
2057 static PyBoolObject
*__pyx_f_5MACS2_6Signal_is_valid_peak(PyArrayObject
*, int); /*proto*/
2058 static PyBoolObject
*__pyx_f_5MACS2_6Signal_too_flat(PyArrayObject
*); /*proto*/
2059 static PyArrayObject
*__pyx_f_5MACS2_6Signal_hard_clip(PyArrayObject
*, int); /*proto*/
2060 static PyObject
*__pyx_f_5MACS2_6Signal_enforce_valleys(PyArrayObject
*, PyArrayObject
*, int __pyx_skip_dispatch
, struct __pyx_opt_args_5MACS2_6Signal_enforce_valleys
*__pyx_optional_args
); /*proto*/
2061 static PyArrayObject
*__pyx_f_5MACS2_6Signal_savitzky_golay_order2_deriv1(PyArrayObject
*, int, int __pyx_skip_dispatch
); /*proto*/
2062 static PyArrayObject
*__pyx_f_5MACS2_6Signal_savitzky_golay(PyArrayObject
*, int, int, int __pyx_skip_dispatch
, struct __pyx_opt_args_5MACS2_6Signal_savitzky_golay
*__pyx_optional_args
); /*proto*/
2063 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
= { "float32_t", NULL
, sizeof(__pyx_t_5numpy_float32_t
), { 0 }, 0, 'R', 0, 0 };
2064 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
= { "float64_t", NULL
, sizeof(__pyx_t_5numpy_float64_t
), { 0 }, 0, 'R', 0, 0 };
2065 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
= { "int32_t", NULL
, sizeof(__pyx_t_5numpy_int32_t
), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int32_t
) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int32_t
), 0 };
2066 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t
= { "int64_t", NULL
, sizeof(__pyx_t_5numpy_int64_t
), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int64_t
) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int64_t
), 0 };
2067 #define __Pyx_MODULE_NAME "MACS2.Signal"
2068 extern int __pyx_module_is_main_MACS2__Signal
;
2069 int __pyx_module_is_main_MACS2__Signal
= 0;
2071 /* Implementation of 'MACS2.Signal' */
2072 static PyObject
*__pyx_builtin_range
;
2073 static PyObject
*__pyx_builtin_ValueError
;
2074 static PyObject
*__pyx_builtin_TypeError
;
2075 static PyObject
*__pyx_builtin_RuntimeError
;
2076 static PyObject
*__pyx_builtin_ImportError
;
2077 static const char __pyx_k_y
[] = "y";
2078 static const char __pyx_k_np
[] = "np";
2079 static const char __pyx_k_abs
[] = "abs";
2080 static const char __pyx_k_any
[] = "any";
2081 static const char __pyx_k_int
[] = "int";
2082 static const char __pyx_k_min
[] = "min";
2083 static const char __pyx_k_copy
[] = "copy";
2084 static const char __pyx_k_diff
[] = "diff";
2085 static const char __pyx_k_main
[] = "__main__";
2086 static const char __pyx_k_math
[] = "math";
2087 static const char __pyx_k_mode
[] = "mode";
2088 static const char __pyx_k_name
[] = "__name__";
2089 static const char __pyx_k_pinv
[] = "pinv";
2090 static const char __pyx_k_rate
[] = "rate";
2091 static const char __pyx_k_sign
[] = "sign";
2092 static const char __pyx_k_sqrt
[] = "sqrt";
2093 static const char __pyx_k_test
[] = "__test__";
2094 static const char __pyx_k_array
[] = "array";
2095 static const char __pyx_k_deriv
[] = "deriv";
2096 static const char __pyx_k_dtype
[] = "dtype";
2097 static const char __pyx_k_int32
[] = "int32";
2098 static const char __pyx_k_int64
[] = "int64";
2099 static const char __pyx_k_numpy
[] = "numpy";
2100 static const char __pyx_k_order
[] = "order";
2101 static const char __pyx_k_range
[] = "range";
2102 static const char __pyx_k_round
[] = "round";
2103 static const char __pyx_k_shape
[] = "shape";
2104 static const char __pyx_k_valid
[] = "valid";
2105 static const char __pyx_k_where
[] = "where";
2106 static const char __pyx_k_zeros
[] = "zeros";
2107 static const char __pyx_k_astype
[] = "astype";
2108 static const char __pyx_k_import
[] = "__import__";
2109 static const char __pyx_k_linalg
[] = "linalg";
2110 static const char __pyx_k_maxima
[] = "maxima";
2111 static const char __pyx_k_resize
[] = "resize";
2112 static const char __pyx_k_signal
[] = "signal";
2113 static const char __pyx_k_unique
[] = "unique";
2114 static const char __pyx_k_float32
[] = "float32";
2115 static const char __pyx_k_float64
[] = "float64";
2116 static const char __pyx_k_summits
[] = "summits";
2117 static const char __pyx_k_convolve
[] = "convolve";
2118 static const char __pyx_k_mathsqrt
[] = "mathsqrt";
2119 static const char __pyx_k_refcheck
[] = "refcheck";
2120 static const char __pyx_k_TypeError
[] = "TypeError";
2121 static const char __pyx_k_factorial
[] = "factorial";
2122 static const char __pyx_k_ValueError
[] = "ValueError";
2123 static const char __pyx_k_min_valley
[] = "min_valley";
2124 static const char __pyx_k_ImportError
[] = "ImportError";
2125 static const char __pyx_k_concatenate
[] = "concatenate";
2126 static const char __pyx_k_window_size
[] = "window_size";
2127 static const char __pyx_k_RuntimeError
[] = "RuntimeError";
2128 static const char __pyx_k_mathfactorial
[] = "mathfactorial";
2129 static const char __pyx_k_cline_in_traceback
[] = "cline_in_traceback";
2130 static const char __pyx_k_ndarray_is_not_C_contiguous
[] = "ndarray is not C contiguous";
2131 static const char __pyx_k_Module_Description_functions_to
[] = "Module Description: functions to find maxima minima or smooth the\nsignal tracks.\n\nThis code is free software; you can redistribute it and/or modify it\nunder the terms of the BSD License (see the file LICENSE included with\nthe distribution).\n";
2132 static const char __pyx_k_numpy_core_multiarray_failed_to
[] = "numpy.core.multiarray failed to import";
2133 static const char __pyx_k_unknown_dtype_code_in_numpy_pxd
[] = "unknown dtype code in numpy.pxd (%d)";
2134 static const char __pyx_k_Format_string_allocated_too_shor
[] = "Format string allocated too short, see comment in numpy.pxd";
2135 static const char __pyx_k_Non_native_byte_order_not_suppor
[] = "Non-native byte order not supported";
2136 static const char __pyx_k_ndarray_is_not_Fortran_contiguou
[] = "ndarray is not Fortran contiguous";
2137 static const char __pyx_k_numpy_core_umath_failed_to_impor
[] = "numpy.core.umath failed to import";
2138 static const char __pyx_k_window_size_and_order_have_to_be
[] = "window_size and order have to be of type int";
2139 static const char __pyx_k_window_size_is_too_small_for_the
[] = "window_size is too small for the polynomials order";
2140 static const char __pyx_k_window_size_size_must_be_a_posit
[] = "window_size size must be a positive odd number";
2141 static const char __pyx_k_Format_string_allocated_too_shor_2
[] = "Format string allocated too short.";
2142 static PyObject
*__pyx_kp_u_Format_string_allocated_too_shor
;
2143 static PyObject
*__pyx_kp_u_Format_string_allocated_too_shor_2
;
2144 static PyObject
*__pyx_n_s_ImportError
;
2145 static PyObject
*__pyx_kp_u_Non_native_byte_order_not_suppor
;
2146 static PyObject
*__pyx_n_s_RuntimeError
;
2147 static PyObject
*__pyx_n_s_TypeError
;
2148 static PyObject
*__pyx_n_s_ValueError
;
2149 static PyObject
*__pyx_n_s_abs
;
2150 static PyObject
*__pyx_n_s_any
;
2151 static PyObject
*__pyx_n_s_array
;
2152 static PyObject
*__pyx_n_s_astype
;
2153 static PyObject
*__pyx_n_s_cline_in_traceback
;
2154 static PyObject
*__pyx_n_s_concatenate
;
2155 static PyObject
*__pyx_n_s_convolve
;
2156 static PyObject
*__pyx_n_s_copy
;
2157 static PyObject
*__pyx_n_s_deriv
;
2158 static PyObject
*__pyx_n_s_diff
;
2159 static PyObject
*__pyx_n_s_dtype
;
2160 static PyObject
*__pyx_n_s_factorial
;
2161 static PyObject
*__pyx_n_u_float32
;
2162 static PyObject
*__pyx_n_u_float64
;
2163 static PyObject
*__pyx_n_s_import
;
2164 static PyObject
*__pyx_n_s_int
;
2165 static PyObject
*__pyx_n_u_int32
;
2166 static PyObject
*__pyx_n_u_int64
;
2167 static PyObject
*__pyx_n_s_linalg
;
2168 static PyObject
*__pyx_n_s_main
;
2169 static PyObject
*__pyx_n_s_math
;
2170 static PyObject
*__pyx_n_s_mathfactorial
;
2171 static PyObject
*__pyx_n_s_mathsqrt
;
2172 static PyObject
*__pyx_n_s_maxima
;
2173 static PyObject
*__pyx_n_s_min
;
2174 static PyObject
*__pyx_n_s_min_valley
;
2175 static PyObject
*__pyx_n_s_mode
;
2176 static PyObject
*__pyx_n_s_name
;
2177 static PyObject
*__pyx_kp_u_ndarray_is_not_C_contiguous
;
2178 static PyObject
*__pyx_kp_u_ndarray_is_not_Fortran_contiguou
;
2179 static PyObject
*__pyx_n_s_np
;
2180 static PyObject
*__pyx_n_s_numpy
;
2181 static PyObject
*__pyx_kp_u_numpy_core_multiarray_failed_to
;
2182 static PyObject
*__pyx_kp_u_numpy_core_umath_failed_to_impor
;
2183 static PyObject
*__pyx_n_s_order
;
2184 static PyObject
*__pyx_n_s_pinv
;
2185 static PyObject
*__pyx_n_s_range
;
2186 static PyObject
*__pyx_n_s_rate
;
2187 static PyObject
*__pyx_n_s_refcheck
;
2188 static PyObject
*__pyx_n_s_resize
;
2189 static PyObject
*__pyx_n_s_round
;
2190 static PyObject
*__pyx_n_s_shape
;
2191 static PyObject
*__pyx_n_s_sign
;
2192 static PyObject
*__pyx_n_s_signal
;
2193 static PyObject
*__pyx_n_s_sqrt
;
2194 static PyObject
*__pyx_n_s_summits
;
2195 static PyObject
*__pyx_n_s_test
;
2196 static PyObject
*__pyx_n_s_unique
;
2197 static PyObject
*__pyx_kp_u_unknown_dtype_code_in_numpy_pxd
;
2198 static PyObject
*__pyx_n_u_valid
;
2199 static PyObject
*__pyx_n_s_where
;
2200 static PyObject
*__pyx_n_s_window_size
;
2201 static PyObject
*__pyx_kp_u_window_size_and_order_have_to_be
;
2202 static PyObject
*__pyx_kp_u_window_size_is_too_small_for_the
;
2203 static PyObject
*__pyx_kp_u_window_size_size_must_be_a_posit
;
2204 static PyObject
*__pyx_n_s_y
;
2205 static PyObject
*__pyx_n_s_zeros
;
2206 static PyObject
*__pyx_pf_5MACS2_6Signal_maxima(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, int __pyx_v_window_size
); /* proto */
2207 static PyObject
*__pyx_pf_5MACS2_6Signal_2enforce_peakyness(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, PyArrayObject
*__pyx_v_maxima
); /* proto */
2208 static PyObject
*__pyx_pf_5MACS2_6Signal_4enforce_valleys(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, PyArrayObject
*__pyx_v_summits
, float __pyx_v_min_valley
); /* proto */
2209 static PyObject
*__pyx_pf_5MACS2_6Signal_6savitzky_golay_order2_deriv1(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, int __pyx_v_window_size
); /* proto */
2210 static PyObject
*__pyx_pf_5MACS2_6Signal_8savitzky_golay(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_y
, int __pyx_v_window_size
, int __pyx_v_order
, int __pyx_v_deriv
, int __pyx_v_rate
); /* proto */
2211 static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
, int __pyx_v_flags
); /* proto */
2212 static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
); /* proto */
2213 static PyObject
*__pyx_int_0
;
2214 static PyObject
*__pyx_int_1
;
2215 static PyObject
*__pyx_int_6
;
2216 static PyObject
*__pyx_int_16
;
2217 static PyObject
*__pyx_int_neg_1
;
2218 static PyObject
*__pyx_tuple_
;
2219 static PyObject
*__pyx_slice__2
;
2220 static PyObject
*__pyx_tuple__3
;
2221 static PyObject
*__pyx_tuple__4
;
2222 static PyObject
*__pyx_tuple__5
;
2223 static PyObject
*__pyx_tuple__6
;
2224 static PyObject
*__pyx_tuple__7
;
2225 static PyObject
*__pyx_tuple__8
;
2226 static PyObject
*__pyx_tuple__9
;
2227 static PyObject
*__pyx_tuple__10
;
2228 static PyObject
*__pyx_tuple__11
;
2229 static PyObject
*__pyx_tuple__12
;
2232 /* "MACS2/Signal.pyx":20
2233 * from math import factorial as mathfactorial
2235 * cpdef np.ndarray[np.int32_t, ndim=1] maxima(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
2236 * int window_size=51):
2237 * """return the local maxima in a signal after applying a 2nd order
2240 static PyObject
*__pyx_pw_5MACS2_6Signal_1maxima(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
2241 static PyArrayObject
*__pyx_f_5MACS2_6Signal_maxima(PyArrayObject
*__pyx_v_signal
, CYTHON_UNUSED
int __pyx_skip_dispatch
, struct __pyx_opt_args_5MACS2_6Signal_maxima
*__pyx_optional_args
) {
2242 int __pyx_v_window_size
= ((int)51);
2243 PyArrayObject
*__pyx_v_m
= 0;
2244 PyArrayObject
*__pyx_v_smoothed
= 0;
2245 PyArrayObject
*__pyx_v_sign
= 0;
2246 PyArrayObject
*__pyx_v_diff
= 0;
2247 __Pyx_LocalBuf_ND __pyx_pybuffernd_diff
;
2248 __Pyx_Buffer __pyx_pybuffer_diff
;
2249 __Pyx_LocalBuf_ND __pyx_pybuffernd_m
;
2250 __Pyx_Buffer __pyx_pybuffer_m
;
2251 __Pyx_LocalBuf_ND __pyx_pybuffernd_sign
;
2252 __Pyx_Buffer __pyx_pybuffer_sign
;
2253 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
2254 __Pyx_Buffer __pyx_pybuffer_signal
;
2255 __Pyx_LocalBuf_ND __pyx_pybuffernd_smoothed
;
2256 __Pyx_Buffer __pyx_pybuffer_smoothed
;
2257 PyArrayObject
*__pyx_r
= NULL
;
2258 __Pyx_TraceDeclarations
2259 __Pyx_RefNannyDeclarations
2260 PyObject
*__pyx_t_1
= NULL
;
2261 PyObject
*__pyx_t_2
= NULL
;
2262 PyObject
*__pyx_t_3
= NULL
;
2263 PyArrayObject
*__pyx_t_4
= NULL
;
2265 PyObject
*__pyx_t_6
= NULL
;
2266 PyObject
*__pyx_t_7
= NULL
;
2267 PyObject
*__pyx_t_8
= NULL
;
2268 PyObject
*__pyx_t_9
= NULL
;
2269 PyObject
*__pyx_t_10
= NULL
;
2270 PyArrayObject
*__pyx_t_11
= NULL
;
2271 PyArrayObject
*__pyx_t_12
= NULL
;
2272 __Pyx_RefNannySetupContext("maxima", 0);
2273 __Pyx_TraceCall("maxima", __pyx_f
[0], 20, 0, __PYX_ERR(0, 20, __pyx_L1_error
));
2274 if (__pyx_optional_args
) {
2275 if (__pyx_optional_args
->__pyx_n
> 0) {
2276 __pyx_v_window_size
= __pyx_optional_args
->window_size
;
2279 __pyx_pybuffer_m
.pybuffer
.buf
= NULL
;
2280 __pyx_pybuffer_m
.refcount
= 0;
2281 __pyx_pybuffernd_m
.data
= NULL
;
2282 __pyx_pybuffernd_m
.rcbuffer
= &__pyx_pybuffer_m
;
2283 __pyx_pybuffer_smoothed
.pybuffer
.buf
= NULL
;
2284 __pyx_pybuffer_smoothed
.refcount
= 0;
2285 __pyx_pybuffernd_smoothed
.data
= NULL
;
2286 __pyx_pybuffernd_smoothed
.rcbuffer
= &__pyx_pybuffer_smoothed
;
2287 __pyx_pybuffer_sign
.pybuffer
.buf
= NULL
;
2288 __pyx_pybuffer_sign
.refcount
= 0;
2289 __pyx_pybuffernd_sign
.data
= NULL
;
2290 __pyx_pybuffernd_sign
.rcbuffer
= &__pyx_pybuffer_sign
;
2291 __pyx_pybuffer_diff
.pybuffer
.buf
= NULL
;
2292 __pyx_pybuffer_diff
.refcount
= 0;
2293 __pyx_pybuffernd_diff
.data
= NULL
;
2294 __pyx_pybuffernd_diff
.rcbuffer
= &__pyx_pybuffer_diff
;
2295 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
2296 __pyx_pybuffer_signal
.refcount
= 0;
2297 __pyx_pybuffernd_signal
.data
= NULL
;
2298 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
2300 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2301 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 20, __pyx_L1_error
)
2303 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
2305 /* "MACS2/Signal.pyx":30
2306 * np.ndarray[np.float32_t, ndim=1] sign, diff
2308 * window_size = window_size//2*2+1 # to make an odd number # <<<<<<<<<<<<<<
2309 * smoothed = savitzky_golay_order2_deriv1(signal, window_size).round(16)
2310 * sign = np.sign( smoothed.astype("float32") )
2312 __pyx_v_window_size
= ((__Pyx_div_long(__pyx_v_window_size
, 2) * 2) + 1);
2314 /* "MACS2/Signal.pyx":31
2316 * window_size = window_size//2*2+1 # to make an odd number
2317 * smoothed = savitzky_golay_order2_deriv1(signal, window_size).round(16) # <<<<<<<<<<<<<<
2318 * sign = np.sign( smoothed.astype("float32") )
2319 * diff = np.diff( sign )
2321 __pyx_t_2
= ((PyObject
*)__pyx_f_5MACS2_6Signal_savitzky_golay_order2_deriv1(((PyArrayObject
*)__pyx_v_signal
), __pyx_v_window_size
, 0)); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 31, __pyx_L1_error
)
2322 __Pyx_GOTREF(__pyx_t_2
);
2323 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_round
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 31, __pyx_L1_error
)
2324 __Pyx_GOTREF(__pyx_t_3
);
2325 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
2327 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_3
))) {
2328 __pyx_t_2
= PyMethod_GET_SELF(__pyx_t_3
);
2329 if (likely(__pyx_t_2
)) {
2330 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_3
);
2331 __Pyx_INCREF(__pyx_t_2
);
2332 __Pyx_INCREF(function
);
2333 __Pyx_DECREF_SET(__pyx_t_3
, function
);
2336 __pyx_t_1
= (__pyx_t_2
) ? __Pyx_PyObject_Call2Args(__pyx_t_3
, __pyx_t_2
, __pyx_int_16
) : __Pyx_PyObject_CallOneArg(__pyx_t_3
, __pyx_int_16
);
2337 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
2338 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 31, __pyx_L1_error
)
2339 __Pyx_GOTREF(__pyx_t_1
);
2340 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
2341 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 31, __pyx_L1_error
)
2342 __pyx_t_4
= ((PyArrayObject
*)__pyx_t_1
);
2344 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2345 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_smoothed
.rcbuffer
->pybuffer
);
2346 __pyx_t_5
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_smoothed
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_4
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
2347 if (unlikely(__pyx_t_5
< 0)) {
2348 PyErr_Fetch(&__pyx_t_6
, &__pyx_t_7
, &__pyx_t_8
);
2349 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_smoothed
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_smoothed
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
2350 Py_XDECREF(__pyx_t_6
); Py_XDECREF(__pyx_t_7
); Py_XDECREF(__pyx_t_8
);
2351 __Pyx_RaiseBufferFallbackError();
2353 PyErr_Restore(__pyx_t_6
, __pyx_t_7
, __pyx_t_8
);
2355 __pyx_t_6
= __pyx_t_7
= __pyx_t_8
= 0;
2357 __pyx_pybuffernd_smoothed
.diminfo
[0].strides
= __pyx_pybuffernd_smoothed
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_smoothed
.diminfo
[0].shape
= __pyx_pybuffernd_smoothed
.rcbuffer
->pybuffer
.shape
[0];
2358 if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 31, __pyx_L1_error
)
2361 __pyx_v_smoothed
= ((PyArrayObject
*)__pyx_t_1
);
2364 /* "MACS2/Signal.pyx":32
2365 * window_size = window_size//2*2+1 # to make an odd number
2366 * smoothed = savitzky_golay_order2_deriv1(signal, window_size).round(16)
2367 * sign = np.sign( smoothed.astype("float32") ) # <<<<<<<<<<<<<<
2368 * diff = np.diff( sign )
2369 * m = np.where( diff <= -1)[0].astype('int32')
2371 __Pyx_GetModuleGlobalName(__pyx_t_3
, __pyx_n_s_np
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 32, __pyx_L1_error
)
2372 __Pyx_GOTREF(__pyx_t_3
);
2373 __pyx_t_2
= __Pyx_PyObject_GetAttrStr(__pyx_t_3
, __pyx_n_s_sign
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 32, __pyx_L1_error
)
2374 __Pyx_GOTREF(__pyx_t_2
);
2375 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
2376 __pyx_t_9
= __Pyx_PyObject_GetAttrStr(((PyObject
*)__pyx_v_smoothed
), __pyx_n_s_astype
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 32, __pyx_L1_error
)
2377 __Pyx_GOTREF(__pyx_t_9
);
2379 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_9
))) {
2380 __pyx_t_10
= PyMethod_GET_SELF(__pyx_t_9
);
2381 if (likely(__pyx_t_10
)) {
2382 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_9
);
2383 __Pyx_INCREF(__pyx_t_10
);
2384 __Pyx_INCREF(function
);
2385 __Pyx_DECREF_SET(__pyx_t_9
, function
);
2388 __pyx_t_3
= (__pyx_t_10
) ? __Pyx_PyObject_Call2Args(__pyx_t_9
, __pyx_t_10
, __pyx_n_u_float32
) : __Pyx_PyObject_CallOneArg(__pyx_t_9
, __pyx_n_u_float32
);
2389 __Pyx_XDECREF(__pyx_t_10
); __pyx_t_10
= 0;
2390 if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 32, __pyx_L1_error
)
2391 __Pyx_GOTREF(__pyx_t_3
);
2392 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
2394 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_2
))) {
2395 __pyx_t_9
= PyMethod_GET_SELF(__pyx_t_2
);
2396 if (likely(__pyx_t_9
)) {
2397 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_2
);
2398 __Pyx_INCREF(__pyx_t_9
);
2399 __Pyx_INCREF(function
);
2400 __Pyx_DECREF_SET(__pyx_t_2
, function
);
2403 __pyx_t_1
= (__pyx_t_9
) ? __Pyx_PyObject_Call2Args(__pyx_t_2
, __pyx_t_9
, __pyx_t_3
) : __Pyx_PyObject_CallOneArg(__pyx_t_2
, __pyx_t_3
);
2404 __Pyx_XDECREF(__pyx_t_9
); __pyx_t_9
= 0;
2405 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
2406 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 32, __pyx_L1_error
)
2407 __Pyx_GOTREF(__pyx_t_1
);
2408 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
2409 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 32, __pyx_L1_error
)
2410 __pyx_t_11
= ((PyArrayObject
*)__pyx_t_1
);
2412 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2413 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sign
.rcbuffer
->pybuffer
);
2414 __pyx_t_5
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sign
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_11
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
2415 if (unlikely(__pyx_t_5
< 0)) {
2416 PyErr_Fetch(&__pyx_t_8
, &__pyx_t_7
, &__pyx_t_6
);
2417 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sign
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_sign
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
2418 Py_XDECREF(__pyx_t_8
); Py_XDECREF(__pyx_t_7
); Py_XDECREF(__pyx_t_6
);
2419 __Pyx_RaiseBufferFallbackError();
2421 PyErr_Restore(__pyx_t_8
, __pyx_t_7
, __pyx_t_6
);
2423 __pyx_t_8
= __pyx_t_7
= __pyx_t_6
= 0;
2425 __pyx_pybuffernd_sign
.diminfo
[0].strides
= __pyx_pybuffernd_sign
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_sign
.diminfo
[0].shape
= __pyx_pybuffernd_sign
.rcbuffer
->pybuffer
.shape
[0];
2426 if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 32, __pyx_L1_error
)
2429 __pyx_v_sign
= ((PyArrayObject
*)__pyx_t_1
);
2432 /* "MACS2/Signal.pyx":33
2433 * smoothed = savitzky_golay_order2_deriv1(signal, window_size).round(16)
2434 * sign = np.sign( smoothed.astype("float32") )
2435 * diff = np.diff( sign ) # <<<<<<<<<<<<<<
2436 * m = np.where( diff <= -1)[0].astype('int32')
2439 __Pyx_GetModuleGlobalName(__pyx_t_2
, __pyx_n_s_np
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 33, __pyx_L1_error
)
2440 __Pyx_GOTREF(__pyx_t_2
);
2441 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_diff
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 33, __pyx_L1_error
)
2442 __Pyx_GOTREF(__pyx_t_3
);
2443 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
2445 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_3
))) {
2446 __pyx_t_2
= PyMethod_GET_SELF(__pyx_t_3
);
2447 if (likely(__pyx_t_2
)) {
2448 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_3
);
2449 __Pyx_INCREF(__pyx_t_2
);
2450 __Pyx_INCREF(function
);
2451 __Pyx_DECREF_SET(__pyx_t_3
, function
);
2454 __pyx_t_1
= (__pyx_t_2
) ? __Pyx_PyObject_Call2Args(__pyx_t_3
, __pyx_t_2
, ((PyObject
*)__pyx_v_sign
)) : __Pyx_PyObject_CallOneArg(__pyx_t_3
, ((PyObject
*)__pyx_v_sign
));
2455 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
2456 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 33, __pyx_L1_error
)
2457 __Pyx_GOTREF(__pyx_t_1
);
2458 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
2459 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 33, __pyx_L1_error
)
2460 __pyx_t_11
= ((PyArrayObject
*)__pyx_t_1
);
2462 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2463 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_diff
.rcbuffer
->pybuffer
);
2464 __pyx_t_5
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_diff
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_11
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
2465 if (unlikely(__pyx_t_5
< 0)) {
2466 PyErr_Fetch(&__pyx_t_6
, &__pyx_t_7
, &__pyx_t_8
);
2467 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_diff
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_diff
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
2468 Py_XDECREF(__pyx_t_6
); Py_XDECREF(__pyx_t_7
); Py_XDECREF(__pyx_t_8
);
2469 __Pyx_RaiseBufferFallbackError();
2471 PyErr_Restore(__pyx_t_6
, __pyx_t_7
, __pyx_t_8
);
2473 __pyx_t_6
= __pyx_t_7
= __pyx_t_8
= 0;
2475 __pyx_pybuffernd_diff
.diminfo
[0].strides
= __pyx_pybuffernd_diff
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_diff
.diminfo
[0].shape
= __pyx_pybuffernd_diff
.rcbuffer
->pybuffer
.shape
[0];
2476 if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 33, __pyx_L1_error
)
2479 __pyx_v_diff
= ((PyArrayObject
*)__pyx_t_1
);
2482 /* "MACS2/Signal.pyx":34
2483 * sign = np.sign( smoothed.astype("float32") )
2484 * diff = np.diff( sign )
2485 * m = np.where( diff <= -1)[0].astype('int32') # <<<<<<<<<<<<<<
2489 __Pyx_GetModuleGlobalName(__pyx_t_2
, __pyx_n_s_np
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 34, __pyx_L1_error
)
2490 __Pyx_GOTREF(__pyx_t_2
);
2491 __pyx_t_9
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_where
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 34, __pyx_L1_error
)
2492 __Pyx_GOTREF(__pyx_t_9
);
2493 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
2494 __pyx_t_2
= PyObject_RichCompare(((PyObject
*)__pyx_v_diff
), __pyx_int_neg_1
, Py_LE
); __Pyx_XGOTREF(__pyx_t_2
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 34, __pyx_L1_error
)
2496 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_9
))) {
2497 __pyx_t_10
= PyMethod_GET_SELF(__pyx_t_9
);
2498 if (likely(__pyx_t_10
)) {
2499 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_9
);
2500 __Pyx_INCREF(__pyx_t_10
);
2501 __Pyx_INCREF(function
);
2502 __Pyx_DECREF_SET(__pyx_t_9
, function
);
2505 __pyx_t_3
= (__pyx_t_10
) ? __Pyx_PyObject_Call2Args(__pyx_t_9
, __pyx_t_10
, __pyx_t_2
) : __Pyx_PyObject_CallOneArg(__pyx_t_9
, __pyx_t_2
);
2506 __Pyx_XDECREF(__pyx_t_10
); __pyx_t_10
= 0;
2507 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
2508 if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 34, __pyx_L1_error
)
2509 __Pyx_GOTREF(__pyx_t_3
);
2510 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
2511 __pyx_t_9
= __Pyx_GetItemInt(__pyx_t_3
, 0, long, 1, __Pyx_PyInt_From_long
, 0, 0, 1); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 34, __pyx_L1_error
)
2512 __Pyx_GOTREF(__pyx_t_9
);
2513 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
2514 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_9
, __pyx_n_s_astype
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 34, __pyx_L1_error
)
2515 __Pyx_GOTREF(__pyx_t_3
);
2516 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
2518 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_3
))) {
2519 __pyx_t_9
= PyMethod_GET_SELF(__pyx_t_3
);
2520 if (likely(__pyx_t_9
)) {
2521 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_3
);
2522 __Pyx_INCREF(__pyx_t_9
);
2523 __Pyx_INCREF(function
);
2524 __Pyx_DECREF_SET(__pyx_t_3
, function
);
2527 __pyx_t_1
= (__pyx_t_9
) ? __Pyx_PyObject_Call2Args(__pyx_t_3
, __pyx_t_9
, __pyx_n_u_int32
) : __Pyx_PyObject_CallOneArg(__pyx_t_3
, __pyx_n_u_int32
);
2528 __Pyx_XDECREF(__pyx_t_9
); __pyx_t_9
= 0;
2529 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 34, __pyx_L1_error
)
2530 __Pyx_GOTREF(__pyx_t_1
);
2531 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
2532 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 34, __pyx_L1_error
)
2533 __pyx_t_12
= ((PyArrayObject
*)__pyx_t_1
);
2535 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2536 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
2537 __pyx_t_5
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_12
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
2538 if (unlikely(__pyx_t_5
< 0)) {
2539 PyErr_Fetch(&__pyx_t_8
, &__pyx_t_7
, &__pyx_t_6
);
2540 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_m
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
2541 Py_XDECREF(__pyx_t_8
); Py_XDECREF(__pyx_t_7
); Py_XDECREF(__pyx_t_6
);
2542 __Pyx_RaiseBufferFallbackError();
2544 PyErr_Restore(__pyx_t_8
, __pyx_t_7
, __pyx_t_6
);
2546 __pyx_t_8
= __pyx_t_7
= __pyx_t_6
= 0;
2548 __pyx_pybuffernd_m
.diminfo
[0].strides
= __pyx_pybuffernd_m
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_m
.diminfo
[0].shape
= __pyx_pybuffernd_m
.rcbuffer
->pybuffer
.shape
[0];
2549 if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 34, __pyx_L1_error
)
2552 __pyx_v_m
= ((PyArrayObject
*)__pyx_t_1
);
2555 /* "MACS2/Signal.pyx":35
2556 * diff = np.diff( sign )
2557 * m = np.where( diff <= -1)[0].astype('int32')
2558 * return m # <<<<<<<<<<<<<<
2560 * cdef np.ndarray[np.int32_t, ndim=1] internal_minima( np.ndarray[np.float32_t, ndim=1] signal,
2562 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
2563 __Pyx_INCREF(((PyObject
*)__pyx_v_m
));
2564 __pyx_r
= ((PyArrayObject
*)__pyx_v_m
);
2567 /* "MACS2/Signal.pyx":20
2568 * from math import factorial as mathfactorial
2570 * cpdef np.ndarray[np.int32_t, ndim=1] maxima(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
2571 * int window_size=51):
2572 * """return the local maxima in a signal after applying a 2nd order
2575 /* function exit code */
2577 __Pyx_XDECREF(__pyx_t_1
);
2578 __Pyx_XDECREF(__pyx_t_2
);
2579 __Pyx_XDECREF(__pyx_t_3
);
2580 __Pyx_XDECREF(__pyx_t_9
);
2581 __Pyx_XDECREF(__pyx_t_10
);
2582 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
2583 __Pyx_PyThreadState_declare
2584 __Pyx_PyThreadState_assign
2585 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
2586 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_diff
.rcbuffer
->pybuffer
);
2587 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
2588 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sign
.rcbuffer
->pybuffer
);
2589 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
2590 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_smoothed
.rcbuffer
->pybuffer
);
2591 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
2592 __Pyx_AddTraceback("MACS2.Signal.maxima", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
2596 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_diff
.rcbuffer
->pybuffer
);
2597 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
2598 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sign
.rcbuffer
->pybuffer
);
2599 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
2600 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_smoothed
.rcbuffer
->pybuffer
);
2602 __Pyx_XDECREF((PyObject
*)__pyx_v_m
);
2603 __Pyx_XDECREF((PyObject
*)__pyx_v_smoothed
);
2604 __Pyx_XDECREF((PyObject
*)__pyx_v_sign
);
2605 __Pyx_XDECREF((PyObject
*)__pyx_v_diff
);
2606 __Pyx_XGIVEREF((PyObject
*)__pyx_r
);
2607 __Pyx_TraceReturn(__pyx_r
, 0);
2608 __Pyx_RefNannyFinishContext();
2612 /* Python wrapper */
2613 static PyObject
*__pyx_pw_5MACS2_6Signal_1maxima(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
2614 static char __pyx_doc_5MACS2_6Signal_maxima
[] = "return the local maxima in a signal after applying a 2nd order\n Savitsky-Golay (polynomial) filter using window_size specified \n ";
2615 static PyObject
*__pyx_pw_5MACS2_6Signal_1maxima(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
) {
2616 PyArrayObject
*__pyx_v_signal
= 0;
2617 int __pyx_v_window_size
;
2618 PyObject
*__pyx_r
= 0;
2619 __Pyx_RefNannyDeclarations
2620 __Pyx_RefNannySetupContext("maxima (wrapper)", 0);
2622 static PyObject
**__pyx_pyargnames
[] = {&__pyx_n_s_signal
,&__pyx_n_s_window_size
,0};
2623 PyObject
* values
[2] = {0,0};
2624 if (unlikely(__pyx_kwds
)) {
2626 const Py_ssize_t pos_args
= PyTuple_GET_SIZE(__pyx_args
);
2628 case 2: values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
2630 case 1: values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
2633 default: goto __pyx_L5_argtuple_error
;
2635 kw_args
= PyDict_Size(__pyx_kwds
);
2638 if (likely((values
[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_signal
)) != 0)) kw_args
--;
2639 else goto __pyx_L5_argtuple_error
;
2643 PyObject
* value
= __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_window_size
);
2644 if (value
) { values
[1] = value
; kw_args
--; }
2647 if (unlikely(kw_args
> 0)) {
2648 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds
, __pyx_pyargnames
, 0, values
, pos_args
, "maxima") < 0)) __PYX_ERR(0, 20, __pyx_L3_error
)
2651 switch (PyTuple_GET_SIZE(__pyx_args
)) {
2652 case 2: values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
2654 case 1: values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
2656 default: goto __pyx_L5_argtuple_error
;
2659 __pyx_v_signal
= ((PyArrayObject
*)values
[0]);
2661 __pyx_v_window_size
= __Pyx_PyInt_As_int(values
[1]); if (unlikely((__pyx_v_window_size
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error
)
2663 __pyx_v_window_size
= ((int)51);
2666 goto __pyx_L4_argument_unpacking_done
;
2667 __pyx_L5_argtuple_error
:;
2668 __Pyx_RaiseArgtupleInvalid("maxima", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args
)); __PYX_ERR(0, 20, __pyx_L3_error
)
2670 __Pyx_AddTraceback("MACS2.Signal.maxima", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
2671 __Pyx_RefNannyFinishContext();
2673 __pyx_L4_argument_unpacking_done
:;
2674 if (unlikely(!__Pyx_ArgTypeTest(((PyObject
*)__pyx_v_signal
), __pyx_ptype_5numpy_ndarray
, 1, "signal", 0))) __PYX_ERR(0, 20, __pyx_L1_error
)
2675 __pyx_r
= __pyx_pf_5MACS2_6Signal_maxima(__pyx_self
, __pyx_v_signal
, __pyx_v_window_size
);
2677 /* function exit code */
2682 __Pyx_RefNannyFinishContext();
2686 static PyObject
*__pyx_pf_5MACS2_6Signal_maxima(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, int __pyx_v_window_size
) {
2687 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
2688 __Pyx_Buffer __pyx_pybuffer_signal
;
2689 PyObject
*__pyx_r
= NULL
;
2690 __Pyx_TraceDeclarations
2691 __Pyx_RefNannyDeclarations
2692 PyObject
*__pyx_t_1
= NULL
;
2693 struct __pyx_opt_args_5MACS2_6Signal_maxima __pyx_t_2
;
2694 __Pyx_RefNannySetupContext("maxima", 0);
2695 __Pyx_TraceCall("maxima (wrapper)", __pyx_f
[0], 20, 0, __PYX_ERR(0, 20, __pyx_L1_error
));
2696 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
2697 __pyx_pybuffer_signal
.refcount
= 0;
2698 __pyx_pybuffernd_signal
.data
= NULL
;
2699 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
2701 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2702 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 20, __pyx_L1_error
)
2704 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
2705 __Pyx_XDECREF(__pyx_r
);
2706 __pyx_t_2
.__pyx_n
= 1;
2707 __pyx_t_2
.window_size
= __pyx_v_window_size
;
2708 __pyx_t_1
= ((PyObject
*)__pyx_f_5MACS2_6Signal_maxima(__pyx_v_signal
, 0, &__pyx_t_2
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 20, __pyx_L1_error
)
2709 __Pyx_GOTREF(__pyx_t_1
);
2710 __pyx_r
= __pyx_t_1
;
2714 /* function exit code */
2716 __Pyx_XDECREF(__pyx_t_1
);
2717 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
2718 __Pyx_PyThreadState_declare
2719 __Pyx_PyThreadState_assign
2720 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
2721 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
2722 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
2723 __Pyx_AddTraceback("MACS2.Signal.maxima", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
2727 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
2729 __Pyx_XGIVEREF(__pyx_r
);
2730 __Pyx_TraceReturn(__pyx_r
, 0);
2731 __Pyx_RefNannyFinishContext();
2735 /* "MACS2/Signal.pyx":37
2738 * cdef np.ndarray[np.int32_t, ndim=1] internal_minima( np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
2739 * np.ndarray[np.int32_t, ndim=1] maxima ):
2743 static PyArrayObject
*__pyx_f_5MACS2_6Signal_internal_minima(PyArrayObject
*__pyx_v_signal
, PyArrayObject
*__pyx_v_maxima
) {
2744 PyArrayObject
*__pyx_v_ret
= 0;
2747 PyObject
*__pyx_v_pos1
= NULL
;
2748 PyObject
*__pyx_v_pos2
= NULL
;
2749 __Pyx_LocalBuf_ND __pyx_pybuffernd_maxima
;
2750 __Pyx_Buffer __pyx_pybuffer_maxima
;
2751 __Pyx_LocalBuf_ND __pyx_pybuffernd_ret
;
2752 __Pyx_Buffer __pyx_pybuffer_ret
;
2753 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
2754 __Pyx_Buffer __pyx_pybuffer_signal
;
2755 PyArrayObject
*__pyx_r
= NULL
;
2756 __Pyx_TraceDeclarations
2757 __Pyx_RefNannyDeclarations
2758 PyObject
*__pyx_t_1
= NULL
;
2760 PyObject
*__pyx_t_3
= NULL
;
2761 PyObject
*__pyx_t_4
= NULL
;
2762 PyObject
*__pyx_t_5
= NULL
;
2763 PyObject
*__pyx_t_6
= NULL
;
2764 PyObject
*__pyx_t_7
= NULL
;
2765 PyObject
*__pyx_t_8
= NULL
;
2766 PyObject
*__pyx_t_9
= NULL
;
2767 PyArrayObject
*__pyx_t_10
= NULL
;
2768 Py_ssize_t __pyx_t_11
;
2771 Py_ssize_t __pyx_t_14
;
2773 PyObject
*__pyx_t_16
= NULL
;
2774 __pyx_t_5numpy_int32_t __pyx_t_17
;
2775 Py_ssize_t __pyx_t_18
;
2776 __Pyx_RefNannySetupContext("internal_minima", 0);
2777 __Pyx_TraceCall("internal_minima", __pyx_f
[0], 37, 0, __PYX_ERR(0, 37, __pyx_L1_error
));
2778 __pyx_pybuffer_ret
.pybuffer
.buf
= NULL
;
2779 __pyx_pybuffer_ret
.refcount
= 0;
2780 __pyx_pybuffernd_ret
.data
= NULL
;
2781 __pyx_pybuffernd_ret
.rcbuffer
= &__pyx_pybuffer_ret
;
2782 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
2783 __pyx_pybuffer_signal
.refcount
= 0;
2784 __pyx_pybuffernd_signal
.data
= NULL
;
2785 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
2786 __pyx_pybuffer_maxima
.pybuffer
.buf
= NULL
;
2787 __pyx_pybuffer_maxima
.refcount
= 0;
2788 __pyx_pybuffernd_maxima
.data
= NULL
;
2789 __pyx_pybuffernd_maxima
.rcbuffer
= &__pyx_pybuffer_maxima
;
2791 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2792 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 37, __pyx_L1_error
)
2794 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
2796 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2797 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_maxima
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 37, __pyx_L1_error
)
2799 __pyx_pybuffernd_maxima
.diminfo
[0].strides
= __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_maxima
.diminfo
[0].shape
= __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.shape
[0];
2801 /* "MACS2/Signal.pyx":41
2803 * np.ndarray[np.int32_t, ndim=1] ret
2804 * int n = maxima.shape[0] # <<<<<<<<<<<<<<
2806 * if n == 0 or n == 1:
2808 __pyx_v_n
= (__pyx_v_maxima
->dimensions
[0]);
2810 /* "MACS2/Signal.pyx":43
2811 * int n = maxima.shape[0]
2813 * if n == 0 or n == 1: # <<<<<<<<<<<<<<
2814 * ret = np.ndarray(0, 'int32')
2817 switch (__pyx_v_n
) {
2821 /* "MACS2/Signal.pyx":44
2823 * if n == 0 or n == 1:
2824 * ret = np.ndarray(0, 'int32') # <<<<<<<<<<<<<<
2828 __pyx_t_1
= __Pyx_PyObject_Call(((PyObject
*)__pyx_ptype_5numpy_ndarray
), __pyx_tuple_
, NULL
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 44, __pyx_L1_error
)
2829 __Pyx_GOTREF(__pyx_t_1
);
2831 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2832 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
2833 __pyx_t_2
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)((PyArrayObject
*)__pyx_t_1
), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
| PyBUF_WRITABLE
, 1, 0, __pyx_stack
);
2834 if (unlikely(__pyx_t_2
< 0)) {
2835 PyErr_Fetch(&__pyx_t_3
, &__pyx_t_4
, &__pyx_t_5
);
2836 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_ret
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
| PyBUF_WRITABLE
, 1, 0, __pyx_stack
) == -1)) {
2837 Py_XDECREF(__pyx_t_3
); Py_XDECREF(__pyx_t_4
); Py_XDECREF(__pyx_t_5
);
2838 __Pyx_RaiseBufferFallbackError();
2840 PyErr_Restore(__pyx_t_3
, __pyx_t_4
, __pyx_t_5
);
2842 __pyx_t_3
= __pyx_t_4
= __pyx_t_5
= 0;
2844 __pyx_pybuffernd_ret
.diminfo
[0].strides
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_ret
.diminfo
[0].shape
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.shape
[0];
2845 if (unlikely(__pyx_t_2
< 0)) __PYX_ERR(0, 44, __pyx_L1_error
)
2847 __pyx_v_ret
= ((PyArrayObject
*)__pyx_t_1
);
2850 /* "MACS2/Signal.pyx":45
2851 * if n == 0 or n == 1:
2852 * ret = np.ndarray(0, 'int32')
2853 * return ret # <<<<<<<<<<<<<<
2855 * ret = np.zeros(n - 1, 'int32')
2857 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
2858 __Pyx_INCREF(((PyObject
*)__pyx_v_ret
));
2859 __pyx_r
= ((PyArrayObject
*)__pyx_v_ret
);
2862 /* "MACS2/Signal.pyx":43
2863 * int n = maxima.shape[0]
2865 * if n == 0 or n == 1: # <<<<<<<<<<<<<<
2866 * ret = np.ndarray(0, 'int32')
2872 /* "MACS2/Signal.pyx":47
2875 * ret = np.zeros(n - 1, 'int32') # <<<<<<<<<<<<<<
2877 * for i in range(n - 1):
2879 __Pyx_GetModuleGlobalName(__pyx_t_6
, __pyx_n_s_np
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 47, __pyx_L1_error
)
2880 __Pyx_GOTREF(__pyx_t_6
);
2881 __pyx_t_7
= __Pyx_PyObject_GetAttrStr(__pyx_t_6
, __pyx_n_s_zeros
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 47, __pyx_L1_error
)
2882 __Pyx_GOTREF(__pyx_t_7
);
2883 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
2884 __pyx_t_6
= __Pyx_PyInt_From_long((__pyx_v_n
- 1)); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 47, __pyx_L1_error
)
2885 __Pyx_GOTREF(__pyx_t_6
);
2888 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_7
))) {
2889 __pyx_t_8
= PyMethod_GET_SELF(__pyx_t_7
);
2890 if (likely(__pyx_t_8
)) {
2891 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_7
);
2892 __Pyx_INCREF(__pyx_t_8
);
2893 __Pyx_INCREF(function
);
2894 __Pyx_DECREF_SET(__pyx_t_7
, function
);
2898 #if CYTHON_FAST_PYCALL
2899 if (PyFunction_Check(__pyx_t_7
)) {
2900 PyObject
*__pyx_temp
[3] = {__pyx_t_8
, __pyx_t_6
, __pyx_n_u_int32
};
2901 __pyx_t_1
= __Pyx_PyFunction_FastCall(__pyx_t_7
, __pyx_temp
+1-__pyx_t_2
, 2+__pyx_t_2
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 47, __pyx_L1_error
)
2902 __Pyx_XDECREF(__pyx_t_8
); __pyx_t_8
= 0;
2903 __Pyx_GOTREF(__pyx_t_1
);
2904 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
2907 #if CYTHON_FAST_PYCCALL
2908 if (__Pyx_PyFastCFunction_Check(__pyx_t_7
)) {
2909 PyObject
*__pyx_temp
[3] = {__pyx_t_8
, __pyx_t_6
, __pyx_n_u_int32
};
2910 __pyx_t_1
= __Pyx_PyCFunction_FastCall(__pyx_t_7
, __pyx_temp
+1-__pyx_t_2
, 2+__pyx_t_2
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 47, __pyx_L1_error
)
2911 __Pyx_XDECREF(__pyx_t_8
); __pyx_t_8
= 0;
2912 __Pyx_GOTREF(__pyx_t_1
);
2913 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
2917 __pyx_t_9
= PyTuple_New(2+__pyx_t_2
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 47, __pyx_L1_error
)
2918 __Pyx_GOTREF(__pyx_t_9
);
2920 __Pyx_GIVEREF(__pyx_t_8
); PyTuple_SET_ITEM(__pyx_t_9
, 0, __pyx_t_8
); __pyx_t_8
= NULL
;
2922 __Pyx_GIVEREF(__pyx_t_6
);
2923 PyTuple_SET_ITEM(__pyx_t_9
, 0+__pyx_t_2
, __pyx_t_6
);
2924 __Pyx_INCREF(__pyx_n_u_int32
);
2925 __Pyx_GIVEREF(__pyx_n_u_int32
);
2926 PyTuple_SET_ITEM(__pyx_t_9
, 1+__pyx_t_2
, __pyx_n_u_int32
);
2928 __pyx_t_1
= __Pyx_PyObject_Call(__pyx_t_7
, __pyx_t_9
, NULL
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 47, __pyx_L1_error
)
2929 __Pyx_GOTREF(__pyx_t_1
);
2930 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
2932 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
2933 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 47, __pyx_L1_error
)
2934 __pyx_t_10
= ((PyArrayObject
*)__pyx_t_1
);
2936 __Pyx_BufFmt_StackElem __pyx_stack
[1];
2937 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
2938 __pyx_t_2
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_10
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
| PyBUF_WRITABLE
, 1, 0, __pyx_stack
);
2939 if (unlikely(__pyx_t_2
< 0)) {
2940 PyErr_Fetch(&__pyx_t_5
, &__pyx_t_4
, &__pyx_t_3
);
2941 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_ret
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
| PyBUF_WRITABLE
, 1, 0, __pyx_stack
) == -1)) {
2942 Py_XDECREF(__pyx_t_5
); Py_XDECREF(__pyx_t_4
); Py_XDECREF(__pyx_t_3
);
2943 __Pyx_RaiseBufferFallbackError();
2945 PyErr_Restore(__pyx_t_5
, __pyx_t_4
, __pyx_t_3
);
2947 __pyx_t_5
= __pyx_t_4
= __pyx_t_3
= 0;
2949 __pyx_pybuffernd_ret
.diminfo
[0].strides
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_ret
.diminfo
[0].shape
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.shape
[0];
2950 if (unlikely(__pyx_t_2
< 0)) __PYX_ERR(0, 47, __pyx_L1_error
)
2953 __pyx_v_ret
= ((PyArrayObject
*)__pyx_t_1
);
2956 /* "MACS2/Signal.pyx":48
2958 * ret = np.zeros(n - 1, 'int32')
2959 * pos1 = maxima[0] # <<<<<<<<<<<<<<
2960 * for i in range(n - 1):
2961 * pos2 = maxima[i + 1]
2965 if (__pyx_t_11
< 0) {
2966 __pyx_t_11
+= __pyx_pybuffernd_maxima
.diminfo
[0].shape
;
2967 if (unlikely(__pyx_t_11
< 0)) __pyx_t_2
= 0;
2968 } else if (unlikely(__pyx_t_11
>= __pyx_pybuffernd_maxima
.diminfo
[0].shape
)) __pyx_t_2
= 0;
2969 if (unlikely(__pyx_t_2
!= -1)) {
2970 __Pyx_RaiseBufferIndexError(__pyx_t_2
);
2971 __PYX_ERR(0, 48, __pyx_L1_error
)
2973 __pyx_t_1
= __Pyx_PyInt_From_npy_int32((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_11
, __pyx_pybuffernd_maxima
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 48, __pyx_L1_error
)
2974 __Pyx_GOTREF(__pyx_t_1
);
2975 __pyx_v_pos1
= __pyx_t_1
;
2978 /* "MACS2/Signal.pyx":49
2979 * ret = np.zeros(n - 1, 'int32')
2981 * for i in range(n - 1): # <<<<<<<<<<<<<<
2982 * pos2 = maxima[i + 1]
2983 * ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
2985 __pyx_t_12
= (__pyx_v_n
- 1);
2986 __pyx_t_13
= __pyx_t_12
;
2987 for (__pyx_t_2
= 0; __pyx_t_2
< __pyx_t_13
; __pyx_t_2
+=1) {
2988 __pyx_v_i
= __pyx_t_2
;
2990 /* "MACS2/Signal.pyx":50
2992 * for i in range(n - 1):
2993 * pos2 = maxima[i + 1] # <<<<<<<<<<<<<<
2994 * ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
2997 __pyx_t_14
= (__pyx_v_i
+ 1);
2999 if (__pyx_t_14
< 0) {
3000 __pyx_t_14
+= __pyx_pybuffernd_maxima
.diminfo
[0].shape
;
3001 if (unlikely(__pyx_t_14
< 0)) __pyx_t_15
= 0;
3002 } else if (unlikely(__pyx_t_14
>= __pyx_pybuffernd_maxima
.diminfo
[0].shape
)) __pyx_t_15
= 0;
3003 if (unlikely(__pyx_t_15
!= -1)) {
3004 __Pyx_RaiseBufferIndexError(__pyx_t_15
);
3005 __PYX_ERR(0, 50, __pyx_L1_error
)
3007 __pyx_t_1
= __Pyx_PyInt_From_npy_int32((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_14
, __pyx_pybuffernd_maxima
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 50, __pyx_L1_error
)
3008 __Pyx_GOTREF(__pyx_t_1
);
3009 __Pyx_XDECREF_SET(__pyx_v_pos2
, __pyx_t_1
);
3012 /* "MACS2/Signal.pyx":51
3013 * for i in range(n - 1):
3014 * pos2 = maxima[i + 1]
3015 * ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1 # <<<<<<<<<<<<<<
3019 __Pyx_GetModuleGlobalName(__pyx_t_7
, __pyx_n_s_np
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3020 __Pyx_GOTREF(__pyx_t_7
);
3021 __pyx_t_9
= __Pyx_PyObject_GetAttrStr(__pyx_t_7
, __pyx_n_s_where
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3022 __Pyx_GOTREF(__pyx_t_9
);
3023 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
3024 __pyx_t_7
= PySlice_New(__pyx_v_pos1
, __pyx_v_pos2
, Py_None
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3025 __Pyx_GOTREF(__pyx_t_7
);
3026 __pyx_t_6
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_7
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3027 __Pyx_GOTREF(__pyx_t_6
);
3028 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
3029 __pyx_t_8
= PySlice_New(__pyx_v_pos1
, __pyx_v_pos2
, Py_None
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3030 __Pyx_GOTREF(__pyx_t_8
);
3031 __pyx_t_16
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_8
); if (unlikely(!__pyx_t_16
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3032 __Pyx_GOTREF(__pyx_t_16
);
3033 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
3034 __pyx_t_8
= __Pyx_PyObject_GetAttrStr(__pyx_t_16
, __pyx_n_s_min
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3035 __Pyx_GOTREF(__pyx_t_8
);
3036 __Pyx_DECREF(__pyx_t_16
); __pyx_t_16
= 0;
3038 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_8
))) {
3039 __pyx_t_16
= PyMethod_GET_SELF(__pyx_t_8
);
3040 if (likely(__pyx_t_16
)) {
3041 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_8
);
3042 __Pyx_INCREF(__pyx_t_16
);
3043 __Pyx_INCREF(function
);
3044 __Pyx_DECREF_SET(__pyx_t_8
, function
);
3047 __pyx_t_7
= (__pyx_t_16
) ? __Pyx_PyObject_CallOneArg(__pyx_t_8
, __pyx_t_16
) : __Pyx_PyObject_CallNoArg(__pyx_t_8
);
3048 __Pyx_XDECREF(__pyx_t_16
); __pyx_t_16
= 0;
3049 if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3050 __Pyx_GOTREF(__pyx_t_7
);
3051 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
3052 __pyx_t_8
= PyObject_RichCompare(__pyx_t_6
, __pyx_t_7
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_8
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3053 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
3054 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
3056 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_9
))) {
3057 __pyx_t_7
= PyMethod_GET_SELF(__pyx_t_9
);
3058 if (likely(__pyx_t_7
)) {
3059 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_9
);
3060 __Pyx_INCREF(__pyx_t_7
);
3061 __Pyx_INCREF(function
);
3062 __Pyx_DECREF_SET(__pyx_t_9
, function
);
3065 __pyx_t_1
= (__pyx_t_7
) ? __Pyx_PyObject_Call2Args(__pyx_t_9
, __pyx_t_7
, __pyx_t_8
) : __Pyx_PyObject_CallOneArg(__pyx_t_9
, __pyx_t_8
);
3066 __Pyx_XDECREF(__pyx_t_7
); __pyx_t_7
= 0;
3067 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
3068 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3069 __Pyx_GOTREF(__pyx_t_1
);
3070 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
3071 __pyx_t_9
= __Pyx_GetItemInt(__pyx_t_1
, 0, long, 1, __Pyx_PyInt_From_long
, 0, 0, 1); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3072 __Pyx_GOTREF(__pyx_t_9
);
3073 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3074 __pyx_t_1
= __Pyx_GetItemInt(__pyx_t_9
, 0, long, 1, __Pyx_PyInt_From_long
, 0, 0, 1); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3075 __Pyx_GOTREF(__pyx_t_1
);
3076 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
3077 __pyx_t_9
= PyNumber_Add(__pyx_t_1
, __pyx_v_pos1
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 51, __pyx_L1_error
)
3078 __Pyx_GOTREF(__pyx_t_9
);
3079 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3080 __pyx_t_17
= __Pyx_PyInt_As_npy_int32(__pyx_t_9
); if (unlikely((__pyx_t_17
== ((npy_int32
)-1)) && PyErr_Occurred())) __PYX_ERR(0, 51, __pyx_L1_error
)
3081 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
3082 __pyx_t_18
= __pyx_v_i
;
3084 if (__pyx_t_18
< 0) {
3085 __pyx_t_18
+= __pyx_pybuffernd_ret
.diminfo
[0].shape
;
3086 if (unlikely(__pyx_t_18
< 0)) __pyx_t_15
= 0;
3087 } else if (unlikely(__pyx_t_18
>= __pyx_pybuffernd_ret
.diminfo
[0].shape
)) __pyx_t_15
= 0;
3088 if (unlikely(__pyx_t_15
!= -1)) {
3089 __Pyx_RaiseBufferIndexError(__pyx_t_15
);
3090 __PYX_ERR(0, 51, __pyx_L1_error
)
3092 *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.buf
, __pyx_t_18
, __pyx_pybuffernd_ret
.diminfo
[0].strides
) = __pyx_t_17
;
3094 /* "MACS2/Signal.pyx":52
3095 * pos2 = maxima[i + 1]
3096 * ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
3097 * pos1 = pos2 # <<<<<<<<<<<<<<
3101 __Pyx_INCREF(__pyx_v_pos2
);
3102 __Pyx_DECREF_SET(__pyx_v_pos1
, __pyx_v_pos2
);
3105 /* "MACS2/Signal.pyx":53
3106 * ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
3108 * return ret # <<<<<<<<<<<<<<
3110 * cdef inline float sqrt(float threshold):
3112 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
3113 __Pyx_INCREF(((PyObject
*)__pyx_v_ret
));
3114 __pyx_r
= ((PyArrayObject
*)__pyx_v_ret
);
3119 /* "MACS2/Signal.pyx":37
3122 * cdef np.ndarray[np.int32_t, ndim=1] internal_minima( np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
3123 * np.ndarray[np.int32_t, ndim=1] maxima ):
3127 /* function exit code */
3129 __Pyx_XDECREF(__pyx_t_1
);
3130 __Pyx_XDECREF(__pyx_t_6
);
3131 __Pyx_XDECREF(__pyx_t_7
);
3132 __Pyx_XDECREF(__pyx_t_8
);
3133 __Pyx_XDECREF(__pyx_t_9
);
3134 __Pyx_XDECREF(__pyx_t_16
);
3135 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
3136 __Pyx_PyThreadState_declare
3137 __Pyx_PyThreadState_assign
3138 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
3139 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
);
3140 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
3141 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
3142 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
3143 __Pyx_AddTraceback("MACS2.Signal.internal_minima", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
3147 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
);
3148 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
3149 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
3151 __Pyx_XDECREF((PyObject
*)__pyx_v_ret
);
3152 __Pyx_XDECREF(__pyx_v_pos1
);
3153 __Pyx_XDECREF(__pyx_v_pos2
);
3154 __Pyx_XGIVEREF((PyObject
*)__pyx_r
);
3155 __Pyx_TraceReturn(__pyx_r
, 0);
3156 __Pyx_RefNannyFinishContext();
3160 /* "MACS2/Signal.pyx":55
3163 * cdef inline float sqrt(float threshold): # <<<<<<<<<<<<<<
3164 * return mathsqrt(threshold)
3168 static CYTHON_INLINE
float __pyx_f_5MACS2_6Signal_sqrt(float __pyx_v_threshold
) {
3170 __Pyx_TraceDeclarations
3171 __Pyx_RefNannyDeclarations
3172 PyObject
*__pyx_t_1
= NULL
;
3173 PyObject
*__pyx_t_2
= NULL
;
3174 PyObject
*__pyx_t_3
= NULL
;
3175 PyObject
*__pyx_t_4
= NULL
;
3177 __Pyx_RefNannySetupContext("sqrt", 0);
3178 __Pyx_TraceCall("sqrt", __pyx_f
[0], 55, 0, __PYX_ERR(0, 55, __pyx_L1_error
));
3180 /* "MACS2/Signal.pyx":56
3182 * cdef inline float sqrt(float threshold):
3183 * return mathsqrt(threshold) # <<<<<<<<<<<<<<
3185 * cpdef enforce_peakyness(np.ndarray[np.float32_t, ndim=1] signal,
3187 __Pyx_GetModuleGlobalName(__pyx_t_2
, __pyx_n_s_mathsqrt
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 56, __pyx_L1_error
)
3188 __Pyx_GOTREF(__pyx_t_2
);
3189 __pyx_t_3
= PyFloat_FromDouble(__pyx_v_threshold
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 56, __pyx_L1_error
)
3190 __Pyx_GOTREF(__pyx_t_3
);
3192 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_2
))) {
3193 __pyx_t_4
= PyMethod_GET_SELF(__pyx_t_2
);
3194 if (likely(__pyx_t_4
)) {
3195 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_2
);
3196 __Pyx_INCREF(__pyx_t_4
);
3197 __Pyx_INCREF(function
);
3198 __Pyx_DECREF_SET(__pyx_t_2
, function
);
3201 __pyx_t_1
= (__pyx_t_4
) ? __Pyx_PyObject_Call2Args(__pyx_t_2
, __pyx_t_4
, __pyx_t_3
) : __Pyx_PyObject_CallOneArg(__pyx_t_2
, __pyx_t_3
);
3202 __Pyx_XDECREF(__pyx_t_4
); __pyx_t_4
= 0;
3203 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3204 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 56, __pyx_L1_error
)
3205 __Pyx_GOTREF(__pyx_t_1
);
3206 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3207 __pyx_t_5
= __pyx_PyFloat_AsFloat(__pyx_t_1
); if (unlikely((__pyx_t_5
== (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error
)
3208 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3209 __pyx_r
= __pyx_t_5
;
3212 /* "MACS2/Signal.pyx":55
3215 * cdef inline float sqrt(float threshold): # <<<<<<<<<<<<<<
3216 * return mathsqrt(threshold)
3220 /* function exit code */
3222 __Pyx_XDECREF(__pyx_t_1
);
3223 __Pyx_XDECREF(__pyx_t_2
);
3224 __Pyx_XDECREF(__pyx_t_3
);
3225 __Pyx_XDECREF(__pyx_t_4
);
3226 __Pyx_WriteUnraisable("MACS2.Signal.sqrt", __pyx_clineno
, __pyx_lineno
, __pyx_filename
, 1, 0);
3229 __Pyx_TraceReturn(Py_None
, 0);
3230 __Pyx_RefNannyFinishContext();
3234 /* "MACS2/Signal.pyx":58
3235 * return mathsqrt(threshold)
3237 * cpdef enforce_peakyness(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
3238 * np.ndarray[np.int32_t, ndim=1] maxima):
3239 * """requires peaks described by a signal and a set of points where the signal
3242 static PyObject
*__pyx_pw_5MACS2_6Signal_3enforce_peakyness(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
3243 static PyObject
*__pyx_f_5MACS2_6Signal_enforce_peakyness(PyArrayObject
*__pyx_v_signal
, PyArrayObject
*__pyx_v_maxima
, CYTHON_UNUSED
int __pyx_skip_dispatch
) {
3244 PyArrayObject
*__pyx_v_minima
= 0;
3245 PyArrayObject
*__pyx_v_new_signal
= 0;
3247 float __pyx_v_threshold
;
3248 PyArrayObject
*__pyx_v_peaky_maxima
= 0;
3250 PyObject
*__pyx_v_i
= NULL
;
3251 PyObject
*__pyx_v_new_maximum
= NULL
;
3252 __Pyx_LocalBuf_ND __pyx_pybuffernd_maxima
;
3253 __Pyx_Buffer __pyx_pybuffer_maxima
;
3254 __Pyx_LocalBuf_ND __pyx_pybuffernd_minima
;
3255 __Pyx_Buffer __pyx_pybuffer_minima
;
3256 __Pyx_LocalBuf_ND __pyx_pybuffernd_new_signal
;
3257 __Pyx_Buffer __pyx_pybuffer_new_signal
;
3258 __Pyx_LocalBuf_ND __pyx_pybuffernd_peaky_maxima
;
3259 __Pyx_Buffer __pyx_pybuffer_peaky_maxima
;
3260 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
3261 __Pyx_Buffer __pyx_pybuffer_signal
;
3262 PyObject
*__pyx_r
= NULL
;
3263 __Pyx_TraceDeclarations
3264 __Pyx_RefNannyDeclarations
3265 PyObject
*__pyx_t_1
= NULL
;
3266 PyObject
*__pyx_t_2
= NULL
;
3267 PyObject
*__pyx_t_3
= NULL
;
3268 PyArrayObject
*__pyx_t_4
= NULL
;
3270 Py_ssize_t __pyx_t_6
;
3272 Py_ssize_t __pyx_t_8
;
3273 Py_ssize_t __pyx_t_9
;
3274 PyArrayObject
*__pyx_t_10
= NULL
;
3275 PyObject
*__pyx_t_11
= NULL
;
3276 PyObject
*__pyx_t_12
= NULL
;
3277 PyObject
*__pyx_t_13
= NULL
;
3278 Py_ssize_t __pyx_t_14
;
3279 Py_ssize_t __pyx_t_15
;
3280 Py_ssize_t __pyx_t_16
;
3281 Py_ssize_t __pyx_t_17
;
3282 PyObject
*(*__pyx_t_18
)(PyObject
*);
3283 PyObject
*__pyx_t_19
= NULL
;
3284 PyObject
*__pyx_t_20
= NULL
;
3286 __pyx_t_5numpy_int32_t __pyx_t_22
;
3287 Py_ssize_t __pyx_t_23
;
3288 Py_ssize_t __pyx_t_24
;
3289 Py_ssize_t __pyx_t_25
;
3290 Py_ssize_t __pyx_t_26
;
3291 Py_ssize_t __pyx_t_27
;
3292 Py_ssize_t __pyx_t_28
;
3293 Py_ssize_t __pyx_t_29
;
3294 Py_ssize_t __pyx_t_30
;
3295 __Pyx_RefNannySetupContext("enforce_peakyness", 0);
3296 __Pyx_TraceCall("enforce_peakyness", __pyx_f
[0], 58, 0, __PYX_ERR(0, 58, __pyx_L1_error
));
3297 __pyx_pybuffer_minima
.pybuffer
.buf
= NULL
;
3298 __pyx_pybuffer_minima
.refcount
= 0;
3299 __pyx_pybuffernd_minima
.data
= NULL
;
3300 __pyx_pybuffernd_minima
.rcbuffer
= &__pyx_pybuffer_minima
;
3301 __pyx_pybuffer_new_signal
.pybuffer
.buf
= NULL
;
3302 __pyx_pybuffer_new_signal
.refcount
= 0;
3303 __pyx_pybuffernd_new_signal
.data
= NULL
;
3304 __pyx_pybuffernd_new_signal
.rcbuffer
= &__pyx_pybuffer_new_signal
;
3305 __pyx_pybuffer_peaky_maxima
.pybuffer
.buf
= NULL
;
3306 __pyx_pybuffer_peaky_maxima
.refcount
= 0;
3307 __pyx_pybuffernd_peaky_maxima
.data
= NULL
;
3308 __pyx_pybuffernd_peaky_maxima
.rcbuffer
= &__pyx_pybuffer_peaky_maxima
;
3309 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
3310 __pyx_pybuffer_signal
.refcount
= 0;
3311 __pyx_pybuffernd_signal
.data
= NULL
;
3312 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
3313 __pyx_pybuffer_maxima
.pybuffer
.buf
= NULL
;
3314 __pyx_pybuffer_maxima
.refcount
= 0;
3315 __pyx_pybuffernd_maxima
.data
= NULL
;
3316 __pyx_pybuffernd_maxima
.rcbuffer
= &__pyx_pybuffer_maxima
;
3318 __Pyx_BufFmt_StackElem __pyx_stack
[1];
3319 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 58, __pyx_L1_error
)
3321 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
3323 __Pyx_BufFmt_StackElem __pyx_stack
[1];
3324 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_maxima
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 58, __pyx_L1_error
)
3326 __pyx_pybuffernd_maxima
.diminfo
[0].strides
= __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_maxima
.diminfo
[0].shape
= __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.shape
[0];
3328 /* "MACS2/Signal.pyx":75
3331 * np.ndarray[np.int32_t, ndim=1] minima = internal_minima(signal, maxima) # <<<<<<<<<<<<<<
3332 * np.ndarray[np.float32_t, ndim=1] new_signal
3333 * int n = minima.shape[0]
3335 __pyx_t_1
= ((PyObject
*)__pyx_f_5MACS2_6Signal_internal_minima(((PyArrayObject
*)__pyx_v_signal
), ((PyArrayObject
*)__pyx_v_maxima
))); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 75, __pyx_L1_error
)
3336 __Pyx_GOTREF(__pyx_t_1
);
3338 __Pyx_BufFmt_StackElem __pyx_stack
[1];
3339 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_minima
.rcbuffer
->pybuffer
, (PyObject
*)((PyArrayObject
*)__pyx_t_1
), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
3340 __pyx_v_minima
= ((PyArrayObject
*)Py_None
); __Pyx_INCREF(Py_None
); __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.buf
= NULL
;
3341 __PYX_ERR(0, 75, __pyx_L1_error
)
3342 } else {__pyx_pybuffernd_minima
.diminfo
[0].strides
= __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_minima
.diminfo
[0].shape
= __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.shape
[0];
3345 __pyx_v_minima
= ((PyArrayObject
*)__pyx_t_1
);
3348 /* "MACS2/Signal.pyx":77
3349 * np.ndarray[np.int32_t, ndim=1] minima = internal_minima(signal, maxima)
3350 * np.ndarray[np.float32_t, ndim=1] new_signal
3351 * int n = minima.shape[0] # <<<<<<<<<<<<<<
3353 * np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
3355 __pyx_v_n
= (__pyx_v_minima
->dimensions
[0]);
3357 /* "MACS2/Signal.pyx":79
3358 * int n = minima.shape[0]
3360 * np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy() # <<<<<<<<<<<<<<
3362 * if n == 0: return maxima
3364 __pyx_t_2
= __Pyx_PyObject_GetAttrStr(((PyObject
*)__pyx_v_maxima
), __pyx_n_s_copy
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 79, __pyx_L1_error
)
3365 __Pyx_GOTREF(__pyx_t_2
);
3367 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_2
))) {
3368 __pyx_t_3
= PyMethod_GET_SELF(__pyx_t_2
);
3369 if (likely(__pyx_t_3
)) {
3370 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_2
);
3371 __Pyx_INCREF(__pyx_t_3
);
3372 __Pyx_INCREF(function
);
3373 __Pyx_DECREF_SET(__pyx_t_2
, function
);
3376 __pyx_t_1
= (__pyx_t_3
) ? __Pyx_PyObject_CallOneArg(__pyx_t_2
, __pyx_t_3
) : __Pyx_PyObject_CallNoArg(__pyx_t_2
);
3377 __Pyx_XDECREF(__pyx_t_3
); __pyx_t_3
= 0;
3378 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 79, __pyx_L1_error
)
3379 __Pyx_GOTREF(__pyx_t_1
);
3380 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3381 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 79, __pyx_L1_error
)
3382 __pyx_t_4
= ((PyArrayObject
*)__pyx_t_1
);
3384 __Pyx_BufFmt_StackElem __pyx_stack
[1];
3385 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_4
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
| PyBUF_WRITABLE
, 1, 0, __pyx_stack
) == -1)) {
3386 __pyx_v_peaky_maxima
= ((PyArrayObject
*)Py_None
); __Pyx_INCREF(Py_None
); __pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
.buf
= NULL
;
3387 __PYX_ERR(0, 79, __pyx_L1_error
)
3388 } else {__pyx_pybuffernd_peaky_maxima
.diminfo
[0].strides
= __pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_peaky_maxima
.diminfo
[0].shape
= __pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
.shape
[0];
3392 __pyx_v_peaky_maxima
= ((PyArrayObject
*)__pyx_t_1
);
3395 /* "MACS2/Signal.pyx":80
3397 * np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
3398 * int j = 0 # <<<<<<<<<<<<<<
3399 * if n == 0: return maxima
3404 /* "MACS2/Signal.pyx":81
3405 * np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
3407 * if n == 0: return maxima # <<<<<<<<<<<<<<
3409 * threshold = signal[minima[0]]
3411 __pyx_t_5
= ((__pyx_v_n
== 0) != 0);
3413 __Pyx_XDECREF(__pyx_r
);
3414 __Pyx_INCREF(((PyObject
*)__pyx_v_maxima
));
3415 __pyx_r
= ((PyObject
*)__pyx_v_maxima
);
3419 /* "MACS2/Signal.pyx":83
3420 * if n == 0: return maxima
3422 * threshold = signal[minima[0]] # <<<<<<<<<<<<<<
3423 * threshold += sqrt(threshold)
3424 * new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
3428 if (__pyx_t_6
< 0) {
3429 __pyx_t_6
+= __pyx_pybuffernd_minima
.diminfo
[0].shape
;
3430 if (unlikely(__pyx_t_6
< 0)) __pyx_t_7
= 0;
3431 } else if (unlikely(__pyx_t_6
>= __pyx_pybuffernd_minima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3432 if (unlikely(__pyx_t_7
!= -1)) {
3433 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3434 __PYX_ERR(0, 83, __pyx_L1_error
)
3436 __pyx_t_8
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.buf
, __pyx_t_6
, __pyx_pybuffernd_minima
.diminfo
[0].strides
));
3438 if (__pyx_t_8
< 0) {
3439 __pyx_t_8
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
3440 if (unlikely(__pyx_t_8
< 0)) __pyx_t_7
= 0;
3441 } else if (unlikely(__pyx_t_8
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3442 if (unlikely(__pyx_t_7
!= -1)) {
3443 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3444 __PYX_ERR(0, 83, __pyx_L1_error
)
3446 __pyx_v_threshold
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_8
, __pyx_pybuffernd_signal
.diminfo
[0].strides
));
3448 /* "MACS2/Signal.pyx":84
3450 * threshold = signal[minima[0]]
3451 * threshold += sqrt(threshold) # <<<<<<<<<<<<<<
3452 * new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
3453 * # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
3455 __pyx_v_threshold
= (__pyx_v_threshold
+ __pyx_f_5MACS2_6Signal_sqrt(__pyx_v_threshold
));
3457 /* "MACS2/Signal.pyx":85
3458 * threshold = signal[minima[0]]
3459 * threshold += sqrt(threshold)
3460 * new_signal = signal[0:minima[0]] - threshold - sqrt(threshold) # <<<<<<<<<<<<<<
3461 * # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
3462 * if is_valid_peak(new_signal, maxima[0]):
3466 if (__pyx_t_9
< 0) {
3467 __pyx_t_9
+= __pyx_pybuffernd_minima
.diminfo
[0].shape
;
3468 if (unlikely(__pyx_t_9
< 0)) __pyx_t_7
= 0;
3469 } else if (unlikely(__pyx_t_9
>= __pyx_pybuffernd_minima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3470 if (unlikely(__pyx_t_7
!= -1)) {
3471 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3472 __PYX_ERR(0, 85, __pyx_L1_error
)
3474 __pyx_t_1
= __Pyx_PyInt_From_npy_int32((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.buf
, __pyx_t_9
, __pyx_pybuffernd_minima
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 85, __pyx_L1_error
)
3475 __Pyx_GOTREF(__pyx_t_1
);
3476 __pyx_t_2
= PySlice_New(__pyx_int_0
, __pyx_t_1
, Py_None
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 85, __pyx_L1_error
)
3477 __Pyx_GOTREF(__pyx_t_2
);
3478 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3479 __pyx_t_1
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_2
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 85, __pyx_L1_error
)
3480 __Pyx_GOTREF(__pyx_t_1
);
3481 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3482 __pyx_t_2
= PyFloat_FromDouble(__pyx_v_threshold
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 85, __pyx_L1_error
)
3483 __Pyx_GOTREF(__pyx_t_2
);
3484 __pyx_t_3
= PyNumber_Subtract(__pyx_t_1
, __pyx_t_2
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 85, __pyx_L1_error
)
3485 __Pyx_GOTREF(__pyx_t_3
);
3486 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3487 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3488 __pyx_t_2
= PyFloat_FromDouble(__pyx_f_5MACS2_6Signal_sqrt(__pyx_v_threshold
)); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 85, __pyx_L1_error
)
3489 __Pyx_GOTREF(__pyx_t_2
);
3490 __pyx_t_1
= PyNumber_Subtract(__pyx_t_3
, __pyx_t_2
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 85, __pyx_L1_error
)
3491 __Pyx_GOTREF(__pyx_t_1
);
3492 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3493 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3494 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 85, __pyx_L1_error
)
3495 __pyx_t_10
= ((PyArrayObject
*)__pyx_t_1
);
3497 __Pyx_BufFmt_StackElem __pyx_stack
[1];
3498 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
);
3499 __pyx_t_7
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_10
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
3500 if (unlikely(__pyx_t_7
< 0)) {
3501 PyErr_Fetch(&__pyx_t_11
, &__pyx_t_12
, &__pyx_t_13
);
3502 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_new_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
3503 Py_XDECREF(__pyx_t_11
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_13
);
3504 __Pyx_RaiseBufferFallbackError();
3506 PyErr_Restore(__pyx_t_11
, __pyx_t_12
, __pyx_t_13
);
3508 __pyx_t_11
= __pyx_t_12
= __pyx_t_13
= 0;
3510 __pyx_pybuffernd_new_signal
.diminfo
[0].strides
= __pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_new_signal
.diminfo
[0].shape
= __pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
.shape
[0];
3511 if (unlikely(__pyx_t_7
< 0)) __PYX_ERR(0, 85, __pyx_L1_error
)
3514 __pyx_v_new_signal
= ((PyArrayObject
*)__pyx_t_1
);
3517 /* "MACS2/Signal.pyx":87
3518 * new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
3519 * # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
3520 * if is_valid_peak(new_signal, maxima[0]): # <<<<<<<<<<<<<<
3521 * peaky_maxima[0] = maxima[0]
3526 if (__pyx_t_14
< 0) {
3527 __pyx_t_14
+= __pyx_pybuffernd_maxima
.diminfo
[0].shape
;
3528 if (unlikely(__pyx_t_14
< 0)) __pyx_t_7
= 0;
3529 } else if (unlikely(__pyx_t_14
>= __pyx_pybuffernd_maxima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3530 if (unlikely(__pyx_t_7
!= -1)) {
3531 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3532 __PYX_ERR(0, 87, __pyx_L1_error
)
3534 __pyx_t_1
= ((PyObject
*)__pyx_f_5MACS2_6Signal_is_valid_peak(((PyArrayObject
*)__pyx_v_new_signal
), (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_14
, __pyx_pybuffernd_maxima
.diminfo
[0].strides
)))); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 87, __pyx_L1_error
)
3535 __Pyx_GOTREF(__pyx_t_1
);
3536 __pyx_t_5
= __Pyx_PyObject_IsTrue(__pyx_t_1
); if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 87, __pyx_L1_error
)
3537 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3540 /* "MACS2/Signal.pyx":88
3541 * # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
3542 * if is_valid_peak(new_signal, maxima[0]):
3543 * peaky_maxima[0] = maxima[0] # <<<<<<<<<<<<<<
3545 * for i in range(n - 1):
3549 if (__pyx_t_15
< 0) {
3550 __pyx_t_15
+= __pyx_pybuffernd_maxima
.diminfo
[0].shape
;
3551 if (unlikely(__pyx_t_15
< 0)) __pyx_t_7
= 0;
3552 } else if (unlikely(__pyx_t_15
>= __pyx_pybuffernd_maxima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3553 if (unlikely(__pyx_t_7
!= -1)) {
3554 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3555 __PYX_ERR(0, 88, __pyx_L1_error
)
3559 if (__pyx_t_16
< 0) {
3560 __pyx_t_16
+= __pyx_pybuffernd_peaky_maxima
.diminfo
[0].shape
;
3561 if (unlikely(__pyx_t_16
< 0)) __pyx_t_7
= 0;
3562 } else if (unlikely(__pyx_t_16
>= __pyx_pybuffernd_peaky_maxima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3563 if (unlikely(__pyx_t_7
!= -1)) {
3564 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3565 __PYX_ERR(0, 88, __pyx_L1_error
)
3567 *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_16
, __pyx_pybuffernd_peaky_maxima
.diminfo
[0].strides
) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_15
, __pyx_pybuffernd_maxima
.diminfo
[0].strides
));
3569 /* "MACS2/Signal.pyx":89
3570 * if is_valid_peak(new_signal, maxima[0]):
3571 * peaky_maxima[0] = maxima[0]
3572 * j += 1 # <<<<<<<<<<<<<<
3573 * for i in range(n - 1):
3574 * threshold = max(signal[minima[i]], signal[minima[i + 1]])
3576 __pyx_v_j
= (__pyx_v_j
+ 1);
3578 /* "MACS2/Signal.pyx":87
3579 * new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
3580 * # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
3581 * if is_valid_peak(new_signal, maxima[0]): # <<<<<<<<<<<<<<
3582 * peaky_maxima[0] = maxima[0]
3587 /* "MACS2/Signal.pyx":90
3588 * peaky_maxima[0] = maxima[0]
3590 * for i in range(n - 1): # <<<<<<<<<<<<<<
3591 * threshold = max(signal[minima[i]], signal[minima[i + 1]])
3592 * threshold += sqrt(threshold)
3594 __pyx_t_1
= __Pyx_PyInt_From_long((__pyx_v_n
- 1)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 90, __pyx_L1_error
)
3595 __Pyx_GOTREF(__pyx_t_1
);
3596 __pyx_t_2
= __Pyx_PyObject_CallOneArg(__pyx_builtin_range
, __pyx_t_1
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 90, __pyx_L1_error
)
3597 __Pyx_GOTREF(__pyx_t_2
);
3598 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3599 if (likely(PyList_CheckExact(__pyx_t_2
)) || PyTuple_CheckExact(__pyx_t_2
)) {
3600 __pyx_t_1
= __pyx_t_2
; __Pyx_INCREF(__pyx_t_1
); __pyx_t_17
= 0;
3603 __pyx_t_17
= -1; __pyx_t_1
= PyObject_GetIter(__pyx_t_2
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 90, __pyx_L1_error
)
3604 __Pyx_GOTREF(__pyx_t_1
);
3605 __pyx_t_18
= Py_TYPE(__pyx_t_1
)->tp_iternext
; if (unlikely(!__pyx_t_18
)) __PYX_ERR(0, 90, __pyx_L1_error
)
3607 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3609 if (likely(!__pyx_t_18
)) {
3610 if (likely(PyList_CheckExact(__pyx_t_1
))) {
3611 if (__pyx_t_17
>= PyList_GET_SIZE(__pyx_t_1
)) break;
3612 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3613 __pyx_t_2
= PyList_GET_ITEM(__pyx_t_1
, __pyx_t_17
); __Pyx_INCREF(__pyx_t_2
); __pyx_t_17
++; if (unlikely(0 < 0)) __PYX_ERR(0, 90, __pyx_L1_error
)
3615 __pyx_t_2
= PySequence_ITEM(__pyx_t_1
, __pyx_t_17
); __pyx_t_17
++; if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 90, __pyx_L1_error
)
3616 __Pyx_GOTREF(__pyx_t_2
);
3619 if (__pyx_t_17
>= PyTuple_GET_SIZE(__pyx_t_1
)) break;
3620 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3621 __pyx_t_2
= PyTuple_GET_ITEM(__pyx_t_1
, __pyx_t_17
); __Pyx_INCREF(__pyx_t_2
); __pyx_t_17
++; if (unlikely(0 < 0)) __PYX_ERR(0, 90, __pyx_L1_error
)
3623 __pyx_t_2
= PySequence_ITEM(__pyx_t_1
, __pyx_t_17
); __pyx_t_17
++; if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 90, __pyx_L1_error
)
3624 __Pyx_GOTREF(__pyx_t_2
);
3628 __pyx_t_2
= __pyx_t_18(__pyx_t_1
);
3629 if (unlikely(!__pyx_t_2
)) {
3630 PyObject
* exc_type
= PyErr_Occurred();
3632 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type
, PyExc_StopIteration
))) PyErr_Clear();
3633 else __PYX_ERR(0, 90, __pyx_L1_error
)
3637 __Pyx_GOTREF(__pyx_t_2
);
3639 __Pyx_XDECREF_SET(__pyx_v_i
, __pyx_t_2
);
3642 /* "MACS2/Signal.pyx":91
3644 * for i in range(n - 1):
3645 * threshold = max(signal[minima[i]], signal[minima[i + 1]]) # <<<<<<<<<<<<<<
3646 * threshold += sqrt(threshold)
3647 * new_signal = signal[minima[i]:minima[i+1]] - threshold
3649 __pyx_t_2
= __Pyx_PyInt_AddObjC(__pyx_v_i
, __pyx_int_1
, 1, 0, 0); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 91, __pyx_L1_error
)
3650 __Pyx_GOTREF(__pyx_t_2
);
3651 __pyx_t_3
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_minima
), __pyx_t_2
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 91, __pyx_L1_error
)
3652 __Pyx_GOTREF(__pyx_t_3
);
3653 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3654 __pyx_t_2
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_3
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 91, __pyx_L1_error
)
3655 __Pyx_GOTREF(__pyx_t_2
);
3656 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3657 __pyx_t_3
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_minima
), __pyx_v_i
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 91, __pyx_L1_error
)
3658 __Pyx_GOTREF(__pyx_t_3
);
3659 __pyx_t_19
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_3
); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 91, __pyx_L1_error
)
3660 __Pyx_GOTREF(__pyx_t_19
);
3661 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3662 __pyx_t_20
= PyObject_RichCompare(__pyx_t_2
, __pyx_t_19
, Py_GT
); __Pyx_XGOTREF(__pyx_t_20
); if (unlikely(!__pyx_t_20
)) __PYX_ERR(0, 91, __pyx_L1_error
)
3663 __pyx_t_5
= __Pyx_PyObject_IsTrue(__pyx_t_20
); if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 91, __pyx_L1_error
)
3664 __Pyx_DECREF(__pyx_t_20
); __pyx_t_20
= 0;
3666 __Pyx_INCREF(__pyx_t_2
);
3667 __pyx_t_3
= __pyx_t_2
;
3669 __Pyx_INCREF(__pyx_t_19
);
3670 __pyx_t_3
= __pyx_t_19
;
3672 __Pyx_DECREF(__pyx_t_19
); __pyx_t_19
= 0;
3673 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3674 __pyx_t_21
= __pyx_PyFloat_AsFloat(__pyx_t_3
); if (unlikely((__pyx_t_21
== (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 91, __pyx_L1_error
)
3675 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3676 __pyx_v_threshold
= __pyx_t_21
;
3678 /* "MACS2/Signal.pyx":92
3679 * for i in range(n - 1):
3680 * threshold = max(signal[minima[i]], signal[minima[i + 1]])
3681 * threshold += sqrt(threshold) # <<<<<<<<<<<<<<
3682 * new_signal = signal[minima[i]:minima[i+1]] - threshold
3683 * new_maximum = maxima[i+1] - minima[i]
3685 __pyx_v_threshold
= (__pyx_v_threshold
+ __pyx_f_5MACS2_6Signal_sqrt(__pyx_v_threshold
));
3687 /* "MACS2/Signal.pyx":93
3688 * threshold = max(signal[minima[i]], signal[minima[i + 1]])
3689 * threshold += sqrt(threshold)
3690 * new_signal = signal[minima[i]:minima[i+1]] - threshold # <<<<<<<<<<<<<<
3691 * new_maximum = maxima[i+1] - minima[i]
3692 * if is_valid_peak(new_signal, new_maximum):
3694 __pyx_t_3
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_minima
), __pyx_v_i
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 93, __pyx_L1_error
)
3695 __Pyx_GOTREF(__pyx_t_3
);
3696 __pyx_t_2
= __Pyx_PyInt_AddObjC(__pyx_v_i
, __pyx_int_1
, 1, 0, 0); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 93, __pyx_L1_error
)
3697 __Pyx_GOTREF(__pyx_t_2
);
3698 __pyx_t_19
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_minima
), __pyx_t_2
); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 93, __pyx_L1_error
)
3699 __Pyx_GOTREF(__pyx_t_19
);
3700 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3701 __pyx_t_2
= PySlice_New(__pyx_t_3
, __pyx_t_19
, Py_None
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 93, __pyx_L1_error
)
3702 __Pyx_GOTREF(__pyx_t_2
);
3703 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3704 __Pyx_DECREF(__pyx_t_19
); __pyx_t_19
= 0;
3705 __pyx_t_19
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_2
); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 93, __pyx_L1_error
)
3706 __Pyx_GOTREF(__pyx_t_19
);
3707 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3708 __pyx_t_2
= PyFloat_FromDouble(__pyx_v_threshold
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 93, __pyx_L1_error
)
3709 __Pyx_GOTREF(__pyx_t_2
);
3710 __pyx_t_3
= PyNumber_Subtract(__pyx_t_19
, __pyx_t_2
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 93, __pyx_L1_error
)
3711 __Pyx_GOTREF(__pyx_t_3
);
3712 __Pyx_DECREF(__pyx_t_19
); __pyx_t_19
= 0;
3713 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3714 if (!(likely(((__pyx_t_3
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_3
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 93, __pyx_L1_error
)
3715 __pyx_t_10
= ((PyArrayObject
*)__pyx_t_3
);
3717 __Pyx_BufFmt_StackElem __pyx_stack
[1];
3718 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
);
3719 __pyx_t_7
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_10
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
3720 if (unlikely(__pyx_t_7
< 0)) {
3721 PyErr_Fetch(&__pyx_t_13
, &__pyx_t_12
, &__pyx_t_11
);
3722 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_new_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
3723 Py_XDECREF(__pyx_t_13
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_11
);
3724 __Pyx_RaiseBufferFallbackError();
3726 PyErr_Restore(__pyx_t_13
, __pyx_t_12
, __pyx_t_11
);
3728 __pyx_t_13
= __pyx_t_12
= __pyx_t_11
= 0;
3730 __pyx_pybuffernd_new_signal
.diminfo
[0].strides
= __pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_new_signal
.diminfo
[0].shape
= __pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
.shape
[0];
3731 if (unlikely(__pyx_t_7
< 0)) __PYX_ERR(0, 93, __pyx_L1_error
)
3734 __Pyx_DECREF_SET(__pyx_v_new_signal
, ((PyArrayObject
*)__pyx_t_3
));
3737 /* "MACS2/Signal.pyx":94
3738 * threshold += sqrt(threshold)
3739 * new_signal = signal[minima[i]:minima[i+1]] - threshold
3740 * new_maximum = maxima[i+1] - minima[i] # <<<<<<<<<<<<<<
3741 * if is_valid_peak(new_signal, new_maximum):
3742 * peaky_maxima[j] = maxima[i + 1]
3744 __pyx_t_3
= __Pyx_PyInt_AddObjC(__pyx_v_i
, __pyx_int_1
, 1, 0, 0); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 94, __pyx_L1_error
)
3745 __Pyx_GOTREF(__pyx_t_3
);
3746 __pyx_t_2
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_maxima
), __pyx_t_3
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 94, __pyx_L1_error
)
3747 __Pyx_GOTREF(__pyx_t_2
);
3748 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3749 __pyx_t_3
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_minima
), __pyx_v_i
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 94, __pyx_L1_error
)
3750 __Pyx_GOTREF(__pyx_t_3
);
3751 __pyx_t_19
= PyNumber_Subtract(__pyx_t_2
, __pyx_t_3
); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 94, __pyx_L1_error
)
3752 __Pyx_GOTREF(__pyx_t_19
);
3753 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
3754 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3755 __Pyx_XDECREF_SET(__pyx_v_new_maximum
, __pyx_t_19
);
3758 /* "MACS2/Signal.pyx":95
3759 * new_signal = signal[minima[i]:minima[i+1]] - threshold
3760 * new_maximum = maxima[i+1] - minima[i]
3761 * if is_valid_peak(new_signal, new_maximum): # <<<<<<<<<<<<<<
3762 * peaky_maxima[j] = maxima[i + 1]
3765 __pyx_t_7
= __Pyx_PyInt_As_int(__pyx_v_new_maximum
); if (unlikely((__pyx_t_7
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L1_error
)
3766 __pyx_t_19
= ((PyObject
*)__pyx_f_5MACS2_6Signal_is_valid_peak(((PyArrayObject
*)__pyx_v_new_signal
), __pyx_t_7
)); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 95, __pyx_L1_error
)
3767 __Pyx_GOTREF(__pyx_t_19
);
3768 __pyx_t_5
= __Pyx_PyObject_IsTrue(__pyx_t_19
); if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 95, __pyx_L1_error
)
3769 __Pyx_DECREF(__pyx_t_19
); __pyx_t_19
= 0;
3772 /* "MACS2/Signal.pyx":96
3773 * new_maximum = maxima[i+1] - minima[i]
3774 * if is_valid_peak(new_signal, new_maximum):
3775 * peaky_maxima[j] = maxima[i + 1] # <<<<<<<<<<<<<<
3777 * threshold = signal[minima[-1]]
3779 __pyx_t_19
= __Pyx_PyInt_AddObjC(__pyx_v_i
, __pyx_int_1
, 1, 0, 0); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 96, __pyx_L1_error
)
3780 __Pyx_GOTREF(__pyx_t_19
);
3781 __pyx_t_3
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_maxima
), __pyx_t_19
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 96, __pyx_L1_error
)
3782 __Pyx_GOTREF(__pyx_t_3
);
3783 __Pyx_DECREF(__pyx_t_19
); __pyx_t_19
= 0;
3784 __pyx_t_22
= __Pyx_PyInt_As_npy_int32(__pyx_t_3
); if (unlikely((__pyx_t_22
== ((npy_int32
)-1)) && PyErr_Occurred())) __PYX_ERR(0, 96, __pyx_L1_error
)
3785 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3786 __pyx_t_23
= __pyx_v_j
;
3788 if (__pyx_t_23
< 0) {
3789 __pyx_t_23
+= __pyx_pybuffernd_peaky_maxima
.diminfo
[0].shape
;
3790 if (unlikely(__pyx_t_23
< 0)) __pyx_t_7
= 0;
3791 } else if (unlikely(__pyx_t_23
>= __pyx_pybuffernd_peaky_maxima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3792 if (unlikely(__pyx_t_7
!= -1)) {
3793 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3794 __PYX_ERR(0, 96, __pyx_L1_error
)
3796 *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_23
, __pyx_pybuffernd_peaky_maxima
.diminfo
[0].strides
) = __pyx_t_22
;
3798 /* "MACS2/Signal.pyx":97
3799 * if is_valid_peak(new_signal, new_maximum):
3800 * peaky_maxima[j] = maxima[i + 1]
3801 * j += 1 # <<<<<<<<<<<<<<
3802 * threshold = signal[minima[-1]]
3803 * threshold += sqrt(threshold)
3805 __pyx_v_j
= (__pyx_v_j
+ 1);
3807 /* "MACS2/Signal.pyx":95
3808 * new_signal = signal[minima[i]:minima[i+1]] - threshold
3809 * new_maximum = maxima[i+1] - minima[i]
3810 * if is_valid_peak(new_signal, new_maximum): # <<<<<<<<<<<<<<
3811 * peaky_maxima[j] = maxima[i + 1]
3816 /* "MACS2/Signal.pyx":90
3817 * peaky_maxima[0] = maxima[0]
3819 * for i in range(n - 1): # <<<<<<<<<<<<<<
3820 * threshold = max(signal[minima[i]], signal[minima[i + 1]])
3821 * threshold += sqrt(threshold)
3824 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3826 /* "MACS2/Signal.pyx":98
3827 * peaky_maxima[j] = maxima[i + 1]
3829 * threshold = signal[minima[-1]] # <<<<<<<<<<<<<<
3830 * threshold += sqrt(threshold)
3831 * new_signal = signal[minima[-1]:] - threshold
3835 if (__pyx_t_24
< 0) {
3836 __pyx_t_24
+= __pyx_pybuffernd_minima
.diminfo
[0].shape
;
3837 if (unlikely(__pyx_t_24
< 0)) __pyx_t_7
= 0;
3838 } else if (unlikely(__pyx_t_24
>= __pyx_pybuffernd_minima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3839 if (unlikely(__pyx_t_7
!= -1)) {
3840 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3841 __PYX_ERR(0, 98, __pyx_L1_error
)
3843 __pyx_t_25
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.buf
, __pyx_t_24
, __pyx_pybuffernd_minima
.diminfo
[0].strides
));
3845 if (__pyx_t_25
< 0) {
3846 __pyx_t_25
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
3847 if (unlikely(__pyx_t_25
< 0)) __pyx_t_7
= 0;
3848 } else if (unlikely(__pyx_t_25
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3849 if (unlikely(__pyx_t_7
!= -1)) {
3850 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3851 __PYX_ERR(0, 98, __pyx_L1_error
)
3853 __pyx_v_threshold
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_25
, __pyx_pybuffernd_signal
.diminfo
[0].strides
));
3855 /* "MACS2/Signal.pyx":99
3857 * threshold = signal[minima[-1]]
3858 * threshold += sqrt(threshold) # <<<<<<<<<<<<<<
3859 * new_signal = signal[minima[-1]:] - threshold
3860 * new_maximum = maxima[-1] - minima[-1]
3862 __pyx_v_threshold
= (__pyx_v_threshold
+ __pyx_f_5MACS2_6Signal_sqrt(__pyx_v_threshold
));
3864 /* "MACS2/Signal.pyx":100
3865 * threshold = signal[minima[-1]]
3866 * threshold += sqrt(threshold)
3867 * new_signal = signal[minima[-1]:] - threshold # <<<<<<<<<<<<<<
3868 * new_maximum = maxima[-1] - minima[-1]
3869 * if is_valid_peak(new_signal, new_maximum):
3873 if (__pyx_t_26
< 0) {
3874 __pyx_t_26
+= __pyx_pybuffernd_minima
.diminfo
[0].shape
;
3875 if (unlikely(__pyx_t_26
< 0)) __pyx_t_7
= 0;
3876 } else if (unlikely(__pyx_t_26
>= __pyx_pybuffernd_minima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3877 if (unlikely(__pyx_t_7
!= -1)) {
3878 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3879 __PYX_ERR(0, 100, __pyx_L1_error
)
3881 __pyx_t_1
= __Pyx_PyInt_From_npy_int32((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.buf
, __pyx_t_26
, __pyx_pybuffernd_minima
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 100, __pyx_L1_error
)
3882 __Pyx_GOTREF(__pyx_t_1
);
3883 __pyx_t_3
= PySlice_New(__pyx_t_1
, Py_None
, Py_None
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 100, __pyx_L1_error
)
3884 __Pyx_GOTREF(__pyx_t_3
);
3885 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3886 __pyx_t_1
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_3
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 100, __pyx_L1_error
)
3887 __Pyx_GOTREF(__pyx_t_1
);
3888 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3889 __pyx_t_3
= PyFloat_FromDouble(__pyx_v_threshold
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 100, __pyx_L1_error
)
3890 __Pyx_GOTREF(__pyx_t_3
);
3891 __pyx_t_19
= PyNumber_Subtract(__pyx_t_1
, __pyx_t_3
); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 100, __pyx_L1_error
)
3892 __Pyx_GOTREF(__pyx_t_19
);
3893 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
3894 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
3895 if (!(likely(((__pyx_t_19
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_19
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 100, __pyx_L1_error
)
3896 __pyx_t_10
= ((PyArrayObject
*)__pyx_t_19
);
3898 __Pyx_BufFmt_StackElem __pyx_stack
[1];
3899 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
);
3900 __pyx_t_7
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_10
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
3901 if (unlikely(__pyx_t_7
< 0)) {
3902 PyErr_Fetch(&__pyx_t_11
, &__pyx_t_12
, &__pyx_t_13
);
3903 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_new_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
3904 Py_XDECREF(__pyx_t_11
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_13
);
3905 __Pyx_RaiseBufferFallbackError();
3907 PyErr_Restore(__pyx_t_11
, __pyx_t_12
, __pyx_t_13
);
3909 __pyx_t_11
= __pyx_t_12
= __pyx_t_13
= 0;
3911 __pyx_pybuffernd_new_signal
.diminfo
[0].strides
= __pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_new_signal
.diminfo
[0].shape
= __pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
.shape
[0];
3912 if (unlikely(__pyx_t_7
< 0)) __PYX_ERR(0, 100, __pyx_L1_error
)
3915 __Pyx_DECREF_SET(__pyx_v_new_signal
, ((PyArrayObject
*)__pyx_t_19
));
3918 /* "MACS2/Signal.pyx":101
3919 * threshold += sqrt(threshold)
3920 * new_signal = signal[minima[-1]:] - threshold
3921 * new_maximum = maxima[-1] - minima[-1] # <<<<<<<<<<<<<<
3922 * if is_valid_peak(new_signal, new_maximum):
3923 * peaky_maxima[j] = maxima[-1]
3927 if (__pyx_t_27
< 0) {
3928 __pyx_t_27
+= __pyx_pybuffernd_maxima
.diminfo
[0].shape
;
3929 if (unlikely(__pyx_t_27
< 0)) __pyx_t_7
= 0;
3930 } else if (unlikely(__pyx_t_27
>= __pyx_pybuffernd_maxima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3931 if (unlikely(__pyx_t_7
!= -1)) {
3932 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3933 __PYX_ERR(0, 101, __pyx_L1_error
)
3937 if (__pyx_t_28
< 0) {
3938 __pyx_t_28
+= __pyx_pybuffernd_minima
.diminfo
[0].shape
;
3939 if (unlikely(__pyx_t_28
< 0)) __pyx_t_7
= 0;
3940 } else if (unlikely(__pyx_t_28
>= __pyx_pybuffernd_minima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3941 if (unlikely(__pyx_t_7
!= -1)) {
3942 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3943 __PYX_ERR(0, 101, __pyx_L1_error
)
3945 __pyx_t_19
= __Pyx_PyInt_From_npy_int32(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_27
, __pyx_pybuffernd_maxima
.diminfo
[0].strides
)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_minima
.rcbuffer
->pybuffer
.buf
, __pyx_t_28
, __pyx_pybuffernd_minima
.diminfo
[0].strides
)))); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 101, __pyx_L1_error
)
3946 __Pyx_GOTREF(__pyx_t_19
);
3947 __Pyx_XDECREF_SET(__pyx_v_new_maximum
, __pyx_t_19
);
3950 /* "MACS2/Signal.pyx":102
3951 * new_signal = signal[minima[-1]:] - threshold
3952 * new_maximum = maxima[-1] - minima[-1]
3953 * if is_valid_peak(new_signal, new_maximum): # <<<<<<<<<<<<<<
3954 * peaky_maxima[j] = maxima[-1]
3957 __pyx_t_7
= __Pyx_PyInt_As_int(__pyx_v_new_maximum
); if (unlikely((__pyx_t_7
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L1_error
)
3958 __pyx_t_19
= ((PyObject
*)__pyx_f_5MACS2_6Signal_is_valid_peak(((PyArrayObject
*)__pyx_v_new_signal
), __pyx_t_7
)); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 102, __pyx_L1_error
)
3959 __Pyx_GOTREF(__pyx_t_19
);
3960 __pyx_t_5
= __Pyx_PyObject_IsTrue(__pyx_t_19
); if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 102, __pyx_L1_error
)
3961 __Pyx_DECREF(__pyx_t_19
); __pyx_t_19
= 0;
3964 /* "MACS2/Signal.pyx":103
3965 * new_maximum = maxima[-1] - minima[-1]
3966 * if is_valid_peak(new_signal, new_maximum):
3967 * peaky_maxima[j] = maxima[-1] # <<<<<<<<<<<<<<
3969 * peaky_maxima.resize(j, refcheck=False)
3973 if (__pyx_t_29
< 0) {
3974 __pyx_t_29
+= __pyx_pybuffernd_maxima
.diminfo
[0].shape
;
3975 if (unlikely(__pyx_t_29
< 0)) __pyx_t_7
= 0;
3976 } else if (unlikely(__pyx_t_29
>= __pyx_pybuffernd_maxima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3977 if (unlikely(__pyx_t_7
!= -1)) {
3978 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3979 __PYX_ERR(0, 103, __pyx_L1_error
)
3981 __pyx_t_30
= __pyx_v_j
;
3983 if (__pyx_t_30
< 0) {
3984 __pyx_t_30
+= __pyx_pybuffernd_peaky_maxima
.diminfo
[0].shape
;
3985 if (unlikely(__pyx_t_30
< 0)) __pyx_t_7
= 0;
3986 } else if (unlikely(__pyx_t_30
>= __pyx_pybuffernd_peaky_maxima
.diminfo
[0].shape
)) __pyx_t_7
= 0;
3987 if (unlikely(__pyx_t_7
!= -1)) {
3988 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
3989 __PYX_ERR(0, 103, __pyx_L1_error
)
3991 *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_30
, __pyx_pybuffernd_peaky_maxima
.diminfo
[0].strides
) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.buf
, __pyx_t_29
, __pyx_pybuffernd_maxima
.diminfo
[0].strides
));
3993 /* "MACS2/Signal.pyx":104
3994 * if is_valid_peak(new_signal, new_maximum):
3995 * peaky_maxima[j] = maxima[-1]
3996 * j += 1 # <<<<<<<<<<<<<<
3997 * peaky_maxima.resize(j, refcheck=False)
3998 * return peaky_maxima
4000 __pyx_v_j
= (__pyx_v_j
+ 1);
4002 /* "MACS2/Signal.pyx":102
4003 * new_signal = signal[minima[-1]:] - threshold
4004 * new_maximum = maxima[-1] - minima[-1]
4005 * if is_valid_peak(new_signal, new_maximum): # <<<<<<<<<<<<<<
4006 * peaky_maxima[j] = maxima[-1]
4011 /* "MACS2/Signal.pyx":105
4012 * peaky_maxima[j] = maxima[-1]
4014 * peaky_maxima.resize(j, refcheck=False) # <<<<<<<<<<<<<<
4015 * return peaky_maxima
4018 __pyx_t_19
= __Pyx_PyObject_GetAttrStr(((PyObject
*)__pyx_v_peaky_maxima
), __pyx_n_s_resize
); if (unlikely(!__pyx_t_19
)) __PYX_ERR(0, 105, __pyx_L1_error
)
4019 __Pyx_GOTREF(__pyx_t_19
);
4020 __pyx_t_3
= __Pyx_PyInt_From_int(__pyx_v_j
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 105, __pyx_L1_error
)
4021 __Pyx_GOTREF(__pyx_t_3
);
4022 __pyx_t_1
= PyTuple_New(1); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 105, __pyx_L1_error
)
4023 __Pyx_GOTREF(__pyx_t_1
);
4024 __Pyx_GIVEREF(__pyx_t_3
);
4025 PyTuple_SET_ITEM(__pyx_t_1
, 0, __pyx_t_3
);
4027 __pyx_t_3
= __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 105, __pyx_L1_error
)
4028 __Pyx_GOTREF(__pyx_t_3
);
4029 if (PyDict_SetItem(__pyx_t_3
, __pyx_n_s_refcheck
, Py_False
) < 0) __PYX_ERR(0, 105, __pyx_L1_error
)
4030 __pyx_t_2
= __Pyx_PyObject_Call(__pyx_t_19
, __pyx_t_1
, __pyx_t_3
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 105, __pyx_L1_error
)
4031 __Pyx_GOTREF(__pyx_t_2
);
4032 __Pyx_DECREF(__pyx_t_19
); __pyx_t_19
= 0;
4033 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
4034 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
4035 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
4037 /* "MACS2/Signal.pyx":106
4039 * peaky_maxima.resize(j, refcheck=False)
4040 * return peaky_maxima # <<<<<<<<<<<<<<
4042 * # hardcoded minimum peak width = 50
4044 __Pyx_XDECREF(__pyx_r
);
4045 __Pyx_INCREF(((PyObject
*)__pyx_v_peaky_maxima
));
4046 __pyx_r
= ((PyObject
*)__pyx_v_peaky_maxima
);
4049 /* "MACS2/Signal.pyx":58
4050 * return mathsqrt(threshold)
4052 * cpdef enforce_peakyness(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
4053 * np.ndarray[np.int32_t, ndim=1] maxima):
4054 * """requires peaks described by a signal and a set of points where the signal
4057 /* function exit code */
4059 __Pyx_XDECREF(__pyx_t_1
);
4060 __Pyx_XDECREF(__pyx_t_2
);
4061 __Pyx_XDECREF(__pyx_t_3
);
4062 __Pyx_XDECREF(__pyx_t_19
);
4063 __Pyx_XDECREF(__pyx_t_20
);
4064 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
4065 __Pyx_PyThreadState_declare
4066 __Pyx_PyThreadState_assign
4067 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
4068 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
);
4069 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_minima
.rcbuffer
->pybuffer
);
4070 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
);
4071 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
);
4072 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4073 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
4074 __Pyx_AddTraceback("MACS2.Signal.enforce_peakyness", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
4078 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
);
4079 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_minima
.rcbuffer
->pybuffer
);
4080 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal
.rcbuffer
->pybuffer
);
4081 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_peaky_maxima
.rcbuffer
->pybuffer
);
4082 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4084 __Pyx_XDECREF((PyObject
*)__pyx_v_minima
);
4085 __Pyx_XDECREF((PyObject
*)__pyx_v_new_signal
);
4086 __Pyx_XDECREF((PyObject
*)__pyx_v_peaky_maxima
);
4087 __Pyx_XDECREF(__pyx_v_i
);
4088 __Pyx_XDECREF(__pyx_v_new_maximum
);
4089 __Pyx_XGIVEREF(__pyx_r
);
4090 __Pyx_TraceReturn(__pyx_r
, 0);
4091 __Pyx_RefNannyFinishContext();
4095 /* Python wrapper */
4096 static PyObject
*__pyx_pw_5MACS2_6Signal_3enforce_peakyness(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
4097 static char __pyx_doc_5MACS2_6Signal_2enforce_peakyness
[] = "requires peaks described by a signal and a set of points where the signal\n is at a maximum to meet a certain set of criteria\n \n maxima which do not meet the required criteria are discarded\n \n criteria:\n for each peak:\n calculate a threshold of the maximum of its adjacent two minima\n plus the sqrt of that value\n subtract the threshold from the region bounded by those minima\n clip that region if negative values occur inside it\n require it be > 50 bp in width\n require that it not be too flat (< 6 unique values) \n ";
4098 static PyObject
*__pyx_pw_5MACS2_6Signal_3enforce_peakyness(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
) {
4099 PyArrayObject
*__pyx_v_signal
= 0;
4100 PyArrayObject
*__pyx_v_maxima
= 0;
4101 PyObject
*__pyx_r
= 0;
4102 __Pyx_RefNannyDeclarations
4103 __Pyx_RefNannySetupContext("enforce_peakyness (wrapper)", 0);
4105 static PyObject
**__pyx_pyargnames
[] = {&__pyx_n_s_signal
,&__pyx_n_s_maxima
,0};
4106 PyObject
* values
[2] = {0,0};
4107 if (unlikely(__pyx_kwds
)) {
4109 const Py_ssize_t pos_args
= PyTuple_GET_SIZE(__pyx_args
);
4111 case 2: values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
4113 case 1: values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
4116 default: goto __pyx_L5_argtuple_error
;
4118 kw_args
= PyDict_Size(__pyx_kwds
);
4121 if (likely((values
[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_signal
)) != 0)) kw_args
--;
4122 else goto __pyx_L5_argtuple_error
;
4125 if (likely((values
[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_maxima
)) != 0)) kw_args
--;
4127 __Pyx_RaiseArgtupleInvalid("enforce_peakyness", 1, 2, 2, 1); __PYX_ERR(0, 58, __pyx_L3_error
)
4130 if (unlikely(kw_args
> 0)) {
4131 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds
, __pyx_pyargnames
, 0, values
, pos_args
, "enforce_peakyness") < 0)) __PYX_ERR(0, 58, __pyx_L3_error
)
4133 } else if (PyTuple_GET_SIZE(__pyx_args
) != 2) {
4134 goto __pyx_L5_argtuple_error
;
4136 values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
4137 values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
4139 __pyx_v_signal
= ((PyArrayObject
*)values
[0]);
4140 __pyx_v_maxima
= ((PyArrayObject
*)values
[1]);
4142 goto __pyx_L4_argument_unpacking_done
;
4143 __pyx_L5_argtuple_error
:;
4144 __Pyx_RaiseArgtupleInvalid("enforce_peakyness", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args
)); __PYX_ERR(0, 58, __pyx_L3_error
)
4146 __Pyx_AddTraceback("MACS2.Signal.enforce_peakyness", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
4147 __Pyx_RefNannyFinishContext();
4149 __pyx_L4_argument_unpacking_done
:;
4150 if (unlikely(!__Pyx_ArgTypeTest(((PyObject
*)__pyx_v_signal
), __pyx_ptype_5numpy_ndarray
, 1, "signal", 0))) __PYX_ERR(0, 58, __pyx_L1_error
)
4151 if (unlikely(!__Pyx_ArgTypeTest(((PyObject
*)__pyx_v_maxima
), __pyx_ptype_5numpy_ndarray
, 1, "maxima", 0))) __PYX_ERR(0, 59, __pyx_L1_error
)
4152 __pyx_r
= __pyx_pf_5MACS2_6Signal_2enforce_peakyness(__pyx_self
, __pyx_v_signal
, __pyx_v_maxima
);
4154 /* function exit code */
4159 __Pyx_RefNannyFinishContext();
4163 static PyObject
*__pyx_pf_5MACS2_6Signal_2enforce_peakyness(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, PyArrayObject
*__pyx_v_maxima
) {
4164 __Pyx_LocalBuf_ND __pyx_pybuffernd_maxima
;
4165 __Pyx_Buffer __pyx_pybuffer_maxima
;
4166 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
4167 __Pyx_Buffer __pyx_pybuffer_signal
;
4168 PyObject
*__pyx_r
= NULL
;
4169 __Pyx_TraceDeclarations
4170 __Pyx_RefNannyDeclarations
4171 PyObject
*__pyx_t_1
= NULL
;
4172 __Pyx_RefNannySetupContext("enforce_peakyness", 0);
4173 __Pyx_TraceCall("enforce_peakyness (wrapper)", __pyx_f
[0], 58, 0, __PYX_ERR(0, 58, __pyx_L1_error
));
4174 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
4175 __pyx_pybuffer_signal
.refcount
= 0;
4176 __pyx_pybuffernd_signal
.data
= NULL
;
4177 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
4178 __pyx_pybuffer_maxima
.pybuffer
.buf
= NULL
;
4179 __pyx_pybuffer_maxima
.refcount
= 0;
4180 __pyx_pybuffernd_maxima
.data
= NULL
;
4181 __pyx_pybuffernd_maxima
.rcbuffer
= &__pyx_pybuffer_maxima
;
4183 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4184 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 58, __pyx_L1_error
)
4186 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
4188 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4189 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_maxima
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 58, __pyx_L1_error
)
4191 __pyx_pybuffernd_maxima
.diminfo
[0].strides
= __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_maxima
.diminfo
[0].shape
= __pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
.shape
[0];
4192 __Pyx_XDECREF(__pyx_r
);
4193 __pyx_t_1
= __pyx_f_5MACS2_6Signal_enforce_peakyness(__pyx_v_signal
, __pyx_v_maxima
, 0); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 58, __pyx_L1_error
)
4194 __Pyx_GOTREF(__pyx_t_1
);
4195 __pyx_r
= __pyx_t_1
;
4199 /* function exit code */
4201 __Pyx_XDECREF(__pyx_t_1
);
4202 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
4203 __Pyx_PyThreadState_declare
4204 __Pyx_PyThreadState_assign
4205 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
4206 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
);
4207 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4208 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
4209 __Pyx_AddTraceback("MACS2.Signal.enforce_peakyness", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
4213 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima
.rcbuffer
->pybuffer
);
4214 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4216 __Pyx_XGIVEREF(__pyx_r
);
4217 __Pyx_TraceReturn(__pyx_r
, 0);
4218 __Pyx_RefNannyFinishContext();
4222 /* "MACS2/Signal.pyx":109
4224 * # hardcoded minimum peak width = 50
4225 * cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum): # <<<<<<<<<<<<<<
4227 * s = hard_clip(signal, maximum)
4230 static PyBoolObject
*__pyx_f_5MACS2_6Signal_is_valid_peak(PyArrayObject
*__pyx_v_signal
, int __pyx_v_maximum
) {
4231 PyObject
*__pyx_v_s
= 0;
4233 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
4234 __Pyx_Buffer __pyx_pybuffer_signal
;
4235 PyBoolObject
*__pyx_r
= NULL
;
4236 __Pyx_TraceDeclarations
4237 __Pyx_RefNannyDeclarations
4238 PyObject
*__pyx_t_1
= NULL
;
4239 PyObject
*__pyx_t_2
= NULL
;
4242 __Pyx_RefNannySetupContext("is_valid_peak", 0);
4243 __Pyx_TraceCall("is_valid_peak", __pyx_f
[0], 109, 0, __PYX_ERR(0, 109, __pyx_L1_error
));
4244 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
4245 __pyx_pybuffer_signal
.refcount
= 0;
4246 __pyx_pybuffernd_signal
.data
= NULL
;
4247 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
4249 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4250 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 109, __pyx_L1_error
)
4252 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
4254 /* "MACS2/Signal.pyx":111
4255 * cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum):
4257 * s = hard_clip(signal, maximum) # <<<<<<<<<<<<<<
4258 * int length = s.shape[0]
4259 * if length < 50: return False
4261 __pyx_t_1
= ((PyObject
*)__pyx_f_5MACS2_6Signal_hard_clip(((PyArrayObject
*)__pyx_v_signal
), __pyx_v_maximum
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 111, __pyx_L1_error
)
4262 __Pyx_GOTREF(__pyx_t_1
);
4263 __pyx_v_s
= __pyx_t_1
;
4266 /* "MACS2/Signal.pyx":112
4268 * s = hard_clip(signal, maximum)
4269 * int length = s.shape[0] # <<<<<<<<<<<<<<
4270 * if length < 50: return False
4271 * elif too_flat(s): return False
4273 __pyx_t_1
= __Pyx_PyObject_GetAttrStr(__pyx_v_s
, __pyx_n_s_shape
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 112, __pyx_L1_error
)
4274 __Pyx_GOTREF(__pyx_t_1
);
4275 __pyx_t_2
= __Pyx_GetItemInt(__pyx_t_1
, 0, long, 1, __Pyx_PyInt_From_long
, 0, 0, 1); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 112, __pyx_L1_error
)
4276 __Pyx_GOTREF(__pyx_t_2
);
4277 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
4278 __pyx_t_3
= __Pyx_PyInt_As_int(__pyx_t_2
); if (unlikely((__pyx_t_3
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error
)
4279 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
4280 __pyx_v_length
= __pyx_t_3
;
4282 /* "MACS2/Signal.pyx":113
4283 * s = hard_clip(signal, maximum)
4284 * int length = s.shape[0]
4285 * if length < 50: return False # <<<<<<<<<<<<<<
4286 * elif too_flat(s): return False
4289 __pyx_t_4
= ((__pyx_v_length
< 50) != 0);
4291 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
4292 __Pyx_INCREF(Py_False
);
4293 __pyx_r
= ((PyBoolObject
*)Py_False
);
4297 /* "MACS2/Signal.pyx":114
4298 * int length = s.shape[0]
4299 * if length < 50: return False
4300 * elif too_flat(s): return False # <<<<<<<<<<<<<<
4304 if (!(likely(((__pyx_v_s
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_v_s
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 114, __pyx_L1_error
)
4305 __pyx_t_2
= ((PyObject
*)__pyx_f_5MACS2_6Signal_too_flat(((PyArrayObject
*)__pyx_v_s
))); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 114, __pyx_L1_error
)
4306 __Pyx_GOTREF(__pyx_t_2
);
4307 __pyx_t_4
= __Pyx_PyObject_IsTrue(__pyx_t_2
); if (unlikely(__pyx_t_4
< 0)) __PYX_ERR(0, 114, __pyx_L1_error
)
4308 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
4310 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
4311 __Pyx_INCREF(Py_False
);
4312 __pyx_r
= ((PyBoolObject
*)Py_False
);
4316 /* "MACS2/Signal.pyx":115
4317 * if length < 50: return False
4318 * elif too_flat(s): return False
4319 * return True # <<<<<<<<<<<<<<
4321 * # require at least 6 different float values -- prevents broad flat peaks
4323 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
4324 __Pyx_INCREF(Py_True
);
4325 __pyx_r
= ((PyBoolObject
*)Py_True
);
4328 /* "MACS2/Signal.pyx":109
4330 * # hardcoded minimum peak width = 50
4331 * cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum): # <<<<<<<<<<<<<<
4333 * s = hard_clip(signal, maximum)
4336 /* function exit code */
4338 __Pyx_XDECREF(__pyx_t_1
);
4339 __Pyx_XDECREF(__pyx_t_2
);
4340 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
4341 __Pyx_PyThreadState_declare
4342 __Pyx_PyThreadState_assign
4343 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
4344 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4345 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
4346 __Pyx_AddTraceback("MACS2.Signal.is_valid_peak", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
4350 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4352 __Pyx_XDECREF(__pyx_v_s
);
4353 __Pyx_XGIVEREF((PyObject
*)__pyx_r
);
4354 __Pyx_TraceReturn(__pyx_r
, 0);
4355 __Pyx_RefNannyFinishContext();
4359 /* "MACS2/Signal.pyx":118
4361 * # require at least 6 different float values -- prevents broad flat peaks
4362 * cdef bool too_flat(np.ndarray[np.float32_t, ndim=1] signal): # <<<<<<<<<<<<<<
4363 * # """return whether signal has at least 6 unique values
4367 static PyBoolObject
*__pyx_f_5MACS2_6Signal_too_flat(PyArrayObject
*__pyx_v_signal
) {
4368 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
4369 __Pyx_Buffer __pyx_pybuffer_signal
;
4370 PyBoolObject
*__pyx_r
= NULL
;
4371 __Pyx_TraceDeclarations
4372 __Pyx_RefNannyDeclarations
4373 PyObject
*__pyx_t_1
= NULL
;
4374 PyObject
*__pyx_t_2
= NULL
;
4375 PyObject
*__pyx_t_3
= NULL
;
4376 __Pyx_RefNannySetupContext("too_flat", 0);
4377 __Pyx_TraceCall("too_flat", __pyx_f
[0], 118, 0, __PYX_ERR(0, 118, __pyx_L1_error
));
4378 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
4379 __pyx_pybuffer_signal
.refcount
= 0;
4380 __pyx_pybuffernd_signal
.data
= NULL
;
4381 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
4383 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4384 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 118, __pyx_L1_error
)
4386 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
4388 /* "MACS2/Signal.pyx":121
4389 * # """return whether signal has at least 6 unique values
4391 * return np.unique(signal).shape[0] < 6 # <<<<<<<<<<<<<<
4393 * # hard clip a region with negative values
4395 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
4396 __Pyx_GetModuleGlobalName(__pyx_t_2
, __pyx_n_s_np
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 121, __pyx_L1_error
)
4397 __Pyx_GOTREF(__pyx_t_2
);
4398 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_unique
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 121, __pyx_L1_error
)
4399 __Pyx_GOTREF(__pyx_t_3
);
4400 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
4402 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_3
))) {
4403 __pyx_t_2
= PyMethod_GET_SELF(__pyx_t_3
);
4404 if (likely(__pyx_t_2
)) {
4405 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_3
);
4406 __Pyx_INCREF(__pyx_t_2
);
4407 __Pyx_INCREF(function
);
4408 __Pyx_DECREF_SET(__pyx_t_3
, function
);
4411 __pyx_t_1
= (__pyx_t_2
) ? __Pyx_PyObject_Call2Args(__pyx_t_3
, __pyx_t_2
, ((PyObject
*)__pyx_v_signal
)) : __Pyx_PyObject_CallOneArg(__pyx_t_3
, ((PyObject
*)__pyx_v_signal
));
4412 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
4413 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 121, __pyx_L1_error
)
4414 __Pyx_GOTREF(__pyx_t_1
);
4415 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
4416 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_1
, __pyx_n_s_shape
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 121, __pyx_L1_error
)
4417 __Pyx_GOTREF(__pyx_t_3
);
4418 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
4419 __pyx_t_1
= __Pyx_GetItemInt(__pyx_t_3
, 0, long, 1, __Pyx_PyInt_From_long
, 0, 0, 1); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 121, __pyx_L1_error
)
4420 __Pyx_GOTREF(__pyx_t_1
);
4421 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
4422 __pyx_t_3
= PyObject_RichCompare(__pyx_t_1
, __pyx_int_6
, Py_LT
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 121, __pyx_L1_error
)
4423 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
4424 if (!(likely(((__pyx_t_3
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_3
, __pyx_ptype_7cpython_4bool_bool
))))) __PYX_ERR(0, 121, __pyx_L1_error
)
4425 __pyx_r
= ((PyBoolObject
*)__pyx_t_3
);
4429 /* "MACS2/Signal.pyx":118
4431 * # require at least 6 different float values -- prevents broad flat peaks
4432 * cdef bool too_flat(np.ndarray[np.float32_t, ndim=1] signal): # <<<<<<<<<<<<<<
4433 * # """return whether signal has at least 6 unique values
4437 /* function exit code */
4439 __Pyx_XDECREF(__pyx_t_1
);
4440 __Pyx_XDECREF(__pyx_t_2
);
4441 __Pyx_XDECREF(__pyx_t_3
);
4442 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
4443 __Pyx_PyThreadState_declare
4444 __Pyx_PyThreadState_assign
4445 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
4446 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4447 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
4448 __Pyx_AddTraceback("MACS2.Signal.too_flat", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
4452 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4454 __Pyx_XGIVEREF((PyObject
*)__pyx_r
);
4455 __Pyx_TraceReturn(__pyx_r
, 0);
4456 __Pyx_RefNannyFinishContext();
4460 /* "MACS2/Signal.pyx":124
4462 * # hard clip a region with negative values
4463 * cdef np.ndarray[np.float32_t, ndim=1] hard_clip(np.ndarray[np.float32_t, ndim=1] signal, int maximum): # <<<<<<<<<<<<<<
4464 * # """clip the signal in both directions at the nearest values <= 0
4465 * # to position maximum
4468 static PyArrayObject
*__pyx_f_5MACS2_6Signal_hard_clip(PyArrayObject
*__pyx_v_signal
, int __pyx_v_maximum
) {
4472 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
4473 __Pyx_Buffer __pyx_pybuffer_signal
;
4474 PyArrayObject
*__pyx_r
= NULL
;
4475 __Pyx_TraceDeclarations
4476 __Pyx_RefNannyDeclarations
4478 Py_ssize_t __pyx_t_2
;
4482 Py_ssize_t __pyx_t_6
;
4484 PyObject
*__pyx_t_8
= NULL
;
4485 PyObject
*__pyx_t_9
= NULL
;
4486 PyObject
*__pyx_t_10
= NULL
;
4487 __Pyx_RefNannySetupContext("hard_clip", 0);
4488 __Pyx_TraceCall("hard_clip", __pyx_f
[0], 124, 0, __PYX_ERR(0, 124, __pyx_L1_error
));
4489 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
4490 __pyx_pybuffer_signal
.refcount
= 0;
4491 __pyx_pybuffernd_signal
.data
= NULL
;
4492 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
4494 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4495 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 124, __pyx_L1_error
)
4497 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
4499 /* "MACS2/Signal.pyx":130
4502 * int left = 0 # <<<<<<<<<<<<<<
4503 * int right = signal.shape[0]
4508 /* "MACS2/Signal.pyx":131
4511 * int right = signal.shape[0] # <<<<<<<<<<<<<<
4513 * for i in range(right - maximum, 0):
4515 __pyx_v_right
= (__pyx_v_signal
->dimensions
[0]);
4517 /* "MACS2/Signal.pyx":133
4518 * int right = signal.shape[0]
4520 * for i in range(right - maximum, 0): # <<<<<<<<<<<<<<
4521 * if signal[-i] < 0:
4524 for (__pyx_t_1
= (__pyx_v_right
- __pyx_v_maximum
); __pyx_t_1
< 0; __pyx_t_1
+=1) {
4525 __pyx_v_i
= __pyx_t_1
;
4527 /* "MACS2/Signal.pyx":134
4529 * for i in range(right - maximum, 0):
4530 * if signal[-i] < 0: # <<<<<<<<<<<<<<
4534 __pyx_t_2
= (-__pyx_v_i
);
4536 if (__pyx_t_2
< 0) {
4537 __pyx_t_2
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
4538 if (unlikely(__pyx_t_2
< 0)) __pyx_t_3
= 0;
4539 } else if (unlikely(__pyx_t_2
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_3
= 0;
4540 if (unlikely(__pyx_t_3
!= -1)) {
4541 __Pyx_RaiseBufferIndexError(__pyx_t_3
);
4542 __PYX_ERR(0, 134, __pyx_L1_error
)
4544 __pyx_t_4
= (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_2
, __pyx_pybuffernd_signal
.diminfo
[0].strides
)) < 0.0) != 0);
4547 /* "MACS2/Signal.pyx":135
4548 * for i in range(right - maximum, 0):
4549 * if signal[-i] < 0:
4550 * left = i # <<<<<<<<<<<<<<
4552 * for i in range(maximum, right):
4554 __pyx_v_left
= __pyx_v_i
;
4556 /* "MACS2/Signal.pyx":136
4557 * if signal[-i] < 0:
4559 * break # <<<<<<<<<<<<<<
4560 * for i in range(maximum, right):
4563 goto __pyx_L4_break
;
4565 /* "MACS2/Signal.pyx":134
4567 * for i in range(right - maximum, 0):
4568 * if signal[-i] < 0: # <<<<<<<<<<<<<<
4576 /* "MACS2/Signal.pyx":137
4579 * for i in range(maximum, right): # <<<<<<<<<<<<<<
4583 __pyx_t_1
= __pyx_v_right
;
4584 __pyx_t_3
= __pyx_t_1
;
4585 for (__pyx_t_5
= __pyx_v_maximum
; __pyx_t_5
< __pyx_t_3
; __pyx_t_5
+=1) {
4586 __pyx_v_i
= __pyx_t_5
;
4588 /* "MACS2/Signal.pyx":138
4590 * for i in range(maximum, right):
4591 * if signal[i] < 0: # <<<<<<<<<<<<<<
4595 __pyx_t_6
= __pyx_v_i
;
4597 if (__pyx_t_6
< 0) {
4598 __pyx_t_6
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
4599 if (unlikely(__pyx_t_6
< 0)) __pyx_t_7
= 0;
4600 } else if (unlikely(__pyx_t_6
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_7
= 0;
4601 if (unlikely(__pyx_t_7
!= -1)) {
4602 __Pyx_RaiseBufferIndexError(__pyx_t_7
);
4603 __PYX_ERR(0, 138, __pyx_L1_error
)
4605 __pyx_t_4
= (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_6
, __pyx_pybuffernd_signal
.diminfo
[0].strides
)) < 0.0) != 0);
4608 /* "MACS2/Signal.pyx":139
4609 * for i in range(maximum, right):
4611 * right = i # <<<<<<<<<<<<<<
4613 * return signal[left:right]
4615 __pyx_v_right
= __pyx_v_i
;
4617 /* "MACS2/Signal.pyx":140
4620 * break # <<<<<<<<<<<<<<
4621 * return signal[left:right]
4624 goto __pyx_L7_break
;
4626 /* "MACS2/Signal.pyx":138
4628 * for i in range(maximum, right):
4629 * if signal[i] < 0: # <<<<<<<<<<<<<<
4637 /* "MACS2/Signal.pyx":141
4640 * return signal[left:right] # <<<<<<<<<<<<<<
4642 * # for all maxima, set min_subpeak_width = 0
4644 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
4645 __pyx_t_8
= __Pyx_PyInt_From_int(__pyx_v_left
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 141, __pyx_L1_error
)
4646 __Pyx_GOTREF(__pyx_t_8
);
4647 __pyx_t_9
= __Pyx_PyInt_From_int(__pyx_v_right
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 141, __pyx_L1_error
)
4648 __Pyx_GOTREF(__pyx_t_9
);
4649 __pyx_t_10
= PySlice_New(__pyx_t_8
, __pyx_t_9
, Py_None
); if (unlikely(!__pyx_t_10
)) __PYX_ERR(0, 141, __pyx_L1_error
)
4650 __Pyx_GOTREF(__pyx_t_10
);
4651 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
4652 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
4653 __pyx_t_9
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_10
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 141, __pyx_L1_error
)
4654 __Pyx_GOTREF(__pyx_t_9
);
4655 __Pyx_DECREF(__pyx_t_10
); __pyx_t_10
= 0;
4656 if (!(likely(((__pyx_t_9
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_9
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 141, __pyx_L1_error
)
4657 __pyx_r
= ((PyArrayObject
*)__pyx_t_9
);
4661 /* "MACS2/Signal.pyx":124
4663 * # hard clip a region with negative values
4664 * cdef np.ndarray[np.float32_t, ndim=1] hard_clip(np.ndarray[np.float32_t, ndim=1] signal, int maximum): # <<<<<<<<<<<<<<
4665 * # """clip the signal in both directions at the nearest values <= 0
4666 * # to position maximum
4669 /* function exit code */
4671 __Pyx_XDECREF(__pyx_t_8
);
4672 __Pyx_XDECREF(__pyx_t_9
);
4673 __Pyx_XDECREF(__pyx_t_10
);
4674 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
4675 __Pyx_PyThreadState_declare
4676 __Pyx_PyThreadState_assign
4677 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
4678 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4679 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
4680 __Pyx_AddTraceback("MACS2.Signal.hard_clip", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
4684 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
4686 __Pyx_XGIVEREF((PyObject
*)__pyx_r
);
4687 __Pyx_TraceReturn(__pyx_r
, 0);
4688 __Pyx_RefNannyFinishContext();
4692 /* "MACS2/Signal.pyx":171
4695 * cpdef enforce_valleys(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
4696 * np.ndarray[np.int32_t, ndim=1] summits,
4697 * float min_valley = 0.8):
4700 static PyObject
*__pyx_pw_5MACS2_6Signal_5enforce_valleys(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
4701 static PyObject
*__pyx_f_5MACS2_6Signal_enforce_valleys(PyArrayObject
*__pyx_v_signal
, PyArrayObject
*__pyx_v_summits
, CYTHON_UNUSED
int __pyx_skip_dispatch
, struct __pyx_opt_args_5MACS2_6Signal_enforce_valleys
*__pyx_optional_args
) {
4702 float __pyx_v_min_valley
= ((float)0.8);
4703 float __pyx_v_req_min
;
4705 float __pyx_v_prev_v
;
4706 int __pyx_v_summit_pos
;
4707 int __pyx_v_prev_summit_pos
;
4708 int __pyx_v_n_summits
;
4709 int __pyx_v_n_valid_summits
;
4710 PyArrayObject
*__pyx_v_valid_summits
= 0;
4712 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
4713 __Pyx_Buffer __pyx_pybuffer_signal
;
4714 __Pyx_LocalBuf_ND __pyx_pybuffernd_summits
;
4715 __Pyx_Buffer __pyx_pybuffer_summits
;
4716 __Pyx_LocalBuf_ND __pyx_pybuffernd_valid_summits
;
4717 __Pyx_Buffer __pyx_pybuffer_valid_summits
;
4718 PyObject
*__pyx_r
= NULL
;
4719 __Pyx_TraceDeclarations
4720 __Pyx_RefNannyDeclarations
4721 PyObject
*__pyx_t_1
= NULL
;
4722 PyObject
*__pyx_t_2
= NULL
;
4723 PyObject
*__pyx_t_3
= NULL
;
4724 PyArrayObject
*__pyx_t_4
= NULL
;
4729 Py_ssize_t __pyx_t_9
;
4731 Py_ssize_t __pyx_t_11
;
4732 Py_ssize_t __pyx_t_12
;
4733 Py_ssize_t __pyx_t_13
;
4737 PyObject
*__pyx_t_17
= NULL
;
4738 Py_ssize_t __pyx_t_18
;
4739 Py_ssize_t __pyx_t_19
;
4740 __Pyx_RefNannySetupContext("enforce_valleys", 0);
4741 __Pyx_TraceCall("enforce_valleys", __pyx_f
[0], 171, 0, __PYX_ERR(0, 171, __pyx_L1_error
));
4742 if (__pyx_optional_args
) {
4743 if (__pyx_optional_args
->__pyx_n
> 0) {
4744 __pyx_v_min_valley
= __pyx_optional_args
->min_valley
;
4747 __pyx_pybuffer_valid_summits
.pybuffer
.buf
= NULL
;
4748 __pyx_pybuffer_valid_summits
.refcount
= 0;
4749 __pyx_pybuffernd_valid_summits
.data
= NULL
;
4750 __pyx_pybuffernd_valid_summits
.rcbuffer
= &__pyx_pybuffer_valid_summits
;
4751 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
4752 __pyx_pybuffer_signal
.refcount
= 0;
4753 __pyx_pybuffernd_signal
.data
= NULL
;
4754 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
4755 __pyx_pybuffer_summits
.pybuffer
.buf
= NULL
;
4756 __pyx_pybuffer_summits
.refcount
= 0;
4757 __pyx_pybuffernd_summits
.data
= NULL
;
4758 __pyx_pybuffernd_summits
.rcbuffer
= &__pyx_pybuffer_summits
;
4760 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4761 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 171, __pyx_L1_error
)
4763 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
4765 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4766 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_summits
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_summits
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 171, __pyx_L1_error
)
4768 __pyx_pybuffernd_summits
.diminfo
[0].strides
= __pyx_pybuffernd_summits
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_summits
.diminfo
[0].shape
= __pyx_pybuffernd_summits
.rcbuffer
->pybuffer
.shape
[0];
4770 /* "MACS2/Signal.pyx":180
4771 * float req_min, v, prev_v
4772 * int summit_pos, prev_summit_pos
4773 * int n_summits = summits.shape[0] # <<<<<<<<<<<<<<
4774 * int n_valid_summits = 1
4775 * np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy()
4777 __pyx_v_n_summits
= (__pyx_v_summits
->dimensions
[0]);
4779 /* "MACS2/Signal.pyx":181
4780 * int summit_pos, prev_summit_pos
4781 * int n_summits = summits.shape[0]
4782 * int n_valid_summits = 1 # <<<<<<<<<<<<<<
4783 * np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy()
4784 * # Step 1: Remove peaks that do not have sufficient valleys
4786 __pyx_v_n_valid_summits
= 1;
4788 /* "MACS2/Signal.pyx":182
4789 * int n_summits = summits.shape[0]
4790 * int n_valid_summits = 1
4791 * np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy() # <<<<<<<<<<<<<<
4792 * # Step 1: Remove peaks that do not have sufficient valleys
4793 * if n_summits == 1: return summits
4795 __pyx_t_2
= __Pyx_PyObject_GetAttrStr(((PyObject
*)__pyx_v_summits
), __pyx_n_s_copy
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 182, __pyx_L1_error
)
4796 __Pyx_GOTREF(__pyx_t_2
);
4798 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_2
))) {
4799 __pyx_t_3
= PyMethod_GET_SELF(__pyx_t_2
);
4800 if (likely(__pyx_t_3
)) {
4801 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_2
);
4802 __Pyx_INCREF(__pyx_t_3
);
4803 __Pyx_INCREF(function
);
4804 __Pyx_DECREF_SET(__pyx_t_2
, function
);
4807 __pyx_t_1
= (__pyx_t_3
) ? __Pyx_PyObject_CallOneArg(__pyx_t_2
, __pyx_t_3
) : __Pyx_PyObject_CallNoArg(__pyx_t_2
);
4808 __Pyx_XDECREF(__pyx_t_3
); __pyx_t_3
= 0;
4809 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 182, __pyx_L1_error
)
4810 __Pyx_GOTREF(__pyx_t_1
);
4811 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
4812 if (!(likely(((__pyx_t_1
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_1
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 182, __pyx_L1_error
)
4813 __pyx_t_4
= ((PyArrayObject
*)__pyx_t_1
);
4815 __Pyx_BufFmt_StackElem __pyx_stack
[1];
4816 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_4
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
| PyBUF_WRITABLE
, 1, 0, __pyx_stack
) == -1)) {
4817 __pyx_v_valid_summits
= ((PyArrayObject
*)Py_None
); __Pyx_INCREF(Py_None
); __pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
.buf
= NULL
;
4818 __PYX_ERR(0, 182, __pyx_L1_error
)
4819 } else {__pyx_pybuffernd_valid_summits
.diminfo
[0].strides
= __pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_valid_summits
.diminfo
[0].shape
= __pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
.shape
[0];
4823 __pyx_v_valid_summits
= ((PyArrayObject
*)__pyx_t_1
);
4826 /* "MACS2/Signal.pyx":184
4827 * np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy()
4828 * # Step 1: Remove peaks that do not have sufficient valleys
4829 * if n_summits == 1: return summits # <<<<<<<<<<<<<<
4830 * for i in range(1, n_summits):
4831 * prev_summit_pos = valid_summits[n_valid_summits-1]
4833 __pyx_t_5
= ((__pyx_v_n_summits
== 1) != 0);
4835 __Pyx_XDECREF(__pyx_r
);
4836 __Pyx_INCREF(((PyObject
*)__pyx_v_summits
));
4837 __pyx_r
= ((PyObject
*)__pyx_v_summits
);
4841 /* "MACS2/Signal.pyx":185
4842 * # Step 1: Remove peaks that do not have sufficient valleys
4843 * if n_summits == 1: return summits
4844 * for i in range(1, n_summits): # <<<<<<<<<<<<<<
4845 * prev_summit_pos = valid_summits[n_valid_summits-1]
4846 * summit_pos = summits[i]
4848 __pyx_t_6
= __pyx_v_n_summits
;
4849 __pyx_t_7
= __pyx_t_6
;
4850 for (__pyx_t_8
= 1; __pyx_t_8
< __pyx_t_7
; __pyx_t_8
+=1) {
4851 __pyx_v_i
= __pyx_t_8
;
4853 /* "MACS2/Signal.pyx":186
4854 * if n_summits == 1: return summits
4855 * for i in range(1, n_summits):
4856 * prev_summit_pos = valid_summits[n_valid_summits-1] # <<<<<<<<<<<<<<
4857 * summit_pos = summits[i]
4858 * prev_v = signal[prev_summit_pos]
4860 __pyx_t_9
= (__pyx_v_n_valid_summits
- 1);
4862 if (__pyx_t_9
< 0) {
4863 __pyx_t_9
+= __pyx_pybuffernd_valid_summits
.diminfo
[0].shape
;
4864 if (unlikely(__pyx_t_9
< 0)) __pyx_t_10
= 0;
4865 } else if (unlikely(__pyx_t_9
>= __pyx_pybuffernd_valid_summits
.diminfo
[0].shape
)) __pyx_t_10
= 0;
4866 if (unlikely(__pyx_t_10
!= -1)) {
4867 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
4868 __PYX_ERR(0, 186, __pyx_L1_error
)
4870 __pyx_v_prev_summit_pos
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
.buf
, __pyx_t_9
, __pyx_pybuffernd_valid_summits
.diminfo
[0].strides
));
4872 /* "MACS2/Signal.pyx":187
4873 * for i in range(1, n_summits):
4874 * prev_summit_pos = valid_summits[n_valid_summits-1]
4875 * summit_pos = summits[i] # <<<<<<<<<<<<<<
4876 * prev_v = signal[prev_summit_pos]
4877 * v = signal[summit_pos]
4879 __pyx_t_11
= __pyx_v_i
;
4881 if (__pyx_t_11
< 0) {
4882 __pyx_t_11
+= __pyx_pybuffernd_summits
.diminfo
[0].shape
;
4883 if (unlikely(__pyx_t_11
< 0)) __pyx_t_10
= 0;
4884 } else if (unlikely(__pyx_t_11
>= __pyx_pybuffernd_summits
.diminfo
[0].shape
)) __pyx_t_10
= 0;
4885 if (unlikely(__pyx_t_10
!= -1)) {
4886 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
4887 __PYX_ERR(0, 187, __pyx_L1_error
)
4889 __pyx_v_summit_pos
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_summits
.rcbuffer
->pybuffer
.buf
, __pyx_t_11
, __pyx_pybuffernd_summits
.diminfo
[0].strides
));
4891 /* "MACS2/Signal.pyx":188
4892 * prev_summit_pos = valid_summits[n_valid_summits-1]
4893 * summit_pos = summits[i]
4894 * prev_v = signal[prev_summit_pos] # <<<<<<<<<<<<<<
4895 * v = signal[summit_pos]
4896 * req_min = min_valley * min(prev_v, v)
4898 __pyx_t_12
= __pyx_v_prev_summit_pos
;
4900 if (__pyx_t_12
< 0) {
4901 __pyx_t_12
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
4902 if (unlikely(__pyx_t_12
< 0)) __pyx_t_10
= 0;
4903 } else if (unlikely(__pyx_t_12
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_10
= 0;
4904 if (unlikely(__pyx_t_10
!= -1)) {
4905 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
4906 __PYX_ERR(0, 188, __pyx_L1_error
)
4908 __pyx_v_prev_v
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_12
, __pyx_pybuffernd_signal
.diminfo
[0].strides
));
4910 /* "MACS2/Signal.pyx":189
4911 * summit_pos = summits[i]
4912 * prev_v = signal[prev_summit_pos]
4913 * v = signal[summit_pos] # <<<<<<<<<<<<<<
4914 * req_min = min_valley * min(prev_v, v)
4915 * if (signal[prev_summit_pos:summit_pos] < req_min).any():
4917 __pyx_t_13
= __pyx_v_summit_pos
;
4919 if (__pyx_t_13
< 0) {
4920 __pyx_t_13
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
4921 if (unlikely(__pyx_t_13
< 0)) __pyx_t_10
= 0;
4922 } else if (unlikely(__pyx_t_13
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_10
= 0;
4923 if (unlikely(__pyx_t_10
!= -1)) {
4924 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
4925 __PYX_ERR(0, 189, __pyx_L1_error
)
4927 __pyx_v_v
= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_13
, __pyx_pybuffernd_signal
.diminfo
[0].strides
));
4929 /* "MACS2/Signal.pyx":190
4930 * prev_v = signal[prev_summit_pos]
4931 * v = signal[summit_pos]
4932 * req_min = min_valley * min(prev_v, v) # <<<<<<<<<<<<<<
4933 * if (signal[prev_summit_pos:summit_pos] < req_min).any():
4934 * valid_summits[n_valid_summits] = summit_pos
4936 __pyx_t_14
= __pyx_v_v
;
4937 __pyx_t_15
= __pyx_v_prev_v
;
4938 if (((__pyx_t_14
< __pyx_t_15
) != 0)) {
4939 __pyx_t_16
= __pyx_t_14
;
4941 __pyx_t_16
= __pyx_t_15
;
4943 __pyx_v_req_min
= (__pyx_v_min_valley
* __pyx_t_16
);
4945 /* "MACS2/Signal.pyx":191
4946 * v = signal[summit_pos]
4947 * req_min = min_valley * min(prev_v, v)
4948 * if (signal[prev_summit_pos:summit_pos] < req_min).any(): # <<<<<<<<<<<<<<
4949 * valid_summits[n_valid_summits] = summit_pos
4950 * n_valid_summits += 1
4952 __pyx_t_2
= __Pyx_PyInt_From_int(__pyx_v_prev_summit_pos
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4953 __Pyx_GOTREF(__pyx_t_2
);
4954 __pyx_t_3
= __Pyx_PyInt_From_int(__pyx_v_summit_pos
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4955 __Pyx_GOTREF(__pyx_t_3
);
4956 __pyx_t_17
= PySlice_New(__pyx_t_2
, __pyx_t_3
, Py_None
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4957 __Pyx_GOTREF(__pyx_t_17
);
4958 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
4959 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
4960 __pyx_t_3
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_17
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4961 __Pyx_GOTREF(__pyx_t_3
);
4962 __Pyx_DECREF(__pyx_t_17
); __pyx_t_17
= 0;
4963 __pyx_t_17
= PyFloat_FromDouble(__pyx_v_req_min
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4964 __Pyx_GOTREF(__pyx_t_17
);
4965 __pyx_t_2
= PyObject_RichCompare(__pyx_t_3
, __pyx_t_17
, Py_LT
); __Pyx_XGOTREF(__pyx_t_2
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4966 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
4967 __Pyx_DECREF(__pyx_t_17
); __pyx_t_17
= 0;
4968 __pyx_t_17
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_any
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4969 __Pyx_GOTREF(__pyx_t_17
);
4970 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
4972 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_17
))) {
4973 __pyx_t_2
= PyMethod_GET_SELF(__pyx_t_17
);
4974 if (likely(__pyx_t_2
)) {
4975 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_17
);
4976 __Pyx_INCREF(__pyx_t_2
);
4977 __Pyx_INCREF(function
);
4978 __Pyx_DECREF_SET(__pyx_t_17
, function
);
4981 __pyx_t_1
= (__pyx_t_2
) ? __Pyx_PyObject_CallOneArg(__pyx_t_17
, __pyx_t_2
) : __Pyx_PyObject_CallNoArg(__pyx_t_17
);
4982 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
4983 if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 191, __pyx_L1_error
)
4984 __Pyx_GOTREF(__pyx_t_1
);
4985 __Pyx_DECREF(__pyx_t_17
); __pyx_t_17
= 0;
4986 __pyx_t_5
= __Pyx_PyObject_IsTrue(__pyx_t_1
); if (unlikely(__pyx_t_5
< 0)) __PYX_ERR(0, 191, __pyx_L1_error
)
4987 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
4990 /* "MACS2/Signal.pyx":192
4991 * req_min = min_valley * min(prev_v, v)
4992 * if (signal[prev_summit_pos:summit_pos] < req_min).any():
4993 * valid_summits[n_valid_summits] = summit_pos # <<<<<<<<<<<<<<
4994 * n_valid_summits += 1
4997 __pyx_t_18
= __pyx_v_n_valid_summits
;
4999 if (__pyx_t_18
< 0) {
5000 __pyx_t_18
+= __pyx_pybuffernd_valid_summits
.diminfo
[0].shape
;
5001 if (unlikely(__pyx_t_18
< 0)) __pyx_t_10
= 0;
5002 } else if (unlikely(__pyx_t_18
>= __pyx_pybuffernd_valid_summits
.diminfo
[0].shape
)) __pyx_t_10
= 0;
5003 if (unlikely(__pyx_t_10
!= -1)) {
5004 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
5005 __PYX_ERR(0, 192, __pyx_L1_error
)
5007 *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
.buf
, __pyx_t_18
, __pyx_pybuffernd_valid_summits
.diminfo
[0].strides
) = __pyx_v_summit_pos
;
5009 /* "MACS2/Signal.pyx":193
5010 * if (signal[prev_summit_pos:summit_pos] < req_min).any():
5011 * valid_summits[n_valid_summits] = summit_pos
5012 * n_valid_summits += 1 # <<<<<<<<<<<<<<
5014 * valid_summits[n_valid_summits-1] = summit_pos
5016 __pyx_v_n_valid_summits
= (__pyx_v_n_valid_summits
+ 1);
5018 /* "MACS2/Signal.pyx":191
5019 * v = signal[summit_pos]
5020 * req_min = min_valley * min(prev_v, v)
5021 * if (signal[prev_summit_pos:summit_pos] < req_min).any(): # <<<<<<<<<<<<<<
5022 * valid_summits[n_valid_summits] = summit_pos
5023 * n_valid_summits += 1
5028 /* "MACS2/Signal.pyx":194
5029 * valid_summits[n_valid_summits] = summit_pos
5030 * n_valid_summits += 1
5031 * elif v > prev_v: # <<<<<<<<<<<<<<
5032 * valid_summits[n_valid_summits-1] = summit_pos
5033 * valid_summits.resize(n_valid_summits, refcheck=False)
5035 __pyx_t_5
= ((__pyx_v_v
> __pyx_v_prev_v
) != 0);
5038 /* "MACS2/Signal.pyx":195
5039 * n_valid_summits += 1
5041 * valid_summits[n_valid_summits-1] = summit_pos # <<<<<<<<<<<<<<
5042 * valid_summits.resize(n_valid_summits, refcheck=False)
5043 * # Step 2: Re-find peaks from subtracted signal
5045 __pyx_t_19
= (__pyx_v_n_valid_summits
- 1);
5047 if (__pyx_t_19
< 0) {
5048 __pyx_t_19
+= __pyx_pybuffernd_valid_summits
.diminfo
[0].shape
;
5049 if (unlikely(__pyx_t_19
< 0)) __pyx_t_10
= 0;
5050 } else if (unlikely(__pyx_t_19
>= __pyx_pybuffernd_valid_summits
.diminfo
[0].shape
)) __pyx_t_10
= 0;
5051 if (unlikely(__pyx_t_10
!= -1)) {
5052 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
5053 __PYX_ERR(0, 195, __pyx_L1_error
)
5055 *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t
*, __pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
.buf
, __pyx_t_19
, __pyx_pybuffernd_valid_summits
.diminfo
[0].strides
) = __pyx_v_summit_pos
;
5057 /* "MACS2/Signal.pyx":194
5058 * valid_summits[n_valid_summits] = summit_pos
5059 * n_valid_summits += 1
5060 * elif v > prev_v: # <<<<<<<<<<<<<<
5061 * valid_summits[n_valid_summits-1] = summit_pos
5062 * valid_summits.resize(n_valid_summits, refcheck=False)
5068 /* "MACS2/Signal.pyx":196
5070 * valid_summits[n_valid_summits-1] = summit_pos
5071 * valid_summits.resize(n_valid_summits, refcheck=False) # <<<<<<<<<<<<<<
5072 * # Step 2: Re-find peaks from subtracted signal
5075 __pyx_t_1
= __Pyx_PyObject_GetAttrStr(((PyObject
*)__pyx_v_valid_summits
), __pyx_n_s_resize
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 196, __pyx_L1_error
)
5076 __Pyx_GOTREF(__pyx_t_1
);
5077 __pyx_t_17
= __Pyx_PyInt_From_int(__pyx_v_n_valid_summits
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 196, __pyx_L1_error
)
5078 __Pyx_GOTREF(__pyx_t_17
);
5079 __pyx_t_2
= PyTuple_New(1); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 196, __pyx_L1_error
)
5080 __Pyx_GOTREF(__pyx_t_2
);
5081 __Pyx_GIVEREF(__pyx_t_17
);
5082 PyTuple_SET_ITEM(__pyx_t_2
, 0, __pyx_t_17
);
5084 __pyx_t_17
= __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 196, __pyx_L1_error
)
5085 __Pyx_GOTREF(__pyx_t_17
);
5086 if (PyDict_SetItem(__pyx_t_17
, __pyx_n_s_refcheck
, Py_False
) < 0) __PYX_ERR(0, 196, __pyx_L1_error
)
5087 __pyx_t_3
= __Pyx_PyObject_Call(__pyx_t_1
, __pyx_t_2
, __pyx_t_17
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 196, __pyx_L1_error
)
5088 __Pyx_GOTREF(__pyx_t_3
);
5089 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
5090 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5091 __Pyx_DECREF(__pyx_t_17
); __pyx_t_17
= 0;
5092 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
5094 /* "MACS2/Signal.pyx":199
5095 * # Step 2: Re-find peaks from subtracted signal
5097 * return valid_summits # <<<<<<<<<<<<<<
5099 * # Modified from http://www.scipy.org/Cookbook/SavitzkyGolay
5101 __Pyx_XDECREF(__pyx_r
);
5102 __Pyx_INCREF(((PyObject
*)__pyx_v_valid_summits
));
5103 __pyx_r
= ((PyObject
*)__pyx_v_valid_summits
);
5106 /* "MACS2/Signal.pyx":171
5109 * cpdef enforce_valleys(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
5110 * np.ndarray[np.int32_t, ndim=1] summits,
5111 * float min_valley = 0.8):
5114 /* function exit code */
5116 __Pyx_XDECREF(__pyx_t_1
);
5117 __Pyx_XDECREF(__pyx_t_2
);
5118 __Pyx_XDECREF(__pyx_t_3
);
5119 __Pyx_XDECREF(__pyx_t_17
);
5120 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
5121 __Pyx_PyThreadState_declare
5122 __Pyx_PyThreadState_assign
5123 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
5124 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
5125 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_summits
.rcbuffer
->pybuffer
);
5126 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
);
5127 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
5128 __Pyx_AddTraceback("MACS2.Signal.enforce_valleys", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
5132 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
5133 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_summits
.rcbuffer
->pybuffer
);
5134 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_valid_summits
.rcbuffer
->pybuffer
);
5136 __Pyx_XDECREF((PyObject
*)__pyx_v_valid_summits
);
5137 __Pyx_XGIVEREF(__pyx_r
);
5138 __Pyx_TraceReturn(__pyx_r
, 0);
5139 __Pyx_RefNannyFinishContext();
5143 /* Python wrapper */
5144 static PyObject
*__pyx_pw_5MACS2_6Signal_5enforce_valleys(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
5145 static char __pyx_doc_5MACS2_6Signal_4enforce_valleys
[] = "require a value of <= min_valley * lower summit\n between each pair of summits\n ";
5146 static PyObject
*__pyx_pw_5MACS2_6Signal_5enforce_valleys(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
) {
5147 PyArrayObject
*__pyx_v_signal
= 0;
5148 PyArrayObject
*__pyx_v_summits
= 0;
5149 float __pyx_v_min_valley
;
5150 PyObject
*__pyx_r
= 0;
5151 __Pyx_RefNannyDeclarations
5152 __Pyx_RefNannySetupContext("enforce_valleys (wrapper)", 0);
5154 static PyObject
**__pyx_pyargnames
[] = {&__pyx_n_s_signal
,&__pyx_n_s_summits
,&__pyx_n_s_min_valley
,0};
5155 PyObject
* values
[3] = {0,0,0};
5156 if (unlikely(__pyx_kwds
)) {
5158 const Py_ssize_t pos_args
= PyTuple_GET_SIZE(__pyx_args
);
5160 case 3: values
[2] = PyTuple_GET_ITEM(__pyx_args
, 2);
5162 case 2: values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
5164 case 1: values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
5167 default: goto __pyx_L5_argtuple_error
;
5169 kw_args
= PyDict_Size(__pyx_kwds
);
5172 if (likely((values
[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_signal
)) != 0)) kw_args
--;
5173 else goto __pyx_L5_argtuple_error
;
5176 if (likely((values
[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_summits
)) != 0)) kw_args
--;
5178 __Pyx_RaiseArgtupleInvalid("enforce_valleys", 0, 2, 3, 1); __PYX_ERR(0, 171, __pyx_L3_error
)
5183 PyObject
* value
= __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_min_valley
);
5184 if (value
) { values
[2] = value
; kw_args
--; }
5187 if (unlikely(kw_args
> 0)) {
5188 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds
, __pyx_pyargnames
, 0, values
, pos_args
, "enforce_valleys") < 0)) __PYX_ERR(0, 171, __pyx_L3_error
)
5191 switch (PyTuple_GET_SIZE(__pyx_args
)) {
5192 case 3: values
[2] = PyTuple_GET_ITEM(__pyx_args
, 2);
5194 case 2: values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
5195 values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
5197 default: goto __pyx_L5_argtuple_error
;
5200 __pyx_v_signal
= ((PyArrayObject
*)values
[0]);
5201 __pyx_v_summits
= ((PyArrayObject
*)values
[1]);
5203 __pyx_v_min_valley
= __pyx_PyFloat_AsFloat(values
[2]); if (unlikely((__pyx_v_min_valley
== (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L3_error
)
5205 __pyx_v_min_valley
= ((float)0.8);
5208 goto __pyx_L4_argument_unpacking_done
;
5209 __pyx_L5_argtuple_error
:;
5210 __Pyx_RaiseArgtupleInvalid("enforce_valleys", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args
)); __PYX_ERR(0, 171, __pyx_L3_error
)
5212 __Pyx_AddTraceback("MACS2.Signal.enforce_valleys", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
5213 __Pyx_RefNannyFinishContext();
5215 __pyx_L4_argument_unpacking_done
:;
5216 if (unlikely(!__Pyx_ArgTypeTest(((PyObject
*)__pyx_v_signal
), __pyx_ptype_5numpy_ndarray
, 1, "signal", 0))) __PYX_ERR(0, 171, __pyx_L1_error
)
5217 if (unlikely(!__Pyx_ArgTypeTest(((PyObject
*)__pyx_v_summits
), __pyx_ptype_5numpy_ndarray
, 1, "summits", 0))) __PYX_ERR(0, 172, __pyx_L1_error
)
5218 __pyx_r
= __pyx_pf_5MACS2_6Signal_4enforce_valleys(__pyx_self
, __pyx_v_signal
, __pyx_v_summits
, __pyx_v_min_valley
);
5220 /* function exit code */
5225 __Pyx_RefNannyFinishContext();
5229 static PyObject
*__pyx_pf_5MACS2_6Signal_4enforce_valleys(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, PyArrayObject
*__pyx_v_summits
, float __pyx_v_min_valley
) {
5230 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
5231 __Pyx_Buffer __pyx_pybuffer_signal
;
5232 __Pyx_LocalBuf_ND __pyx_pybuffernd_summits
;
5233 __Pyx_Buffer __pyx_pybuffer_summits
;
5234 PyObject
*__pyx_r
= NULL
;
5235 __Pyx_TraceDeclarations
5236 __Pyx_RefNannyDeclarations
5237 PyObject
*__pyx_t_1
= NULL
;
5238 struct __pyx_opt_args_5MACS2_6Signal_enforce_valleys __pyx_t_2
;
5239 __Pyx_RefNannySetupContext("enforce_valleys", 0);
5240 __Pyx_TraceCall("enforce_valleys (wrapper)", __pyx_f
[0], 171, 0, __PYX_ERR(0, 171, __pyx_L1_error
));
5241 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
5242 __pyx_pybuffer_signal
.refcount
= 0;
5243 __pyx_pybuffernd_signal
.data
= NULL
;
5244 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
5245 __pyx_pybuffer_summits
.pybuffer
.buf
= NULL
;
5246 __pyx_pybuffer_summits
.refcount
= 0;
5247 __pyx_pybuffernd_summits
.data
= NULL
;
5248 __pyx_pybuffernd_summits
.rcbuffer
= &__pyx_pybuffer_summits
;
5250 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5251 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 171, __pyx_L1_error
)
5253 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
5255 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5256 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_summits
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_summits
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 171, __pyx_L1_error
)
5258 __pyx_pybuffernd_summits
.diminfo
[0].strides
= __pyx_pybuffernd_summits
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_summits
.diminfo
[0].shape
= __pyx_pybuffernd_summits
.rcbuffer
->pybuffer
.shape
[0];
5259 __Pyx_XDECREF(__pyx_r
);
5260 __pyx_t_2
.__pyx_n
= 1;
5261 __pyx_t_2
.min_valley
= __pyx_v_min_valley
;
5262 __pyx_t_1
= __pyx_f_5MACS2_6Signal_enforce_valleys(__pyx_v_signal
, __pyx_v_summits
, 0, &__pyx_t_2
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 171, __pyx_L1_error
)
5263 __Pyx_GOTREF(__pyx_t_1
);
5264 __pyx_r
= __pyx_t_1
;
5268 /* function exit code */
5270 __Pyx_XDECREF(__pyx_t_1
);
5271 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
5272 __Pyx_PyThreadState_declare
5273 __Pyx_PyThreadState_assign
5274 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
5275 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
5276 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_summits
.rcbuffer
->pybuffer
);
5277 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
5278 __Pyx_AddTraceback("MACS2.Signal.enforce_valleys", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
5282 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
5283 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_summits
.rcbuffer
->pybuffer
);
5285 __Pyx_XGIVEREF(__pyx_r
);
5286 __Pyx_TraceReturn(__pyx_r
, 0);
5287 __Pyx_RefNannyFinishContext();
5291 /* "MACS2/Signal.pyx":205
5292 * # needs sane input paramters, window size > 4
5293 * # switched to double precision for internal accuracy
5294 * cpdef np.ndarray[np.float64_t, ndim=1] savitzky_golay_order2_deriv1(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
5296 * """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
5299 static PyObject
*__pyx_pw_5MACS2_6Signal_7savitzky_golay_order2_deriv1(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
5300 static PyArrayObject
*__pyx_f_5MACS2_6Signal_savitzky_golay_order2_deriv1(PyArrayObject
*__pyx_v_signal
, int __pyx_v_window_size
, CYTHON_UNUSED
int __pyx_skip_dispatch
) {
5301 int __pyx_v_half_window
;
5302 PyArrayObject
*__pyx_v_b
= 0;
5303 PyArrayObject
*__pyx_v_firstvals
= 0;
5304 PyArrayObject
*__pyx_v_lastvals
= 0;
5305 PyArrayObject
*__pyx_v_m
= 0;
5306 PyArrayObject
*__pyx_v_ret
= 0;
5307 int __pyx_7genexpr__pyx_v_k
;
5308 __Pyx_LocalBuf_ND __pyx_pybuffernd_b
;
5309 __Pyx_Buffer __pyx_pybuffer_b
;
5310 __Pyx_LocalBuf_ND __pyx_pybuffernd_firstvals
;
5311 __Pyx_Buffer __pyx_pybuffer_firstvals
;
5312 __Pyx_LocalBuf_ND __pyx_pybuffernd_lastvals
;
5313 __Pyx_Buffer __pyx_pybuffer_lastvals
;
5314 __Pyx_LocalBuf_ND __pyx_pybuffernd_m
;
5315 __Pyx_Buffer __pyx_pybuffer_m
;
5316 __Pyx_LocalBuf_ND __pyx_pybuffernd_ret
;
5317 __Pyx_Buffer __pyx_pybuffer_ret
;
5318 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
5319 __Pyx_Buffer __pyx_pybuffer_signal
;
5320 PyArrayObject
*__pyx_r
= NULL
;
5321 __Pyx_TraceDeclarations
5322 __Pyx_RefNannyDeclarations
5324 PyObject
*__pyx_t_2
= NULL
;
5325 PyObject
*__pyx_t_3
= NULL
;
5329 PyObject
*__pyx_t_7
= NULL
;
5330 PyObject
*__pyx_t_8
= NULL
;
5331 PyObject
*__pyx_t_9
= NULL
;
5332 PyArrayObject
*__pyx_t_10
= NULL
;
5333 PyObject
*__pyx_t_11
= NULL
;
5334 PyObject
*__pyx_t_12
= NULL
;
5335 PyObject
*__pyx_t_13
= NULL
;
5336 PyArrayObject
*__pyx_t_14
= NULL
;
5337 Py_ssize_t __pyx_t_15
;
5338 Py_ssize_t __pyx_t_16
;
5339 PyObject
*__pyx_t_17
= NULL
;
5340 PyArrayObject
*__pyx_t_18
= NULL
;
5341 Py_ssize_t __pyx_t_19
;
5342 Py_ssize_t __pyx_t_20
;
5343 PyArrayObject
*__pyx_t_21
= NULL
;
5344 __Pyx_RefNannySetupContext("savitzky_golay_order2_deriv1", 0);
5345 __Pyx_TraceCall("savitzky_golay_order2_deriv1", __pyx_f
[0], 205, 0, __PYX_ERR(0, 205, __pyx_L1_error
));
5346 __Pyx_INCREF((PyObject
*)__pyx_v_signal
);
5347 __pyx_pybuffer_b
.pybuffer
.buf
= NULL
;
5348 __pyx_pybuffer_b
.refcount
= 0;
5349 __pyx_pybuffernd_b
.data
= NULL
;
5350 __pyx_pybuffernd_b
.rcbuffer
= &__pyx_pybuffer_b
;
5351 __pyx_pybuffer_firstvals
.pybuffer
.buf
= NULL
;
5352 __pyx_pybuffer_firstvals
.refcount
= 0;
5353 __pyx_pybuffernd_firstvals
.data
= NULL
;
5354 __pyx_pybuffernd_firstvals
.rcbuffer
= &__pyx_pybuffer_firstvals
;
5355 __pyx_pybuffer_lastvals
.pybuffer
.buf
= NULL
;
5356 __pyx_pybuffer_lastvals
.refcount
= 0;
5357 __pyx_pybuffernd_lastvals
.data
= NULL
;
5358 __pyx_pybuffernd_lastvals
.rcbuffer
= &__pyx_pybuffer_lastvals
;
5359 __pyx_pybuffer_m
.pybuffer
.buf
= NULL
;
5360 __pyx_pybuffer_m
.refcount
= 0;
5361 __pyx_pybuffernd_m
.data
= NULL
;
5362 __pyx_pybuffernd_m
.rcbuffer
= &__pyx_pybuffer_m
;
5363 __pyx_pybuffer_ret
.pybuffer
.buf
= NULL
;
5364 __pyx_pybuffer_ret
.refcount
= 0;
5365 __pyx_pybuffernd_ret
.data
= NULL
;
5366 __pyx_pybuffernd_ret
.rcbuffer
= &__pyx_pybuffer_ret
;
5367 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
5368 __pyx_pybuffer_signal
.refcount
= 0;
5369 __pyx_pybuffernd_signal
.data
= NULL
;
5370 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
5372 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5373 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 205, __pyx_L1_error
)
5375 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
5377 /* "MACS2/Signal.pyx":249
5378 * np.ndarray[np.float64_t, ndim=1] m, ret
5380 * if window_size % 2 != 1: window_size += 1 # <<<<<<<<<<<<<<
5381 * half_window = (window_size - 1) // 2
5382 * # precompute coefficients
5384 __pyx_t_1
= ((__Pyx_mod_long(__pyx_v_window_size
, 2) != 1) != 0);
5386 __pyx_v_window_size
= (__pyx_v_window_size
+ 1);
5389 /* "MACS2/Signal.pyx":250
5391 * if window_size % 2 != 1: window_size += 1
5392 * half_window = (window_size - 1) // 2 # <<<<<<<<<<<<<<
5393 * # precompute coefficients
5394 * b = np.array([[1, k, k**2] for k in range(-half_window, half_window+1)],
5396 __pyx_v_half_window
= __Pyx_div_long((__pyx_v_window_size
- 1), 2);
5398 /* "MACS2/Signal.pyx":252
5399 * half_window = (window_size - 1) // 2
5400 * # precompute coefficients
5401 * b = np.array([[1, k, k**2] for k in range(-half_window, half_window+1)], # <<<<<<<<<<<<<<
5403 * m = np.linalg.pinv(b)[1]
5405 __Pyx_GetModuleGlobalName(__pyx_t_2
, __pyx_n_s_np
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5406 __Pyx_GOTREF(__pyx_t_2
);
5407 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_array
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5408 __Pyx_GOTREF(__pyx_t_3
);
5409 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5410 { /* enter inner scope */
5411 __pyx_t_2
= PyList_New(0); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5412 __Pyx_GOTREF(__pyx_t_2
);
5413 __pyx_t_4
= (__pyx_v_half_window
+ 1);
5414 __pyx_t_5
= __pyx_t_4
;
5415 for (__pyx_t_6
= (-__pyx_v_half_window
); __pyx_t_6
< __pyx_t_5
; __pyx_t_6
+=1) {
5416 __pyx_7genexpr__pyx_v_k
= __pyx_t_6
;
5417 __pyx_t_7
= __Pyx_PyInt_From_int(__pyx_7genexpr__pyx_v_k
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5418 __Pyx_GOTREF(__pyx_t_7
);
5419 __pyx_t_8
= __Pyx_PyInt_From_long(__Pyx_pow_long(((long)__pyx_7genexpr__pyx_v_k
), 2)); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5420 __Pyx_GOTREF(__pyx_t_8
);
5421 __pyx_t_9
= PyList_New(3); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5422 __Pyx_GOTREF(__pyx_t_9
);
5423 __Pyx_INCREF(__pyx_int_1
);
5424 __Pyx_GIVEREF(__pyx_int_1
);
5425 PyList_SET_ITEM(__pyx_t_9
, 0, __pyx_int_1
);
5426 __Pyx_GIVEREF(__pyx_t_7
);
5427 PyList_SET_ITEM(__pyx_t_9
, 1, __pyx_t_7
);
5428 __Pyx_GIVEREF(__pyx_t_8
);
5429 PyList_SET_ITEM(__pyx_t_9
, 2, __pyx_t_8
);
5432 if (unlikely(__Pyx_ListComp_Append(__pyx_t_2
, (PyObject
*)__pyx_t_9
))) __PYX_ERR(0, 252, __pyx_L1_error
)
5433 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5435 } /* exit inner scope */
5436 __pyx_t_9
= PyTuple_New(1); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5437 __Pyx_GOTREF(__pyx_t_9
);
5438 __Pyx_GIVEREF(__pyx_t_2
);
5439 PyTuple_SET_ITEM(__pyx_t_9
, 0, __pyx_t_2
);
5442 /* "MACS2/Signal.pyx":253
5443 * # precompute coefficients
5444 * b = np.array([[1, k, k**2] for k in range(-half_window, half_window+1)],
5445 * dtype='int64') # <<<<<<<<<<<<<<
5446 * m = np.linalg.pinv(b)[1]
5447 * # pad the signal at the extremes with
5449 __pyx_t_2
= __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 253, __pyx_L1_error
)
5450 __Pyx_GOTREF(__pyx_t_2
);
5451 if (PyDict_SetItem(__pyx_t_2
, __pyx_n_s_dtype
, __pyx_n_u_int64
) < 0) __PYX_ERR(0, 253, __pyx_L1_error
)
5453 /* "MACS2/Signal.pyx":252
5454 * half_window = (window_size - 1) // 2
5455 * # precompute coefficients
5456 * b = np.array([[1, k, k**2] for k in range(-half_window, half_window+1)], # <<<<<<<<<<<<<<
5458 * m = np.linalg.pinv(b)[1]
5460 __pyx_t_8
= __Pyx_PyObject_Call(__pyx_t_3
, __pyx_t_9
, __pyx_t_2
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 252, __pyx_L1_error
)
5461 __Pyx_GOTREF(__pyx_t_8
);
5462 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
5463 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5464 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5465 if (!(likely(((__pyx_t_8
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_8
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 252, __pyx_L1_error
)
5466 __pyx_t_10
= ((PyArrayObject
*)__pyx_t_8
);
5468 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5469 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
);
5470 __pyx_t_6
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_10
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 2, 0, __pyx_stack
);
5471 if (unlikely(__pyx_t_6
< 0)) {
5472 PyErr_Fetch(&__pyx_t_11
, &__pyx_t_12
, &__pyx_t_13
);
5473 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_b
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 2, 0, __pyx_stack
) == -1)) {
5474 Py_XDECREF(__pyx_t_11
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_13
);
5475 __Pyx_RaiseBufferFallbackError();
5477 PyErr_Restore(__pyx_t_11
, __pyx_t_12
, __pyx_t_13
);
5479 __pyx_t_11
= __pyx_t_12
= __pyx_t_13
= 0;
5481 __pyx_pybuffernd_b
.diminfo
[0].strides
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_b
.diminfo
[0].shape
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.shape
[0]; __pyx_pybuffernd_b
.diminfo
[1].strides
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.strides
[1]; __pyx_pybuffernd_b
.diminfo
[1].shape
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.shape
[1];
5482 if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(0, 252, __pyx_L1_error
)
5485 __pyx_v_b
= ((PyArrayObject
*)__pyx_t_8
);
5488 /* "MACS2/Signal.pyx":254
5489 * b = np.array([[1, k, k**2] for k in range(-half_window, half_window+1)],
5491 * m = np.linalg.pinv(b)[1] # <<<<<<<<<<<<<<
5492 * # pad the signal at the extremes with
5493 * # values taken from the signal itself
5495 __Pyx_GetModuleGlobalName(__pyx_t_2
, __pyx_n_s_np
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 254, __pyx_L1_error
)
5496 __Pyx_GOTREF(__pyx_t_2
);
5497 __pyx_t_9
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_linalg
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 254, __pyx_L1_error
)
5498 __Pyx_GOTREF(__pyx_t_9
);
5499 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5500 __pyx_t_2
= __Pyx_PyObject_GetAttrStr(__pyx_t_9
, __pyx_n_s_pinv
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 254, __pyx_L1_error
)
5501 __Pyx_GOTREF(__pyx_t_2
);
5502 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5504 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_2
))) {
5505 __pyx_t_9
= PyMethod_GET_SELF(__pyx_t_2
);
5506 if (likely(__pyx_t_9
)) {
5507 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_2
);
5508 __Pyx_INCREF(__pyx_t_9
);
5509 __Pyx_INCREF(function
);
5510 __Pyx_DECREF_SET(__pyx_t_2
, function
);
5513 __pyx_t_8
= (__pyx_t_9
) ? __Pyx_PyObject_Call2Args(__pyx_t_2
, __pyx_t_9
, ((PyObject
*)__pyx_v_b
)) : __Pyx_PyObject_CallOneArg(__pyx_t_2
, ((PyObject
*)__pyx_v_b
));
5514 __Pyx_XDECREF(__pyx_t_9
); __pyx_t_9
= 0;
5515 if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 254, __pyx_L1_error
)
5516 __Pyx_GOTREF(__pyx_t_8
);
5517 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5518 __pyx_t_2
= __Pyx_GetItemInt(__pyx_t_8
, 1, long, 1, __Pyx_PyInt_From_long
, 0, 0, 1); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 254, __pyx_L1_error
)
5519 __Pyx_GOTREF(__pyx_t_2
);
5520 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
5521 if (!(likely(((__pyx_t_2
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_2
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 254, __pyx_L1_error
)
5522 __pyx_t_14
= ((PyArrayObject
*)__pyx_t_2
);
5524 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5525 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
5526 __pyx_t_6
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_14
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
5527 if (unlikely(__pyx_t_6
< 0)) {
5528 PyErr_Fetch(&__pyx_t_13
, &__pyx_t_12
, &__pyx_t_11
);
5529 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_m
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
5530 Py_XDECREF(__pyx_t_13
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_11
);
5531 __Pyx_RaiseBufferFallbackError();
5533 PyErr_Restore(__pyx_t_13
, __pyx_t_12
, __pyx_t_11
);
5535 __pyx_t_13
= __pyx_t_12
= __pyx_t_11
= 0;
5537 __pyx_pybuffernd_m
.diminfo
[0].strides
= __pyx_pybuffernd_m
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_m
.diminfo
[0].shape
= __pyx_pybuffernd_m
.rcbuffer
->pybuffer
.shape
[0];
5538 if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(0, 254, __pyx_L1_error
)
5541 __pyx_v_m
= ((PyArrayObject
*)__pyx_t_2
);
5544 /* "MACS2/Signal.pyx":257
5545 * # pad the signal at the extremes with
5546 * # values taken from the signal itself
5547 * firstvals = signal[0] - np.abs(signal[1:half_window+1][::-1] - signal[0]) # <<<<<<<<<<<<<<
5548 * lastvals = signal[-1] + np.abs(signal[-half_window-1:-1][::-1] - signal[-1])
5549 * signal = np.concatenate((firstvals, signal, lastvals))
5553 if (__pyx_t_15
< 0) {
5554 __pyx_t_15
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
5555 if (unlikely(__pyx_t_15
< 0)) __pyx_t_6
= 0;
5556 } else if (unlikely(__pyx_t_15
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_6
= 0;
5557 if (unlikely(__pyx_t_6
!= -1)) {
5558 __Pyx_RaiseBufferIndexError(__pyx_t_6
);
5559 __PYX_ERR(0, 257, __pyx_L1_error
)
5561 __pyx_t_2
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_15
, __pyx_pybuffernd_signal
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5562 __Pyx_GOTREF(__pyx_t_2
);
5563 __Pyx_GetModuleGlobalName(__pyx_t_9
, __pyx_n_s_np
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5564 __Pyx_GOTREF(__pyx_t_9
);
5565 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_9
, __pyx_n_s_abs
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5566 __Pyx_GOTREF(__pyx_t_3
);
5567 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5568 __pyx_t_9
= __Pyx_PyInt_From_long((__pyx_v_half_window
+ 1)); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5569 __Pyx_GOTREF(__pyx_t_9
);
5570 __pyx_t_7
= PySlice_New(__pyx_int_1
, __pyx_t_9
, Py_None
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5571 __Pyx_GOTREF(__pyx_t_7
);
5572 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5573 __pyx_t_9
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_7
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5574 __Pyx_GOTREF(__pyx_t_9
);
5575 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
5576 __pyx_t_7
= __Pyx_PyObject_GetItem(__pyx_t_9
, __pyx_slice__2
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5577 __Pyx_GOTREF(__pyx_t_7
);
5578 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5581 if (__pyx_t_16
< 0) {
5582 __pyx_t_16
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
5583 if (unlikely(__pyx_t_16
< 0)) __pyx_t_6
= 0;
5584 } else if (unlikely(__pyx_t_16
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_6
= 0;
5585 if (unlikely(__pyx_t_6
!= -1)) {
5586 __Pyx_RaiseBufferIndexError(__pyx_t_6
);
5587 __PYX_ERR(0, 257, __pyx_L1_error
)
5589 __pyx_t_9
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_16
, __pyx_pybuffernd_signal
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5590 __Pyx_GOTREF(__pyx_t_9
);
5591 __pyx_t_17
= PyNumber_Subtract(__pyx_t_7
, __pyx_t_9
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5592 __Pyx_GOTREF(__pyx_t_17
);
5593 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
5594 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5596 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_3
))) {
5597 __pyx_t_9
= PyMethod_GET_SELF(__pyx_t_3
);
5598 if (likely(__pyx_t_9
)) {
5599 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_3
);
5600 __Pyx_INCREF(__pyx_t_9
);
5601 __Pyx_INCREF(function
);
5602 __Pyx_DECREF_SET(__pyx_t_3
, function
);
5605 __pyx_t_8
= (__pyx_t_9
) ? __Pyx_PyObject_Call2Args(__pyx_t_3
, __pyx_t_9
, __pyx_t_17
) : __Pyx_PyObject_CallOneArg(__pyx_t_3
, __pyx_t_17
);
5606 __Pyx_XDECREF(__pyx_t_9
); __pyx_t_9
= 0;
5607 __Pyx_DECREF(__pyx_t_17
); __pyx_t_17
= 0;
5608 if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5609 __Pyx_GOTREF(__pyx_t_8
);
5610 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
5611 __pyx_t_3
= PyNumber_Subtract(__pyx_t_2
, __pyx_t_8
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 257, __pyx_L1_error
)
5612 __Pyx_GOTREF(__pyx_t_3
);
5613 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5614 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
5615 if (!(likely(((__pyx_t_3
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_3
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 257, __pyx_L1_error
)
5616 __pyx_t_18
= ((PyArrayObject
*)__pyx_t_3
);
5618 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5619 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
);
5620 __pyx_t_6
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_18
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
5621 if (unlikely(__pyx_t_6
< 0)) {
5622 PyErr_Fetch(&__pyx_t_11
, &__pyx_t_12
, &__pyx_t_13
);
5623 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_firstvals
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
5624 Py_XDECREF(__pyx_t_11
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_13
);
5625 __Pyx_RaiseBufferFallbackError();
5627 PyErr_Restore(__pyx_t_11
, __pyx_t_12
, __pyx_t_13
);
5629 __pyx_t_11
= __pyx_t_12
= __pyx_t_13
= 0;
5631 __pyx_pybuffernd_firstvals
.diminfo
[0].strides
= __pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_firstvals
.diminfo
[0].shape
= __pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
.shape
[0];
5632 if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(0, 257, __pyx_L1_error
)
5635 __pyx_v_firstvals
= ((PyArrayObject
*)__pyx_t_3
);
5638 /* "MACS2/Signal.pyx":258
5639 * # values taken from the signal itself
5640 * firstvals = signal[0] - np.abs(signal[1:half_window+1][::-1] - signal[0])
5641 * lastvals = signal[-1] + np.abs(signal[-half_window-1:-1][::-1] - signal[-1]) # <<<<<<<<<<<<<<
5642 * signal = np.concatenate((firstvals, signal, lastvals))
5647 if (__pyx_t_19
< 0) {
5648 __pyx_t_19
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
5649 if (unlikely(__pyx_t_19
< 0)) __pyx_t_6
= 0;
5650 } else if (unlikely(__pyx_t_19
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_6
= 0;
5651 if (unlikely(__pyx_t_6
!= -1)) {
5652 __Pyx_RaiseBufferIndexError(__pyx_t_6
);
5653 __PYX_ERR(0, 258, __pyx_L1_error
)
5655 __pyx_t_3
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_19
, __pyx_pybuffernd_signal
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5656 __Pyx_GOTREF(__pyx_t_3
);
5657 __Pyx_GetModuleGlobalName(__pyx_t_2
, __pyx_n_s_np
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5658 __Pyx_GOTREF(__pyx_t_2
);
5659 __pyx_t_17
= __Pyx_PyObject_GetAttrStr(__pyx_t_2
, __pyx_n_s_abs
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5660 __Pyx_GOTREF(__pyx_t_17
);
5661 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5662 __pyx_t_2
= __Pyx_PyInt_From_long(((-__pyx_v_half_window
) - 1)); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5663 __Pyx_GOTREF(__pyx_t_2
);
5664 __pyx_t_9
= PySlice_New(__pyx_t_2
, __pyx_int_neg_1
, Py_None
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5665 __Pyx_GOTREF(__pyx_t_9
);
5666 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5667 __pyx_t_2
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_signal
), __pyx_t_9
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5668 __Pyx_GOTREF(__pyx_t_2
);
5669 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5670 __pyx_t_9
= __Pyx_PyObject_GetItem(__pyx_t_2
, __pyx_slice__2
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5671 __Pyx_GOTREF(__pyx_t_9
);
5672 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5675 if (__pyx_t_20
< 0) {
5676 __pyx_t_20
+= __pyx_pybuffernd_signal
.diminfo
[0].shape
;
5677 if (unlikely(__pyx_t_20
< 0)) __pyx_t_6
= 0;
5678 } else if (unlikely(__pyx_t_20
>= __pyx_pybuffernd_signal
.diminfo
[0].shape
)) __pyx_t_6
= 0;
5679 if (unlikely(__pyx_t_6
!= -1)) {
5680 __Pyx_RaiseBufferIndexError(__pyx_t_6
);
5681 __PYX_ERR(0, 258, __pyx_L1_error
)
5683 __pyx_t_2
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.buf
, __pyx_t_20
, __pyx_pybuffernd_signal
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5684 __Pyx_GOTREF(__pyx_t_2
);
5685 __pyx_t_7
= PyNumber_Subtract(__pyx_t_9
, __pyx_t_2
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5686 __Pyx_GOTREF(__pyx_t_7
);
5687 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
5688 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
5690 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_17
))) {
5691 __pyx_t_2
= PyMethod_GET_SELF(__pyx_t_17
);
5692 if (likely(__pyx_t_2
)) {
5693 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_17
);
5694 __Pyx_INCREF(__pyx_t_2
);
5695 __Pyx_INCREF(function
);
5696 __Pyx_DECREF_SET(__pyx_t_17
, function
);
5699 __pyx_t_8
= (__pyx_t_2
) ? __Pyx_PyObject_Call2Args(__pyx_t_17
, __pyx_t_2
, __pyx_t_7
) : __Pyx_PyObject_CallOneArg(__pyx_t_17
, __pyx_t_7
);
5700 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
5701 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
5702 if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5703 __Pyx_GOTREF(__pyx_t_8
);
5704 __Pyx_DECREF(__pyx_t_17
); __pyx_t_17
= 0;
5705 __pyx_t_17
= PyNumber_Add(__pyx_t_3
, __pyx_t_8
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 258, __pyx_L1_error
)
5706 __Pyx_GOTREF(__pyx_t_17
);
5707 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
5708 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
5709 if (!(likely(((__pyx_t_17
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_17
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 258, __pyx_L1_error
)
5710 __pyx_t_18
= ((PyArrayObject
*)__pyx_t_17
);
5712 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5713 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
);
5714 __pyx_t_6
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_18
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
5715 if (unlikely(__pyx_t_6
< 0)) {
5716 PyErr_Fetch(&__pyx_t_13
, &__pyx_t_12
, &__pyx_t_11
);
5717 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_lastvals
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
5718 Py_XDECREF(__pyx_t_13
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_11
);
5719 __Pyx_RaiseBufferFallbackError();
5721 PyErr_Restore(__pyx_t_13
, __pyx_t_12
, __pyx_t_11
);
5723 __pyx_t_13
= __pyx_t_12
= __pyx_t_11
= 0;
5725 __pyx_pybuffernd_lastvals
.diminfo
[0].strides
= __pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_lastvals
.diminfo
[0].shape
= __pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
.shape
[0];
5726 if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(0, 258, __pyx_L1_error
)
5729 __pyx_v_lastvals
= ((PyArrayObject
*)__pyx_t_17
);
5732 /* "MACS2/Signal.pyx":259
5733 * firstvals = signal[0] - np.abs(signal[1:half_window+1][::-1] - signal[0])
5734 * lastvals = signal[-1] + np.abs(signal[-half_window-1:-1][::-1] - signal[-1])
5735 * signal = np.concatenate((firstvals, signal, lastvals)) # <<<<<<<<<<<<<<
5737 * ret = np.convolve( m[::-1], signal.astype("float64"), mode='valid') #.astype("float32").round(8) # round to 8 decimals to avoid signing issue
5739 __Pyx_GetModuleGlobalName(__pyx_t_8
, __pyx_n_s_np
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 259, __pyx_L1_error
)
5740 __Pyx_GOTREF(__pyx_t_8
);
5741 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_8
, __pyx_n_s_concatenate
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 259, __pyx_L1_error
)
5742 __Pyx_GOTREF(__pyx_t_3
);
5743 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
5744 __pyx_t_8
= PyTuple_New(3); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 259, __pyx_L1_error
)
5745 __Pyx_GOTREF(__pyx_t_8
);
5746 __Pyx_INCREF(((PyObject
*)__pyx_v_firstvals
));
5747 __Pyx_GIVEREF(((PyObject
*)__pyx_v_firstvals
));
5748 PyTuple_SET_ITEM(__pyx_t_8
, 0, ((PyObject
*)__pyx_v_firstvals
));
5749 __Pyx_INCREF(((PyObject
*)__pyx_v_signal
));
5750 __Pyx_GIVEREF(((PyObject
*)__pyx_v_signal
));
5751 PyTuple_SET_ITEM(__pyx_t_8
, 1, ((PyObject
*)__pyx_v_signal
));
5752 __Pyx_INCREF(((PyObject
*)__pyx_v_lastvals
));
5753 __Pyx_GIVEREF(((PyObject
*)__pyx_v_lastvals
));
5754 PyTuple_SET_ITEM(__pyx_t_8
, 2, ((PyObject
*)__pyx_v_lastvals
));
5756 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_3
))) {
5757 __pyx_t_7
= PyMethod_GET_SELF(__pyx_t_3
);
5758 if (likely(__pyx_t_7
)) {
5759 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_3
);
5760 __Pyx_INCREF(__pyx_t_7
);
5761 __Pyx_INCREF(function
);
5762 __Pyx_DECREF_SET(__pyx_t_3
, function
);
5765 __pyx_t_17
= (__pyx_t_7
) ? __Pyx_PyObject_Call2Args(__pyx_t_3
, __pyx_t_7
, __pyx_t_8
) : __Pyx_PyObject_CallOneArg(__pyx_t_3
, __pyx_t_8
);
5766 __Pyx_XDECREF(__pyx_t_7
); __pyx_t_7
= 0;
5767 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
5768 if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 259, __pyx_L1_error
)
5769 __Pyx_GOTREF(__pyx_t_17
);
5770 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
5771 if (!(likely(((__pyx_t_17
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_17
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 259, __pyx_L1_error
)
5772 __pyx_t_21
= ((PyArrayObject
*)__pyx_t_17
);
5774 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5775 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
5776 __pyx_t_6
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_21
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
5777 if (unlikely(__pyx_t_6
< 0)) {
5778 PyErr_Fetch(&__pyx_t_11
, &__pyx_t_12
, &__pyx_t_13
);
5779 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
5780 Py_XDECREF(__pyx_t_11
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_13
);
5781 __Pyx_RaiseBufferFallbackError();
5783 PyErr_Restore(__pyx_t_11
, __pyx_t_12
, __pyx_t_13
);
5785 __pyx_t_11
= __pyx_t_12
= __pyx_t_13
= 0;
5787 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
5788 if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(0, 259, __pyx_L1_error
)
5791 __Pyx_DECREF_SET(__pyx_v_signal
, ((PyArrayObject
*)__pyx_t_17
));
5794 /* "MACS2/Signal.pyx":261
5795 * signal = np.concatenate((firstvals, signal, lastvals))
5797 * ret = np.convolve( m[::-1], signal.astype("float64"), mode='valid') #.astype("float32").round(8) # round to 8 decimals to avoid signing issue # <<<<<<<<<<<<<<
5798 * #print (ret[160:165])
5801 __Pyx_GetModuleGlobalName(__pyx_t_17
, __pyx_n_s_np
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5802 __Pyx_GOTREF(__pyx_t_17
);
5803 __pyx_t_3
= __Pyx_PyObject_GetAttrStr(__pyx_t_17
, __pyx_n_s_convolve
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5804 __Pyx_GOTREF(__pyx_t_3
);
5805 __Pyx_DECREF(__pyx_t_17
); __pyx_t_17
= 0;
5806 __pyx_t_17
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_m
), __pyx_slice__2
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5807 __Pyx_GOTREF(__pyx_t_17
);
5808 __pyx_t_7
= __Pyx_PyObject_GetAttrStr(((PyObject
*)__pyx_v_signal
), __pyx_n_s_astype
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5809 __Pyx_GOTREF(__pyx_t_7
);
5811 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_7
))) {
5812 __pyx_t_2
= PyMethod_GET_SELF(__pyx_t_7
);
5813 if (likely(__pyx_t_2
)) {
5814 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_7
);
5815 __Pyx_INCREF(__pyx_t_2
);
5816 __Pyx_INCREF(function
);
5817 __Pyx_DECREF_SET(__pyx_t_7
, function
);
5820 __pyx_t_8
= (__pyx_t_2
) ? __Pyx_PyObject_Call2Args(__pyx_t_7
, __pyx_t_2
, __pyx_n_u_float64
) : __Pyx_PyObject_CallOneArg(__pyx_t_7
, __pyx_n_u_float64
);
5821 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
5822 if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5823 __Pyx_GOTREF(__pyx_t_8
);
5824 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
5825 __pyx_t_7
= PyTuple_New(2); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5826 __Pyx_GOTREF(__pyx_t_7
);
5827 __Pyx_GIVEREF(__pyx_t_17
);
5828 PyTuple_SET_ITEM(__pyx_t_7
, 0, __pyx_t_17
);
5829 __Pyx_GIVEREF(__pyx_t_8
);
5830 PyTuple_SET_ITEM(__pyx_t_7
, 1, __pyx_t_8
);
5833 __pyx_t_8
= __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5834 __Pyx_GOTREF(__pyx_t_8
);
5835 if (PyDict_SetItem(__pyx_t_8
, __pyx_n_s_mode
, __pyx_n_u_valid
) < 0) __PYX_ERR(0, 261, __pyx_L1_error
)
5836 __pyx_t_17
= __Pyx_PyObject_Call(__pyx_t_3
, __pyx_t_7
, __pyx_t_8
); if (unlikely(!__pyx_t_17
)) __PYX_ERR(0, 261, __pyx_L1_error
)
5837 __Pyx_GOTREF(__pyx_t_17
);
5838 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
5839 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
5840 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
5841 if (!(likely(((__pyx_t_17
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_17
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 261, __pyx_L1_error
)
5842 __pyx_t_14
= ((PyArrayObject
*)__pyx_t_17
);
5844 __Pyx_BufFmt_StackElem __pyx_stack
[1];
5845 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
5846 __pyx_t_6
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_14
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
5847 if (unlikely(__pyx_t_6
< 0)) {
5848 PyErr_Fetch(&__pyx_t_13
, &__pyx_t_12
, &__pyx_t_11
);
5849 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_ret
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
5850 Py_XDECREF(__pyx_t_13
); Py_XDECREF(__pyx_t_12
); Py_XDECREF(__pyx_t_11
);
5851 __Pyx_RaiseBufferFallbackError();
5853 PyErr_Restore(__pyx_t_13
, __pyx_t_12
, __pyx_t_11
);
5855 __pyx_t_13
= __pyx_t_12
= __pyx_t_11
= 0;
5857 __pyx_pybuffernd_ret
.diminfo
[0].strides
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_ret
.diminfo
[0].shape
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.shape
[0];
5858 if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(0, 261, __pyx_L1_error
)
5861 __pyx_v_ret
= ((PyArrayObject
*)__pyx_t_17
);
5864 /* "MACS2/Signal.pyx":263
5865 * ret = np.convolve( m[::-1], signal.astype("float64"), mode='valid') #.astype("float32").round(8) # round to 8 decimals to avoid signing issue
5866 * #print (ret[160:165])
5867 * return ret # <<<<<<<<<<<<<<
5871 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
5872 __Pyx_INCREF(((PyObject
*)__pyx_v_ret
));
5873 __pyx_r
= ((PyArrayObject
*)__pyx_v_ret
);
5876 /* "MACS2/Signal.pyx":205
5877 * # needs sane input paramters, window size > 4
5878 * # switched to double precision for internal accuracy
5879 * cpdef np.ndarray[np.float64_t, ndim=1] savitzky_golay_order2_deriv1(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
5881 * """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
5884 /* function exit code */
5886 __Pyx_XDECREF(__pyx_t_2
);
5887 __Pyx_XDECREF(__pyx_t_3
);
5888 __Pyx_XDECREF(__pyx_t_7
);
5889 __Pyx_XDECREF(__pyx_t_8
);
5890 __Pyx_XDECREF(__pyx_t_9
);
5891 __Pyx_XDECREF(__pyx_t_17
);
5892 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
5893 __Pyx_PyThreadState_declare
5894 __Pyx_PyThreadState_assign
5895 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
5896 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
);
5897 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
);
5898 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
);
5899 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
5900 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
5901 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
5902 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
5903 __Pyx_AddTraceback("MACS2.Signal.savitzky_golay_order2_deriv1", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
5907 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
);
5908 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
);
5909 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
);
5910 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
5911 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
5912 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
5914 __Pyx_XDECREF((PyObject
*)__pyx_v_b
);
5915 __Pyx_XDECREF((PyObject
*)__pyx_v_firstvals
);
5916 __Pyx_XDECREF((PyObject
*)__pyx_v_lastvals
);
5917 __Pyx_XDECREF((PyObject
*)__pyx_v_m
);
5918 __Pyx_XDECREF((PyObject
*)__pyx_v_ret
);
5919 __Pyx_XDECREF((PyObject
*)__pyx_v_signal
);
5920 __Pyx_XGIVEREF((PyObject
*)__pyx_r
);
5921 __Pyx_TraceReturn(__pyx_r
, 0);
5922 __Pyx_RefNannyFinishContext();
5926 /* Python wrapper */
5927 static PyObject
*__pyx_pw_5MACS2_6Signal_7savitzky_golay_order2_deriv1(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
5928 static char __pyx_doc_5MACS2_6Signal_6savitzky_golay_order2_deriv1
[] = "Smooth (and optionally differentiate) data with a Savitzky-Golay filter.\n The Savitzky-Golay filter removes high frequency noise from data.\n It has the advantage of preserving the original shape and\n features of the signal better than other types of filtering\n approaches, such as moving averages techhniques.\n Parameters\n ----------\n y : array_like, shape (N,)\n the values of the time history of the signal.\n window_size : int\n the length of the window. Must be an odd integer number.\n deriv: int\n the order of the derivative to compute (default = 0 means only smoothing)\n Returns\n -------\n ys : ndarray, shape (N)\n the smoothed signal (or it's n-th derivative).\n Notes\n -----\n The Savitzky-Golay is a type of low-pass filter, particularly\n suited for smoothing noisy data. The main idea behind this\n approach is to make for each point a least-square fit with a\n polynomial of high order over a odd-sized window centered at\n the point.\n\n References\n ----------\n .. [1] A. Savitzky, M. J. E. Golay, Smoothing and Differentiation of\n Data by Simplified Least Squares Procedures. Analytical\n Chemistry, 1964, 36 (8), pp 1627-1639.\n .. [2] Numerical Recipes 3rd Edition: The Art of Scientific Computing\n W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery\n Cambridge University Press ISBN-13: 9780521880688\n ";
5929 static PyObject
*__pyx_pw_5MACS2_6Signal_7savitzky_golay_order2_deriv1(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
) {
5930 PyArrayObject
*__pyx_v_signal
= 0;
5931 int __pyx_v_window_size
;
5932 PyObject
*__pyx_r
= 0;
5933 __Pyx_RefNannyDeclarations
5934 __Pyx_RefNannySetupContext("savitzky_golay_order2_deriv1 (wrapper)", 0);
5936 static PyObject
**__pyx_pyargnames
[] = {&__pyx_n_s_signal
,&__pyx_n_s_window_size
,0};
5937 PyObject
* values
[2] = {0,0};
5938 if (unlikely(__pyx_kwds
)) {
5940 const Py_ssize_t pos_args
= PyTuple_GET_SIZE(__pyx_args
);
5942 case 2: values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
5944 case 1: values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
5947 default: goto __pyx_L5_argtuple_error
;
5949 kw_args
= PyDict_Size(__pyx_kwds
);
5952 if (likely((values
[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_signal
)) != 0)) kw_args
--;
5953 else goto __pyx_L5_argtuple_error
;
5956 if (likely((values
[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_window_size
)) != 0)) kw_args
--;
5958 __Pyx_RaiseArgtupleInvalid("savitzky_golay_order2_deriv1", 1, 2, 2, 1); __PYX_ERR(0, 205, __pyx_L3_error
)
5961 if (unlikely(kw_args
> 0)) {
5962 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds
, __pyx_pyargnames
, 0, values
, pos_args
, "savitzky_golay_order2_deriv1") < 0)) __PYX_ERR(0, 205, __pyx_L3_error
)
5964 } else if (PyTuple_GET_SIZE(__pyx_args
) != 2) {
5965 goto __pyx_L5_argtuple_error
;
5967 values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
5968 values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
5970 __pyx_v_signal
= ((PyArrayObject
*)values
[0]);
5971 __pyx_v_window_size
= __Pyx_PyInt_As_int(values
[1]); if (unlikely((__pyx_v_window_size
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 206, __pyx_L3_error
)
5973 goto __pyx_L4_argument_unpacking_done
;
5974 __pyx_L5_argtuple_error
:;
5975 __Pyx_RaiseArgtupleInvalid("savitzky_golay_order2_deriv1", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args
)); __PYX_ERR(0, 205, __pyx_L3_error
)
5977 __Pyx_AddTraceback("MACS2.Signal.savitzky_golay_order2_deriv1", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
5978 __Pyx_RefNannyFinishContext();
5980 __pyx_L4_argument_unpacking_done
:;
5981 if (unlikely(!__Pyx_ArgTypeTest(((PyObject
*)__pyx_v_signal
), __pyx_ptype_5numpy_ndarray
, 1, "signal", 0))) __PYX_ERR(0, 205, __pyx_L1_error
)
5982 __pyx_r
= __pyx_pf_5MACS2_6Signal_6savitzky_golay_order2_deriv1(__pyx_self
, __pyx_v_signal
, __pyx_v_window_size
);
5984 /* function exit code */
5989 __Pyx_RefNannyFinishContext();
5993 static PyObject
*__pyx_pf_5MACS2_6Signal_6savitzky_golay_order2_deriv1(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_signal
, int __pyx_v_window_size
) {
5994 __Pyx_LocalBuf_ND __pyx_pybuffernd_signal
;
5995 __Pyx_Buffer __pyx_pybuffer_signal
;
5996 PyObject
*__pyx_r
= NULL
;
5997 __Pyx_TraceDeclarations
5998 __Pyx_RefNannyDeclarations
5999 PyObject
*__pyx_t_1
= NULL
;
6000 __Pyx_RefNannySetupContext("savitzky_golay_order2_deriv1", 0);
6001 __Pyx_TraceCall("savitzky_golay_order2_deriv1 (wrapper)", __pyx_f
[0], 205, 0, __PYX_ERR(0, 205, __pyx_L1_error
));
6002 __pyx_pybuffer_signal
.pybuffer
.buf
= NULL
;
6003 __pyx_pybuffer_signal
.refcount
= 0;
6004 __pyx_pybuffernd_signal
.data
= NULL
;
6005 __pyx_pybuffernd_signal
.rcbuffer
= &__pyx_pybuffer_signal
;
6007 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6008 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_signal
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 205, __pyx_L1_error
)
6010 __pyx_pybuffernd_signal
.diminfo
[0].strides
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_signal
.diminfo
[0].shape
= __pyx_pybuffernd_signal
.rcbuffer
->pybuffer
.shape
[0];
6011 __Pyx_XDECREF(__pyx_r
);
6012 __pyx_t_1
= ((PyObject
*)__pyx_f_5MACS2_6Signal_savitzky_golay_order2_deriv1(__pyx_v_signal
, __pyx_v_window_size
, 0)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 205, __pyx_L1_error
)
6013 __Pyx_GOTREF(__pyx_t_1
);
6014 __pyx_r
= __pyx_t_1
;
6018 /* function exit code */
6020 __Pyx_XDECREF(__pyx_t_1
);
6021 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
6022 __Pyx_PyThreadState_declare
6023 __Pyx_PyThreadState_assign
6024 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
6025 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
6026 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
6027 __Pyx_AddTraceback("MACS2.Signal.savitzky_golay_order2_deriv1", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
6031 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal
.rcbuffer
->pybuffer
);
6033 __Pyx_XGIVEREF(__pyx_r
);
6034 __Pyx_TraceReturn(__pyx_r
, 0);
6035 __Pyx_RefNannyFinishContext();
6039 /* "MACS2/Signal.pyx":267
6041 * # Another modified version from http://www.scipy.org/Cookbook/SavitzkyGolay
6042 * cpdef np.ndarray[np.float32_t, ndim=1] savitzky_golay( np.ndarray[np.float32_t, ndim=1] y, int window_size, # <<<<<<<<<<<<<<
6043 * int order, int deriv = 0, int rate = 1 ):
6044 * """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
6047 static PyObject
*__pyx_pw_5MACS2_6Signal_9savitzky_golay(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
6048 static PyArrayObject
*__pyx_f_5MACS2_6Signal_savitzky_golay(PyArrayObject
*__pyx_v_y
, int __pyx_v_window_size
, int __pyx_v_order
, CYTHON_UNUSED
int __pyx_skip_dispatch
, struct __pyx_opt_args_5MACS2_6Signal_savitzky_golay
*__pyx_optional_args
) {
6049 int __pyx_v_deriv
= ((int)0);
6050 int __pyx_v_rate
= ((int)1);
6051 int __pyx_v_half_window
;
6052 PyArrayObject
*__pyx_v_b
= 0;
6053 PyArrayObject
*__pyx_v_firstvals
= 0;
6054 PyArrayObject
*__pyx_v_lastvals
= 0;
6055 PyArrayObject
*__pyx_v_ret
= 0;
6056 PyArrayObject
*__pyx_v_m
= 0;
6057 CYTHON_UNUSED PyObject
*__pyx_v_msg
= NULL
;
6058 int __pyx_8genexpr1__pyx_v_k
;
6059 long __pyx_8genexpr2__pyx_v_i
;
6060 __Pyx_LocalBuf_ND __pyx_pybuffernd_b
;
6061 __Pyx_Buffer __pyx_pybuffer_b
;
6062 __Pyx_LocalBuf_ND __pyx_pybuffernd_firstvals
;
6063 __Pyx_Buffer __pyx_pybuffer_firstvals
;
6064 __Pyx_LocalBuf_ND __pyx_pybuffernd_lastvals
;
6065 __Pyx_Buffer __pyx_pybuffer_lastvals
;
6066 __Pyx_LocalBuf_ND __pyx_pybuffernd_m
;
6067 __Pyx_Buffer __pyx_pybuffer_m
;
6068 __Pyx_LocalBuf_ND __pyx_pybuffernd_ret
;
6069 __Pyx_Buffer __pyx_pybuffer_ret
;
6070 __Pyx_LocalBuf_ND __pyx_pybuffernd_y
;
6071 __Pyx_Buffer __pyx_pybuffer_y
;
6072 PyArrayObject
*__pyx_r
= NULL
;
6073 __Pyx_TraceDeclarations
6074 __Pyx_RefNannyDeclarations
6075 PyObject
*__pyx_t_1
= NULL
;
6076 PyObject
*__pyx_t_2
= NULL
;
6077 PyObject
*__pyx_t_3
= NULL
;
6078 PyObject
*__pyx_t_4
= NULL
;
6079 PyObject
*__pyx_t_5
= NULL
;
6080 PyObject
*__pyx_t_6
= NULL
;
6081 PyObject
*__pyx_t_7
= NULL
;
6082 PyObject
*__pyx_t_8
= NULL
;
6083 PyObject
*__pyx_t_9
= NULL
;
6092 PyArrayObject
*__pyx_t_18
= NULL
;
6093 PyArrayObject
*__pyx_t_19
= NULL
;
6094 Py_ssize_t __pyx_t_20
;
6095 Py_ssize_t __pyx_t_21
;
6096 PyArrayObject
*__pyx_t_22
= NULL
;
6097 Py_ssize_t __pyx_t_23
;
6098 Py_ssize_t __pyx_t_24
;
6099 PyArrayObject
*__pyx_t_25
= NULL
;
6100 __Pyx_RefNannySetupContext("savitzky_golay", 0);
6101 __Pyx_TraceCall("savitzky_golay", __pyx_f
[0], 267, 0, __PYX_ERR(0, 267, __pyx_L1_error
));
6102 if (__pyx_optional_args
) {
6103 if (__pyx_optional_args
->__pyx_n
> 0) {
6104 __pyx_v_deriv
= __pyx_optional_args
->deriv
;
6105 if (__pyx_optional_args
->__pyx_n
> 1) {
6106 __pyx_v_rate
= __pyx_optional_args
->rate
;
6110 __Pyx_INCREF((PyObject
*)__pyx_v_y
);
6111 __pyx_pybuffer_b
.pybuffer
.buf
= NULL
;
6112 __pyx_pybuffer_b
.refcount
= 0;
6113 __pyx_pybuffernd_b
.data
= NULL
;
6114 __pyx_pybuffernd_b
.rcbuffer
= &__pyx_pybuffer_b
;
6115 __pyx_pybuffer_firstvals
.pybuffer
.buf
= NULL
;
6116 __pyx_pybuffer_firstvals
.refcount
= 0;
6117 __pyx_pybuffernd_firstvals
.data
= NULL
;
6118 __pyx_pybuffernd_firstvals
.rcbuffer
= &__pyx_pybuffer_firstvals
;
6119 __pyx_pybuffer_lastvals
.pybuffer
.buf
= NULL
;
6120 __pyx_pybuffer_lastvals
.refcount
= 0;
6121 __pyx_pybuffernd_lastvals
.data
= NULL
;
6122 __pyx_pybuffernd_lastvals
.rcbuffer
= &__pyx_pybuffer_lastvals
;
6123 __pyx_pybuffer_ret
.pybuffer
.buf
= NULL
;
6124 __pyx_pybuffer_ret
.refcount
= 0;
6125 __pyx_pybuffernd_ret
.data
= NULL
;
6126 __pyx_pybuffernd_ret
.rcbuffer
= &__pyx_pybuffer_ret
;
6127 __pyx_pybuffer_m
.pybuffer
.buf
= NULL
;
6128 __pyx_pybuffer_m
.refcount
= 0;
6129 __pyx_pybuffernd_m
.data
= NULL
;
6130 __pyx_pybuffernd_m
.rcbuffer
= &__pyx_pybuffer_m
;
6131 __pyx_pybuffer_y
.pybuffer
.buf
= NULL
;
6132 __pyx_pybuffer_y
.refcount
= 0;
6133 __pyx_pybuffernd_y
.data
= NULL
;
6134 __pyx_pybuffernd_y
.rcbuffer
= &__pyx_pybuffer_y
;
6136 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6137 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_y
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 267, __pyx_L1_error
)
6139 __pyx_pybuffernd_y
.diminfo
[0].strides
= __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_y
.diminfo
[0].shape
= __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.shape
[0];
6141 /* "MACS2/Signal.pyx":324
6142 * np.ndarray[np.float64_t, ndim=1] m
6144 * try: # <<<<<<<<<<<<<<
6145 * window_size = np.abs( np.int( window_size ) )
6146 * order = np.abs( np.int( order ) )
6149 __Pyx_PyThreadState_declare
6150 __Pyx_PyThreadState_assign
6151 __Pyx_ExceptionSave(&__pyx_t_1
, &__pyx_t_2
, &__pyx_t_3
);
6152 __Pyx_XGOTREF(__pyx_t_1
);
6153 __Pyx_XGOTREF(__pyx_t_2
);
6154 __Pyx_XGOTREF(__pyx_t_3
);
6157 /* "MACS2/Signal.pyx":325
6160 * window_size = np.abs( np.int( window_size ) ) # <<<<<<<<<<<<<<
6161 * order = np.abs( np.int( order ) )
6162 * except ValueError, msg:
6164 __Pyx_GetModuleGlobalName(__pyx_t_5
, __pyx_n_s_np
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 325, __pyx_L3_error
)
6165 __Pyx_GOTREF(__pyx_t_5
);
6166 __pyx_t_6
= __Pyx_PyObject_GetAttrStr(__pyx_t_5
, __pyx_n_s_abs
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 325, __pyx_L3_error
)
6167 __Pyx_GOTREF(__pyx_t_6
);
6168 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6169 __Pyx_GetModuleGlobalName(__pyx_t_7
, __pyx_n_s_np
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 325, __pyx_L3_error
)
6170 __Pyx_GOTREF(__pyx_t_7
);
6171 __pyx_t_8
= __Pyx_PyObject_GetAttrStr(__pyx_t_7
, __pyx_n_s_int
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 325, __pyx_L3_error
)
6172 __Pyx_GOTREF(__pyx_t_8
);
6173 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6174 __pyx_t_7
= __Pyx_PyInt_From_int(__pyx_v_window_size
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 325, __pyx_L3_error
)
6175 __Pyx_GOTREF(__pyx_t_7
);
6177 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_8
))) {
6178 __pyx_t_9
= PyMethod_GET_SELF(__pyx_t_8
);
6179 if (likely(__pyx_t_9
)) {
6180 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_8
);
6181 __Pyx_INCREF(__pyx_t_9
);
6182 __Pyx_INCREF(function
);
6183 __Pyx_DECREF_SET(__pyx_t_8
, function
);
6186 __pyx_t_5
= (__pyx_t_9
) ? __Pyx_PyObject_Call2Args(__pyx_t_8
, __pyx_t_9
, __pyx_t_7
) : __Pyx_PyObject_CallOneArg(__pyx_t_8
, __pyx_t_7
);
6187 __Pyx_XDECREF(__pyx_t_9
); __pyx_t_9
= 0;
6188 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6189 if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 325, __pyx_L3_error
)
6190 __Pyx_GOTREF(__pyx_t_5
);
6191 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6193 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_6
))) {
6194 __pyx_t_8
= PyMethod_GET_SELF(__pyx_t_6
);
6195 if (likely(__pyx_t_8
)) {
6196 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_6
);
6197 __Pyx_INCREF(__pyx_t_8
);
6198 __Pyx_INCREF(function
);
6199 __Pyx_DECREF_SET(__pyx_t_6
, function
);
6202 __pyx_t_4
= (__pyx_t_8
) ? __Pyx_PyObject_Call2Args(__pyx_t_6
, __pyx_t_8
, __pyx_t_5
) : __Pyx_PyObject_CallOneArg(__pyx_t_6
, __pyx_t_5
);
6203 __Pyx_XDECREF(__pyx_t_8
); __pyx_t_8
= 0;
6204 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6205 if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 325, __pyx_L3_error
)
6206 __Pyx_GOTREF(__pyx_t_4
);
6207 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6208 __pyx_t_10
= __Pyx_PyInt_As_int(__pyx_t_4
); if (unlikely((__pyx_t_10
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 325, __pyx_L3_error
)
6209 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6210 __pyx_v_window_size
= __pyx_t_10
;
6212 /* "MACS2/Signal.pyx":326
6214 * window_size = np.abs( np.int( window_size ) )
6215 * order = np.abs( np.int( order ) ) # <<<<<<<<<<<<<<
6216 * except ValueError, msg:
6217 * raise ValueError("window_size and order have to be of type int")
6219 __Pyx_GetModuleGlobalName(__pyx_t_6
, __pyx_n_s_np
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 326, __pyx_L3_error
)
6220 __Pyx_GOTREF(__pyx_t_6
);
6221 __pyx_t_5
= __Pyx_PyObject_GetAttrStr(__pyx_t_6
, __pyx_n_s_abs
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 326, __pyx_L3_error
)
6222 __Pyx_GOTREF(__pyx_t_5
);
6223 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6224 __Pyx_GetModuleGlobalName(__pyx_t_8
, __pyx_n_s_np
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 326, __pyx_L3_error
)
6225 __Pyx_GOTREF(__pyx_t_8
);
6226 __pyx_t_7
= __Pyx_PyObject_GetAttrStr(__pyx_t_8
, __pyx_n_s_int
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 326, __pyx_L3_error
)
6227 __Pyx_GOTREF(__pyx_t_7
);
6228 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6229 __pyx_t_8
= __Pyx_PyInt_From_int(__pyx_v_order
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 326, __pyx_L3_error
)
6230 __Pyx_GOTREF(__pyx_t_8
);
6232 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_7
))) {
6233 __pyx_t_9
= PyMethod_GET_SELF(__pyx_t_7
);
6234 if (likely(__pyx_t_9
)) {
6235 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_7
);
6236 __Pyx_INCREF(__pyx_t_9
);
6237 __Pyx_INCREF(function
);
6238 __Pyx_DECREF_SET(__pyx_t_7
, function
);
6241 __pyx_t_6
= (__pyx_t_9
) ? __Pyx_PyObject_Call2Args(__pyx_t_7
, __pyx_t_9
, __pyx_t_8
) : __Pyx_PyObject_CallOneArg(__pyx_t_7
, __pyx_t_8
);
6242 __Pyx_XDECREF(__pyx_t_9
); __pyx_t_9
= 0;
6243 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6244 if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 326, __pyx_L3_error
)
6245 __Pyx_GOTREF(__pyx_t_6
);
6246 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6248 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_5
))) {
6249 __pyx_t_7
= PyMethod_GET_SELF(__pyx_t_5
);
6250 if (likely(__pyx_t_7
)) {
6251 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_5
);
6252 __Pyx_INCREF(__pyx_t_7
);
6253 __Pyx_INCREF(function
);
6254 __Pyx_DECREF_SET(__pyx_t_5
, function
);
6257 __pyx_t_4
= (__pyx_t_7
) ? __Pyx_PyObject_Call2Args(__pyx_t_5
, __pyx_t_7
, __pyx_t_6
) : __Pyx_PyObject_CallOneArg(__pyx_t_5
, __pyx_t_6
);
6258 __Pyx_XDECREF(__pyx_t_7
); __pyx_t_7
= 0;
6259 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6260 if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 326, __pyx_L3_error
)
6261 __Pyx_GOTREF(__pyx_t_4
);
6262 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6263 __pyx_t_10
= __Pyx_PyInt_As_int(__pyx_t_4
); if (unlikely((__pyx_t_10
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L3_error
)
6264 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6265 __pyx_v_order
= __pyx_t_10
;
6267 /* "MACS2/Signal.pyx":324
6268 * np.ndarray[np.float64_t, ndim=1] m
6270 * try: # <<<<<<<<<<<<<<
6271 * window_size = np.abs( np.int( window_size ) )
6272 * order = np.abs( np.int( order ) )
6275 __Pyx_XDECREF(__pyx_t_1
); __pyx_t_1
= 0;
6276 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
6277 __Pyx_XDECREF(__pyx_t_3
); __pyx_t_3
= 0;
6278 goto __pyx_L8_try_end
;
6280 __Pyx_XDECREF(__pyx_t_4
); __pyx_t_4
= 0;
6281 __Pyx_XDECREF(__pyx_t_5
); __pyx_t_5
= 0;
6282 __Pyx_XDECREF(__pyx_t_6
); __pyx_t_6
= 0;
6283 __Pyx_XDECREF(__pyx_t_7
); __pyx_t_7
= 0;
6284 __Pyx_XDECREF(__pyx_t_8
); __pyx_t_8
= 0;
6285 __Pyx_XDECREF(__pyx_t_9
); __pyx_t_9
= 0;
6287 /* "MACS2/Signal.pyx":327
6288 * window_size = np.abs( np.int( window_size ) )
6289 * order = np.abs( np.int( order ) )
6290 * except ValueError, msg: # <<<<<<<<<<<<<<
6291 * raise ValueError("window_size and order have to be of type int")
6292 * if window_size % 2 != 1 or window_size < 1:
6294 __pyx_t_10
= __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError
);
6296 __Pyx_AddTraceback("MACS2.Signal.savitzky_golay", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
6297 if (__Pyx_GetException(&__pyx_t_4
, &__pyx_t_5
, &__pyx_t_6
) < 0) __PYX_ERR(0, 327, __pyx_L5_except_error
)
6298 __Pyx_GOTREF(__pyx_t_4
);
6299 __Pyx_GOTREF(__pyx_t_5
);
6300 __Pyx_GOTREF(__pyx_t_6
);
6301 __Pyx_INCREF(__pyx_t_5
);
6302 __pyx_v_msg
= __pyx_t_5
;
6304 /* "MACS2/Signal.pyx":328
6305 * order = np.abs( np.int( order ) )
6306 * except ValueError, msg:
6307 * raise ValueError("window_size and order have to be of type int") # <<<<<<<<<<<<<<
6308 * if window_size % 2 != 1 or window_size < 1:
6309 * raise TypeError("window_size size must be a positive odd number")
6311 __pyx_t_7
= __Pyx_PyObject_Call(__pyx_builtin_ValueError
, __pyx_tuple__3
, NULL
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 328, __pyx_L5_except_error
)
6312 __Pyx_GOTREF(__pyx_t_7
);
6313 __Pyx_Raise(__pyx_t_7
, 0, 0, 0);
6314 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6315 __PYX_ERR(0, 328, __pyx_L5_except_error
)
6317 goto __pyx_L5_except_error
;
6318 __pyx_L5_except_error
:;
6320 /* "MACS2/Signal.pyx":324
6321 * np.ndarray[np.float64_t, ndim=1] m
6323 * try: # <<<<<<<<<<<<<<
6324 * window_size = np.abs( np.int( window_size ) )
6325 * order = np.abs( np.int( order ) )
6327 __Pyx_XGIVEREF(__pyx_t_1
);
6328 __Pyx_XGIVEREF(__pyx_t_2
);
6329 __Pyx_XGIVEREF(__pyx_t_3
);
6330 __Pyx_ExceptionReset(__pyx_t_1
, __pyx_t_2
, __pyx_t_3
);
6331 goto __pyx_L1_error
;
6335 /* "MACS2/Signal.pyx":329
6336 * except ValueError, msg:
6337 * raise ValueError("window_size and order have to be of type int")
6338 * if window_size % 2 != 1 or window_size < 1: # <<<<<<<<<<<<<<
6339 * raise TypeError("window_size size must be a positive odd number")
6340 * if window_size < order + 2:
6342 __pyx_t_12
= ((__Pyx_mod_long(__pyx_v_window_size
, 2) != 1) != 0);
6345 __pyx_t_11
= __pyx_t_12
;
6346 goto __pyx_L12_bool_binop_done
;
6348 __pyx_t_12
= ((__pyx_v_window_size
< 1) != 0);
6349 __pyx_t_11
= __pyx_t_12
;
6350 __pyx_L12_bool_binop_done
:;
6351 if (unlikely(__pyx_t_11
)) {
6353 /* "MACS2/Signal.pyx":330
6354 * raise ValueError("window_size and order have to be of type int")
6355 * if window_size % 2 != 1 or window_size < 1:
6356 * raise TypeError("window_size size must be a positive odd number") # <<<<<<<<<<<<<<
6357 * if window_size < order + 2:
6358 * raise TypeError("window_size is too small for the polynomials order")
6360 __pyx_t_6
= __Pyx_PyObject_Call(__pyx_builtin_TypeError
, __pyx_tuple__4
, NULL
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 330, __pyx_L1_error
)
6361 __Pyx_GOTREF(__pyx_t_6
);
6362 __Pyx_Raise(__pyx_t_6
, 0, 0, 0);
6363 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6364 __PYX_ERR(0, 330, __pyx_L1_error
)
6366 /* "MACS2/Signal.pyx":329
6367 * except ValueError, msg:
6368 * raise ValueError("window_size and order have to be of type int")
6369 * if window_size % 2 != 1 or window_size < 1: # <<<<<<<<<<<<<<
6370 * raise TypeError("window_size size must be a positive odd number")
6371 * if window_size < order + 2:
6375 /* "MACS2/Signal.pyx":331
6376 * if window_size % 2 != 1 or window_size < 1:
6377 * raise TypeError("window_size size must be a positive odd number")
6378 * if window_size < order + 2: # <<<<<<<<<<<<<<
6379 * raise TypeError("window_size is too small for the polynomials order")
6380 * half_window = ( window_size -1 ) // 2
6382 __pyx_t_11
= ((__pyx_v_window_size
< (__pyx_v_order
+ 2)) != 0);
6383 if (unlikely(__pyx_t_11
)) {
6385 /* "MACS2/Signal.pyx":332
6386 * raise TypeError("window_size size must be a positive odd number")
6387 * if window_size < order + 2:
6388 * raise TypeError("window_size is too small for the polynomials order") # <<<<<<<<<<<<<<
6389 * half_window = ( window_size -1 ) // 2
6390 * # precompute coefficients
6392 __pyx_t_6
= __Pyx_PyObject_Call(__pyx_builtin_TypeError
, __pyx_tuple__5
, NULL
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 332, __pyx_L1_error
)
6393 __Pyx_GOTREF(__pyx_t_6
);
6394 __Pyx_Raise(__pyx_t_6
, 0, 0, 0);
6395 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6396 __PYX_ERR(0, 332, __pyx_L1_error
)
6398 /* "MACS2/Signal.pyx":331
6399 * if window_size % 2 != 1 or window_size < 1:
6400 * raise TypeError("window_size size must be a positive odd number")
6401 * if window_size < order + 2: # <<<<<<<<<<<<<<
6402 * raise TypeError("window_size is too small for the polynomials order")
6403 * half_window = ( window_size -1 ) // 2
6407 /* "MACS2/Signal.pyx":333
6408 * if window_size < order + 2:
6409 * raise TypeError("window_size is too small for the polynomials order")
6410 * half_window = ( window_size -1 ) // 2 # <<<<<<<<<<<<<<
6411 * # precompute coefficients
6412 * b = np.array( [ [ k**i for i in range( order + 1 ) ] for k in range( -half_window, half_window+1 ) ] )
6414 __pyx_v_half_window
= __Pyx_div_long((__pyx_v_window_size
- 1), 2);
6416 /* "MACS2/Signal.pyx":335
6417 * half_window = ( window_size -1 ) // 2
6418 * # precompute coefficients
6419 * b = np.array( [ [ k**i for i in range( order + 1 ) ] for k in range( -half_window, half_window+1 ) ] ) # <<<<<<<<<<<<<<
6420 * m = np.linalg.pinv( b )[ deriv ] * rate**deriv * mathfactorial( deriv )
6421 * # pad the signal at the extremes with
6423 __Pyx_GetModuleGlobalName(__pyx_t_5
, __pyx_n_s_np
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 335, __pyx_L1_error
)
6424 __Pyx_GOTREF(__pyx_t_5
);
6425 __pyx_t_4
= __Pyx_PyObject_GetAttrStr(__pyx_t_5
, __pyx_n_s_array
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 335, __pyx_L1_error
)
6426 __Pyx_GOTREF(__pyx_t_4
);
6427 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6428 { /* enter inner scope */
6429 __pyx_t_5
= PyList_New(0); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 335, __pyx_L1_error
)
6430 __Pyx_GOTREF(__pyx_t_5
);
6431 __pyx_t_13
= (__pyx_v_half_window
+ 1);
6432 __pyx_t_14
= __pyx_t_13
;
6433 for (__pyx_t_10
= (-__pyx_v_half_window
); __pyx_t_10
< __pyx_t_14
; __pyx_t_10
+=1) {
6434 __pyx_8genexpr1__pyx_v_k
= __pyx_t_10
;
6435 { /* enter inner scope */
6436 __pyx_t_7
= PyList_New(0); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 335, __pyx_L1_error
)
6437 __Pyx_GOTREF(__pyx_t_7
);
6438 __pyx_t_15
= (__pyx_v_order
+ 1);
6439 __pyx_t_16
= __pyx_t_15
;
6440 for (__pyx_t_17
= 0; __pyx_t_17
< __pyx_t_16
; __pyx_t_17
+=1) {
6441 __pyx_8genexpr2__pyx_v_i
= __pyx_t_17
;
6442 __pyx_t_8
= __Pyx_PyInt_From_long(__Pyx_pow_long(((long)__pyx_8genexpr1__pyx_v_k
), __pyx_8genexpr2__pyx_v_i
)); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 335, __pyx_L1_error
)
6443 __Pyx_GOTREF(__pyx_t_8
);
6444 if (unlikely(__Pyx_ListComp_Append(__pyx_t_7
, (PyObject
*)__pyx_t_8
))) __PYX_ERR(0, 335, __pyx_L1_error
)
6445 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6447 } /* exit inner scope */
6448 if (unlikely(__Pyx_ListComp_Append(__pyx_t_5
, (PyObject
*)__pyx_t_7
))) __PYX_ERR(0, 335, __pyx_L1_error
)
6449 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6451 } /* exit inner scope */
6453 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_4
))) {
6454 __pyx_t_7
= PyMethod_GET_SELF(__pyx_t_4
);
6455 if (likely(__pyx_t_7
)) {
6456 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_4
);
6457 __Pyx_INCREF(__pyx_t_7
);
6458 __Pyx_INCREF(function
);
6459 __Pyx_DECREF_SET(__pyx_t_4
, function
);
6462 __pyx_t_6
= (__pyx_t_7
) ? __Pyx_PyObject_Call2Args(__pyx_t_4
, __pyx_t_7
, __pyx_t_5
) : __Pyx_PyObject_CallOneArg(__pyx_t_4
, __pyx_t_5
);
6463 __Pyx_XDECREF(__pyx_t_7
); __pyx_t_7
= 0;
6464 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6465 if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 335, __pyx_L1_error
)
6466 __Pyx_GOTREF(__pyx_t_6
);
6467 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6468 if (!(likely(((__pyx_t_6
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_6
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 335, __pyx_L1_error
)
6469 __pyx_t_18
= ((PyArrayObject
*)__pyx_t_6
);
6471 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6472 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
);
6473 __pyx_t_10
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_18
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 2, 0, __pyx_stack
);
6474 if (unlikely(__pyx_t_10
< 0)) {
6475 PyErr_Fetch(&__pyx_t_3
, &__pyx_t_2
, &__pyx_t_1
);
6476 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_b
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 2, 0, __pyx_stack
) == -1)) {
6477 Py_XDECREF(__pyx_t_3
); Py_XDECREF(__pyx_t_2
); Py_XDECREF(__pyx_t_1
);
6478 __Pyx_RaiseBufferFallbackError();
6480 PyErr_Restore(__pyx_t_3
, __pyx_t_2
, __pyx_t_1
);
6482 __pyx_t_3
= __pyx_t_2
= __pyx_t_1
= 0;
6484 __pyx_pybuffernd_b
.diminfo
[0].strides
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_b
.diminfo
[0].shape
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.shape
[0]; __pyx_pybuffernd_b
.diminfo
[1].strides
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.strides
[1]; __pyx_pybuffernd_b
.diminfo
[1].shape
= __pyx_pybuffernd_b
.rcbuffer
->pybuffer
.shape
[1];
6485 if (unlikely(__pyx_t_10
< 0)) __PYX_ERR(0, 335, __pyx_L1_error
)
6488 __pyx_v_b
= ((PyArrayObject
*)__pyx_t_6
);
6491 /* "MACS2/Signal.pyx":336
6492 * # precompute coefficients
6493 * b = np.array( [ [ k**i for i in range( order + 1 ) ] for k in range( -half_window, half_window+1 ) ] )
6494 * m = np.linalg.pinv( b )[ deriv ] * rate**deriv * mathfactorial( deriv ) # <<<<<<<<<<<<<<
6495 * # pad the signal at the extremes with
6496 * # values taken from the signal itself
6498 __Pyx_GetModuleGlobalName(__pyx_t_4
, __pyx_n_s_np
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6499 __Pyx_GOTREF(__pyx_t_4
);
6500 __pyx_t_5
= __Pyx_PyObject_GetAttrStr(__pyx_t_4
, __pyx_n_s_linalg
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6501 __Pyx_GOTREF(__pyx_t_5
);
6502 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6503 __pyx_t_4
= __Pyx_PyObject_GetAttrStr(__pyx_t_5
, __pyx_n_s_pinv
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6504 __Pyx_GOTREF(__pyx_t_4
);
6505 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6507 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_4
))) {
6508 __pyx_t_5
= PyMethod_GET_SELF(__pyx_t_4
);
6509 if (likely(__pyx_t_5
)) {
6510 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_4
);
6511 __Pyx_INCREF(__pyx_t_5
);
6512 __Pyx_INCREF(function
);
6513 __Pyx_DECREF_SET(__pyx_t_4
, function
);
6516 __pyx_t_6
= (__pyx_t_5
) ? __Pyx_PyObject_Call2Args(__pyx_t_4
, __pyx_t_5
, ((PyObject
*)__pyx_v_b
)) : __Pyx_PyObject_CallOneArg(__pyx_t_4
, ((PyObject
*)__pyx_v_b
));
6517 __Pyx_XDECREF(__pyx_t_5
); __pyx_t_5
= 0;
6518 if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6519 __Pyx_GOTREF(__pyx_t_6
);
6520 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6521 __pyx_t_4
= __Pyx_GetItemInt(__pyx_t_6
, __pyx_v_deriv
, int, 1, __Pyx_PyInt_From_int
, 0, 1, 1); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6522 __Pyx_GOTREF(__pyx_t_4
);
6523 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6524 __pyx_t_6
= __Pyx_PyInt_From_int(__Pyx_pow_int(__pyx_v_rate
, __pyx_v_deriv
)); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6525 __Pyx_GOTREF(__pyx_t_6
);
6526 __pyx_t_5
= PyNumber_Multiply(__pyx_t_4
, __pyx_t_6
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6527 __Pyx_GOTREF(__pyx_t_5
);
6528 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6529 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6530 __Pyx_GetModuleGlobalName(__pyx_t_4
, __pyx_n_s_mathfactorial
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6531 __Pyx_GOTREF(__pyx_t_4
);
6532 __pyx_t_7
= __Pyx_PyInt_From_int(__pyx_v_deriv
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6533 __Pyx_GOTREF(__pyx_t_7
);
6535 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_4
))) {
6536 __pyx_t_8
= PyMethod_GET_SELF(__pyx_t_4
);
6537 if (likely(__pyx_t_8
)) {
6538 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_4
);
6539 __Pyx_INCREF(__pyx_t_8
);
6540 __Pyx_INCREF(function
);
6541 __Pyx_DECREF_SET(__pyx_t_4
, function
);
6544 __pyx_t_6
= (__pyx_t_8
) ? __Pyx_PyObject_Call2Args(__pyx_t_4
, __pyx_t_8
, __pyx_t_7
) : __Pyx_PyObject_CallOneArg(__pyx_t_4
, __pyx_t_7
);
6545 __Pyx_XDECREF(__pyx_t_8
); __pyx_t_8
= 0;
6546 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6547 if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6548 __Pyx_GOTREF(__pyx_t_6
);
6549 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6550 __pyx_t_4
= PyNumber_Multiply(__pyx_t_5
, __pyx_t_6
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 336, __pyx_L1_error
)
6551 __Pyx_GOTREF(__pyx_t_4
);
6552 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6553 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6554 if (!(likely(((__pyx_t_4
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_4
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 336, __pyx_L1_error
)
6555 __pyx_t_19
= ((PyArrayObject
*)__pyx_t_4
);
6557 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6558 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
6559 __pyx_t_10
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_19
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
6560 if (unlikely(__pyx_t_10
< 0)) {
6561 PyErr_Fetch(&__pyx_t_1
, &__pyx_t_2
, &__pyx_t_3
);
6562 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_m
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
6563 Py_XDECREF(__pyx_t_1
); Py_XDECREF(__pyx_t_2
); Py_XDECREF(__pyx_t_3
);
6564 __Pyx_RaiseBufferFallbackError();
6566 PyErr_Restore(__pyx_t_1
, __pyx_t_2
, __pyx_t_3
);
6568 __pyx_t_1
= __pyx_t_2
= __pyx_t_3
= 0;
6570 __pyx_pybuffernd_m
.diminfo
[0].strides
= __pyx_pybuffernd_m
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_m
.diminfo
[0].shape
= __pyx_pybuffernd_m
.rcbuffer
->pybuffer
.shape
[0];
6571 if (unlikely(__pyx_t_10
< 0)) __PYX_ERR(0, 336, __pyx_L1_error
)
6574 __pyx_v_m
= ((PyArrayObject
*)__pyx_t_4
);
6577 /* "MACS2/Signal.pyx":339
6578 * # pad the signal at the extremes with
6579 * # values taken from the signal itself
6580 * firstvals = y[ 0 ] - np.abs( y[ 1:half_window + 1 ][ ::-1 ] - y[ 0 ] ) # <<<<<<<<<<<<<<
6581 * lastvals = y[ -1 ] + np.abs( y[ -half_window - 1:-1 ][ ::-1 ] - y[ -1 ])
6582 * y = np.concatenate( ( firstvals, y, lastvals ) )
6586 if (__pyx_t_20
< 0) {
6587 __pyx_t_20
+= __pyx_pybuffernd_y
.diminfo
[0].shape
;
6588 if (unlikely(__pyx_t_20
< 0)) __pyx_t_10
= 0;
6589 } else if (unlikely(__pyx_t_20
>= __pyx_pybuffernd_y
.diminfo
[0].shape
)) __pyx_t_10
= 0;
6590 if (unlikely(__pyx_t_10
!= -1)) {
6591 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
6592 __PYX_ERR(0, 339, __pyx_L1_error
)
6594 __pyx_t_4
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.buf
, __pyx_t_20
, __pyx_pybuffernd_y
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6595 __Pyx_GOTREF(__pyx_t_4
);
6596 __Pyx_GetModuleGlobalName(__pyx_t_5
, __pyx_n_s_np
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6597 __Pyx_GOTREF(__pyx_t_5
);
6598 __pyx_t_7
= __Pyx_PyObject_GetAttrStr(__pyx_t_5
, __pyx_n_s_abs
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6599 __Pyx_GOTREF(__pyx_t_7
);
6600 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6601 __pyx_t_5
= __Pyx_PyInt_From_long((__pyx_v_half_window
+ 1)); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6602 __Pyx_GOTREF(__pyx_t_5
);
6603 __pyx_t_8
= PySlice_New(__pyx_int_1
, __pyx_t_5
, Py_None
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6604 __Pyx_GOTREF(__pyx_t_8
);
6605 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6606 __pyx_t_5
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_y
), __pyx_t_8
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6607 __Pyx_GOTREF(__pyx_t_5
);
6608 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6609 __pyx_t_8
= __Pyx_PyObject_GetItem(__pyx_t_5
, __pyx_slice__2
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6610 __Pyx_GOTREF(__pyx_t_8
);
6611 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6614 if (__pyx_t_21
< 0) {
6615 __pyx_t_21
+= __pyx_pybuffernd_y
.diminfo
[0].shape
;
6616 if (unlikely(__pyx_t_21
< 0)) __pyx_t_10
= 0;
6617 } else if (unlikely(__pyx_t_21
>= __pyx_pybuffernd_y
.diminfo
[0].shape
)) __pyx_t_10
= 0;
6618 if (unlikely(__pyx_t_10
!= -1)) {
6619 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
6620 __PYX_ERR(0, 339, __pyx_L1_error
)
6622 __pyx_t_5
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.buf
, __pyx_t_21
, __pyx_pybuffernd_y
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6623 __Pyx_GOTREF(__pyx_t_5
);
6624 __pyx_t_9
= PyNumber_Subtract(__pyx_t_8
, __pyx_t_5
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6625 __Pyx_GOTREF(__pyx_t_9
);
6626 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6627 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6629 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_7
))) {
6630 __pyx_t_5
= PyMethod_GET_SELF(__pyx_t_7
);
6631 if (likely(__pyx_t_5
)) {
6632 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_7
);
6633 __Pyx_INCREF(__pyx_t_5
);
6634 __Pyx_INCREF(function
);
6635 __Pyx_DECREF_SET(__pyx_t_7
, function
);
6638 __pyx_t_6
= (__pyx_t_5
) ? __Pyx_PyObject_Call2Args(__pyx_t_7
, __pyx_t_5
, __pyx_t_9
) : __Pyx_PyObject_CallOneArg(__pyx_t_7
, __pyx_t_9
);
6639 __Pyx_XDECREF(__pyx_t_5
); __pyx_t_5
= 0;
6640 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
6641 if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6642 __Pyx_GOTREF(__pyx_t_6
);
6643 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6644 __pyx_t_7
= PyNumber_Subtract(__pyx_t_4
, __pyx_t_6
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 339, __pyx_L1_error
)
6645 __Pyx_GOTREF(__pyx_t_7
);
6646 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6647 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6648 if (!(likely(((__pyx_t_7
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_7
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 339, __pyx_L1_error
)
6649 __pyx_t_22
= ((PyArrayObject
*)__pyx_t_7
);
6651 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6652 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
);
6653 __pyx_t_10
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_22
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
6654 if (unlikely(__pyx_t_10
< 0)) {
6655 PyErr_Fetch(&__pyx_t_3
, &__pyx_t_2
, &__pyx_t_1
);
6656 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_firstvals
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
6657 Py_XDECREF(__pyx_t_3
); Py_XDECREF(__pyx_t_2
); Py_XDECREF(__pyx_t_1
);
6658 __Pyx_RaiseBufferFallbackError();
6660 PyErr_Restore(__pyx_t_3
, __pyx_t_2
, __pyx_t_1
);
6662 __pyx_t_3
= __pyx_t_2
= __pyx_t_1
= 0;
6664 __pyx_pybuffernd_firstvals
.diminfo
[0].strides
= __pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_firstvals
.diminfo
[0].shape
= __pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
.shape
[0];
6665 if (unlikely(__pyx_t_10
< 0)) __PYX_ERR(0, 339, __pyx_L1_error
)
6668 __pyx_v_firstvals
= ((PyArrayObject
*)__pyx_t_7
);
6671 /* "MACS2/Signal.pyx":340
6672 * # values taken from the signal itself
6673 * firstvals = y[ 0 ] - np.abs( y[ 1:half_window + 1 ][ ::-1 ] - y[ 0 ] )
6674 * lastvals = y[ -1 ] + np.abs( y[ -half_window - 1:-1 ][ ::-1 ] - y[ -1 ]) # <<<<<<<<<<<<<<
6675 * y = np.concatenate( ( firstvals, y, lastvals ) )
6676 * ret = np.convolve( m[ ::-1 ], y, mode = 'valid' ).astype("float32")
6680 if (__pyx_t_23
< 0) {
6681 __pyx_t_23
+= __pyx_pybuffernd_y
.diminfo
[0].shape
;
6682 if (unlikely(__pyx_t_23
< 0)) __pyx_t_10
= 0;
6683 } else if (unlikely(__pyx_t_23
>= __pyx_pybuffernd_y
.diminfo
[0].shape
)) __pyx_t_10
= 0;
6684 if (unlikely(__pyx_t_10
!= -1)) {
6685 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
6686 __PYX_ERR(0, 340, __pyx_L1_error
)
6688 __pyx_t_7
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.buf
, __pyx_t_23
, __pyx_pybuffernd_y
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6689 __Pyx_GOTREF(__pyx_t_7
);
6690 __Pyx_GetModuleGlobalName(__pyx_t_4
, __pyx_n_s_np
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6691 __Pyx_GOTREF(__pyx_t_4
);
6692 __pyx_t_9
= __Pyx_PyObject_GetAttrStr(__pyx_t_4
, __pyx_n_s_abs
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6693 __Pyx_GOTREF(__pyx_t_9
);
6694 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6695 __pyx_t_4
= __Pyx_PyInt_From_long(((-__pyx_v_half_window
) - 1)); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6696 __Pyx_GOTREF(__pyx_t_4
);
6697 __pyx_t_5
= PySlice_New(__pyx_t_4
, __pyx_int_neg_1
, Py_None
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6698 __Pyx_GOTREF(__pyx_t_5
);
6699 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6700 __pyx_t_4
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_y
), __pyx_t_5
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6701 __Pyx_GOTREF(__pyx_t_4
);
6702 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6703 __pyx_t_5
= __Pyx_PyObject_GetItem(__pyx_t_4
, __pyx_slice__2
); if (unlikely(!__pyx_t_5
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6704 __Pyx_GOTREF(__pyx_t_5
);
6705 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6708 if (__pyx_t_24
< 0) {
6709 __pyx_t_24
+= __pyx_pybuffernd_y
.diminfo
[0].shape
;
6710 if (unlikely(__pyx_t_24
< 0)) __pyx_t_10
= 0;
6711 } else if (unlikely(__pyx_t_24
>= __pyx_pybuffernd_y
.diminfo
[0].shape
)) __pyx_t_10
= 0;
6712 if (unlikely(__pyx_t_10
!= -1)) {
6713 __Pyx_RaiseBufferIndexError(__pyx_t_10
);
6714 __PYX_ERR(0, 340, __pyx_L1_error
)
6716 __pyx_t_4
= PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t
*, __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.buf
, __pyx_t_24
, __pyx_pybuffernd_y
.diminfo
[0].strides
))); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6717 __Pyx_GOTREF(__pyx_t_4
);
6718 __pyx_t_8
= PyNumber_Subtract(__pyx_t_5
, __pyx_t_4
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6719 __Pyx_GOTREF(__pyx_t_8
);
6720 __Pyx_DECREF(__pyx_t_5
); __pyx_t_5
= 0;
6721 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6723 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_9
))) {
6724 __pyx_t_4
= PyMethod_GET_SELF(__pyx_t_9
);
6725 if (likely(__pyx_t_4
)) {
6726 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_9
);
6727 __Pyx_INCREF(__pyx_t_4
);
6728 __Pyx_INCREF(function
);
6729 __Pyx_DECREF_SET(__pyx_t_9
, function
);
6732 __pyx_t_6
= (__pyx_t_4
) ? __Pyx_PyObject_Call2Args(__pyx_t_9
, __pyx_t_4
, __pyx_t_8
) : __Pyx_PyObject_CallOneArg(__pyx_t_9
, __pyx_t_8
);
6733 __Pyx_XDECREF(__pyx_t_4
); __pyx_t_4
= 0;
6734 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6735 if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6736 __Pyx_GOTREF(__pyx_t_6
);
6737 __Pyx_DECREF(__pyx_t_9
); __pyx_t_9
= 0;
6738 __pyx_t_9
= PyNumber_Add(__pyx_t_7
, __pyx_t_6
); if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 340, __pyx_L1_error
)
6739 __Pyx_GOTREF(__pyx_t_9
);
6740 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6741 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6742 if (!(likely(((__pyx_t_9
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_9
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 340, __pyx_L1_error
)
6743 __pyx_t_22
= ((PyArrayObject
*)__pyx_t_9
);
6745 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6746 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
);
6747 __pyx_t_10
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_22
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
6748 if (unlikely(__pyx_t_10
< 0)) {
6749 PyErr_Fetch(&__pyx_t_1
, &__pyx_t_2
, &__pyx_t_3
);
6750 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_lastvals
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
6751 Py_XDECREF(__pyx_t_1
); Py_XDECREF(__pyx_t_2
); Py_XDECREF(__pyx_t_3
);
6752 __Pyx_RaiseBufferFallbackError();
6754 PyErr_Restore(__pyx_t_1
, __pyx_t_2
, __pyx_t_3
);
6756 __pyx_t_1
= __pyx_t_2
= __pyx_t_3
= 0;
6758 __pyx_pybuffernd_lastvals
.diminfo
[0].strides
= __pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_lastvals
.diminfo
[0].shape
= __pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
.shape
[0];
6759 if (unlikely(__pyx_t_10
< 0)) __PYX_ERR(0, 340, __pyx_L1_error
)
6762 __pyx_v_lastvals
= ((PyArrayObject
*)__pyx_t_9
);
6765 /* "MACS2/Signal.pyx":341
6766 * firstvals = y[ 0 ] - np.abs( y[ 1:half_window + 1 ][ ::-1 ] - y[ 0 ] )
6767 * lastvals = y[ -1 ] + np.abs( y[ -half_window - 1:-1 ][ ::-1 ] - y[ -1 ])
6768 * y = np.concatenate( ( firstvals, y, lastvals ) ) # <<<<<<<<<<<<<<
6769 * ret = np.convolve( m[ ::-1 ], y, mode = 'valid' ).astype("float32")
6772 __Pyx_GetModuleGlobalName(__pyx_t_6
, __pyx_n_s_np
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 341, __pyx_L1_error
)
6773 __Pyx_GOTREF(__pyx_t_6
);
6774 __pyx_t_7
= __Pyx_PyObject_GetAttrStr(__pyx_t_6
, __pyx_n_s_concatenate
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 341, __pyx_L1_error
)
6775 __Pyx_GOTREF(__pyx_t_7
);
6776 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6777 __pyx_t_6
= PyTuple_New(3); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 341, __pyx_L1_error
)
6778 __Pyx_GOTREF(__pyx_t_6
);
6779 __Pyx_INCREF(((PyObject
*)__pyx_v_firstvals
));
6780 __Pyx_GIVEREF(((PyObject
*)__pyx_v_firstvals
));
6781 PyTuple_SET_ITEM(__pyx_t_6
, 0, ((PyObject
*)__pyx_v_firstvals
));
6782 __Pyx_INCREF(((PyObject
*)__pyx_v_y
));
6783 __Pyx_GIVEREF(((PyObject
*)__pyx_v_y
));
6784 PyTuple_SET_ITEM(__pyx_t_6
, 1, ((PyObject
*)__pyx_v_y
));
6785 __Pyx_INCREF(((PyObject
*)__pyx_v_lastvals
));
6786 __Pyx_GIVEREF(((PyObject
*)__pyx_v_lastvals
));
6787 PyTuple_SET_ITEM(__pyx_t_6
, 2, ((PyObject
*)__pyx_v_lastvals
));
6789 if (CYTHON_UNPACK_METHODS
&& unlikely(PyMethod_Check(__pyx_t_7
))) {
6790 __pyx_t_8
= PyMethod_GET_SELF(__pyx_t_7
);
6791 if (likely(__pyx_t_8
)) {
6792 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_7
);
6793 __Pyx_INCREF(__pyx_t_8
);
6794 __Pyx_INCREF(function
);
6795 __Pyx_DECREF_SET(__pyx_t_7
, function
);
6798 __pyx_t_9
= (__pyx_t_8
) ? __Pyx_PyObject_Call2Args(__pyx_t_7
, __pyx_t_8
, __pyx_t_6
) : __Pyx_PyObject_CallOneArg(__pyx_t_7
, __pyx_t_6
);
6799 __Pyx_XDECREF(__pyx_t_8
); __pyx_t_8
= 0;
6800 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6801 if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 341, __pyx_L1_error
)
6802 __Pyx_GOTREF(__pyx_t_9
);
6803 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6804 if (!(likely(((__pyx_t_9
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_9
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 341, __pyx_L1_error
)
6805 __pyx_t_25
= ((PyArrayObject
*)__pyx_t_9
);
6807 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6808 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
);
6809 __pyx_t_10
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_25
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
6810 if (unlikely(__pyx_t_10
< 0)) {
6811 PyErr_Fetch(&__pyx_t_3
, &__pyx_t_2
, &__pyx_t_1
);
6812 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_y
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
6813 Py_XDECREF(__pyx_t_3
); Py_XDECREF(__pyx_t_2
); Py_XDECREF(__pyx_t_1
);
6814 __Pyx_RaiseBufferFallbackError();
6816 PyErr_Restore(__pyx_t_3
, __pyx_t_2
, __pyx_t_1
);
6818 __pyx_t_3
= __pyx_t_2
= __pyx_t_1
= 0;
6820 __pyx_pybuffernd_y
.diminfo
[0].strides
= __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_y
.diminfo
[0].shape
= __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.shape
[0];
6821 if (unlikely(__pyx_t_10
< 0)) __PYX_ERR(0, 341, __pyx_L1_error
)
6824 __Pyx_DECREF_SET(__pyx_v_y
, ((PyArrayObject
*)__pyx_t_9
));
6827 /* "MACS2/Signal.pyx":342
6828 * lastvals = y[ -1 ] + np.abs( y[ -half_window - 1:-1 ][ ::-1 ] - y[ -1 ])
6829 * y = np.concatenate( ( firstvals, y, lastvals ) )
6830 * ret = np.convolve( m[ ::-1 ], y, mode = 'valid' ).astype("float32") # <<<<<<<<<<<<<<
6833 __Pyx_GetModuleGlobalName(__pyx_t_7
, __pyx_n_s_np
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6834 __Pyx_GOTREF(__pyx_t_7
);
6835 __pyx_t_6
= __Pyx_PyObject_GetAttrStr(__pyx_t_7
, __pyx_n_s_convolve
); if (unlikely(!__pyx_t_6
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6836 __Pyx_GOTREF(__pyx_t_6
);
6837 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6838 __pyx_t_7
= __Pyx_PyObject_GetItem(((PyObject
*)__pyx_v_m
), __pyx_slice__2
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6839 __Pyx_GOTREF(__pyx_t_7
);
6840 __pyx_t_8
= PyTuple_New(2); if (unlikely(!__pyx_t_8
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6841 __Pyx_GOTREF(__pyx_t_8
);
6842 __Pyx_GIVEREF(__pyx_t_7
);
6843 PyTuple_SET_ITEM(__pyx_t_8
, 0, __pyx_t_7
);
6844 __Pyx_INCREF(((PyObject
*)__pyx_v_y
));
6845 __Pyx_GIVEREF(((PyObject
*)__pyx_v_y
));
6846 PyTuple_SET_ITEM(__pyx_t_8
, 1, ((PyObject
*)__pyx_v_y
));
6848 __pyx_t_7
= __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6849 __Pyx_GOTREF(__pyx_t_7
);
6850 if (PyDict_SetItem(__pyx_t_7
, __pyx_n_s_mode
, __pyx_n_u_valid
) < 0) __PYX_ERR(0, 342, __pyx_L1_error
)
6851 __pyx_t_4
= __Pyx_PyObject_Call(__pyx_t_6
, __pyx_t_8
, __pyx_t_7
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6852 __Pyx_GOTREF(__pyx_t_4
);
6853 __Pyx_DECREF(__pyx_t_6
); __pyx_t_6
= 0;
6854 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
6855 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6856 __pyx_t_7
= __Pyx_PyObject_GetAttrStr(__pyx_t_4
, __pyx_n_s_astype
); if (unlikely(!__pyx_t_7
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6857 __Pyx_GOTREF(__pyx_t_7
);
6858 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
6860 if (CYTHON_UNPACK_METHODS
&& likely(PyMethod_Check(__pyx_t_7
))) {
6861 __pyx_t_4
= PyMethod_GET_SELF(__pyx_t_7
);
6862 if (likely(__pyx_t_4
)) {
6863 PyObject
* function
= PyMethod_GET_FUNCTION(__pyx_t_7
);
6864 __Pyx_INCREF(__pyx_t_4
);
6865 __Pyx_INCREF(function
);
6866 __Pyx_DECREF_SET(__pyx_t_7
, function
);
6869 __pyx_t_9
= (__pyx_t_4
) ? __Pyx_PyObject_Call2Args(__pyx_t_7
, __pyx_t_4
, __pyx_n_u_float32
) : __Pyx_PyObject_CallOneArg(__pyx_t_7
, __pyx_n_u_float32
);
6870 __Pyx_XDECREF(__pyx_t_4
); __pyx_t_4
= 0;
6871 if (unlikely(!__pyx_t_9
)) __PYX_ERR(0, 342, __pyx_L1_error
)
6872 __Pyx_GOTREF(__pyx_t_9
);
6873 __Pyx_DECREF(__pyx_t_7
); __pyx_t_7
= 0;
6874 if (!(likely(((__pyx_t_9
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_9
, __pyx_ptype_5numpy_ndarray
))))) __PYX_ERR(0, 342, __pyx_L1_error
)
6875 __pyx_t_22
= ((PyArrayObject
*)__pyx_t_9
);
6877 __Pyx_BufFmt_StackElem __pyx_stack
[1];
6878 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
6879 __pyx_t_10
= __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_t_22
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
);
6880 if (unlikely(__pyx_t_10
< 0)) {
6881 PyErr_Fetch(&__pyx_t_1
, &__pyx_t_2
, &__pyx_t_3
);
6882 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_ret
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) {
6883 Py_XDECREF(__pyx_t_1
); Py_XDECREF(__pyx_t_2
); Py_XDECREF(__pyx_t_3
);
6884 __Pyx_RaiseBufferFallbackError();
6886 PyErr_Restore(__pyx_t_1
, __pyx_t_2
, __pyx_t_3
);
6888 __pyx_t_1
= __pyx_t_2
= __pyx_t_3
= 0;
6890 __pyx_pybuffernd_ret
.diminfo
[0].strides
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_ret
.diminfo
[0].shape
= __pyx_pybuffernd_ret
.rcbuffer
->pybuffer
.shape
[0];
6891 if (unlikely(__pyx_t_10
< 0)) __PYX_ERR(0, 342, __pyx_L1_error
)
6894 __pyx_v_ret
= ((PyArrayObject
*)__pyx_t_9
);
6897 /* "MACS2/Signal.pyx":343
6898 * y = np.concatenate( ( firstvals, y, lastvals ) )
6899 * ret = np.convolve( m[ ::-1 ], y, mode = 'valid' ).astype("float32")
6900 * return ret # <<<<<<<<<<<<<<
6902 __Pyx_XDECREF(((PyObject
*)__pyx_r
));
6903 __Pyx_INCREF(((PyObject
*)__pyx_v_ret
));
6904 __pyx_r
= ((PyArrayObject
*)__pyx_v_ret
);
6907 /* "MACS2/Signal.pyx":267
6909 * # Another modified version from http://www.scipy.org/Cookbook/SavitzkyGolay
6910 * cpdef np.ndarray[np.float32_t, ndim=1] savitzky_golay( np.ndarray[np.float32_t, ndim=1] y, int window_size, # <<<<<<<<<<<<<<
6911 * int order, int deriv = 0, int rate = 1 ):
6912 * """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
6915 /* function exit code */
6917 __Pyx_XDECREF(__pyx_t_4
);
6918 __Pyx_XDECREF(__pyx_t_5
);
6919 __Pyx_XDECREF(__pyx_t_6
);
6920 __Pyx_XDECREF(__pyx_t_7
);
6921 __Pyx_XDECREF(__pyx_t_8
);
6922 __Pyx_XDECREF(__pyx_t_9
);
6923 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
6924 __Pyx_PyThreadState_declare
6925 __Pyx_PyThreadState_assign
6926 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
6927 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
);
6928 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
);
6929 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
);
6930 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
6931 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
6932 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
);
6933 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
6934 __Pyx_AddTraceback("MACS2.Signal.savitzky_golay", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
6938 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b
.rcbuffer
->pybuffer
);
6939 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_firstvals
.rcbuffer
->pybuffer
);
6940 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lastvals
.rcbuffer
->pybuffer
);
6941 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m
.rcbuffer
->pybuffer
);
6942 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret
.rcbuffer
->pybuffer
);
6943 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
);
6945 __Pyx_XDECREF((PyObject
*)__pyx_v_b
);
6946 __Pyx_XDECREF((PyObject
*)__pyx_v_firstvals
);
6947 __Pyx_XDECREF((PyObject
*)__pyx_v_lastvals
);
6948 __Pyx_XDECREF((PyObject
*)__pyx_v_ret
);
6949 __Pyx_XDECREF((PyObject
*)__pyx_v_m
);
6950 __Pyx_XDECREF(__pyx_v_msg
);
6951 __Pyx_XDECREF((PyObject
*)__pyx_v_y
);
6952 __Pyx_XGIVEREF((PyObject
*)__pyx_r
);
6953 __Pyx_TraceReturn(__pyx_r
, 0);
6954 __Pyx_RefNannyFinishContext();
6958 /* Python wrapper */
6959 static PyObject
*__pyx_pw_5MACS2_6Signal_9savitzky_golay(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
); /*proto*/
6960 static char __pyx_doc_5MACS2_6Signal_8savitzky_golay
[] = "Smooth (and optionally differentiate) data with a Savitzky-Golay filter.\n The Savitzky-Golay filter removes high frequency noise from data.\n It has the advantage of preserving the original shape and\n features of the signal better than other types of filtering\n approaches, such as moving averages techniques.\n Parameters\n ----------\n y : array_like, shape (N,)\n the values of the time history of the signal.\n window_size : int\n the length of the window. Must be an odd integer number.\n order : int\n the order of the polynomial used in the filtering.\n Must be less then `window_size` - 1.\n deriv: int\n the order of the derivative to compute (default = 0 means only smoothing)\n Returns\n -------\n ys : ndarray, shape (N)\n the smoothed signal (or it's n-th derivative).\n Notes\n -----\n The Savitzky-Golay is a type of low-pass filter, particularly\n suited for smoothing noisy data. The main idea behind this\n approach is to make for each point a least-square fit with a\n polynomial of high order over a odd-sized window centered at\n the point.\n Examples\n --------\n t = np.linspace(-4, 4, 500)\n y = np.exp( -t**2 ) + np.random.normal(0, 0.05, t.shape)\n ysg = savitzky_golay(y, window_size=31, order=4)\n import matplotlib.pyplot as plt\n plt.plot(t, y, label='Noisy signal')\n plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal')\n plt.plot(t, ysg, 'r', label='Filtered signal')\n plt.legend()\n plt.show()\n References\n ----------\n .. [1] A. Savitzky, M. J. E. Golay, Smoothing and Differentiation of\n Data by Simplified Least Squares Procedures. Analytical\n Chemistry, 1964, 36 (8), pp 1627-1639.\n .. [2] Numerical Recipes 3rd Edition: The Art of Scientific Computing\n W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery\n Cambridge University Press ISBN-13: 9780521880688\n "" ";
6961 static PyObject
*__pyx_pw_5MACS2_6Signal_9savitzky_golay(PyObject
*__pyx_self
, PyObject
*__pyx_args
, PyObject
*__pyx_kwds
) {
6962 PyArrayObject
*__pyx_v_y
= 0;
6963 int __pyx_v_window_size
;
6967 PyObject
*__pyx_r
= 0;
6968 __Pyx_RefNannyDeclarations
6969 __Pyx_RefNannySetupContext("savitzky_golay (wrapper)", 0);
6971 static PyObject
**__pyx_pyargnames
[] = {&__pyx_n_s_y
,&__pyx_n_s_window_size
,&__pyx_n_s_order
,&__pyx_n_s_deriv
,&__pyx_n_s_rate
,0};
6972 PyObject
* values
[5] = {0,0,0,0,0};
6973 if (unlikely(__pyx_kwds
)) {
6975 const Py_ssize_t pos_args
= PyTuple_GET_SIZE(__pyx_args
);
6977 case 5: values
[4] = PyTuple_GET_ITEM(__pyx_args
, 4);
6979 case 4: values
[3] = PyTuple_GET_ITEM(__pyx_args
, 3);
6981 case 3: values
[2] = PyTuple_GET_ITEM(__pyx_args
, 2);
6983 case 2: values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
6985 case 1: values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
6988 default: goto __pyx_L5_argtuple_error
;
6990 kw_args
= PyDict_Size(__pyx_kwds
);
6993 if (likely((values
[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_y
)) != 0)) kw_args
--;
6994 else goto __pyx_L5_argtuple_error
;
6997 if (likely((values
[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_window_size
)) != 0)) kw_args
--;
6999 __Pyx_RaiseArgtupleInvalid("savitzky_golay", 0, 3, 5, 1); __PYX_ERR(0, 267, __pyx_L3_error
)
7003 if (likely((values
[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_order
)) != 0)) kw_args
--;
7005 __Pyx_RaiseArgtupleInvalid("savitzky_golay", 0, 3, 5, 2); __PYX_ERR(0, 267, __pyx_L3_error
)
7010 PyObject
* value
= __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_deriv
);
7011 if (value
) { values
[3] = value
; kw_args
--; }
7016 PyObject
* value
= __Pyx_PyDict_GetItemStr(__pyx_kwds
, __pyx_n_s_rate
);
7017 if (value
) { values
[4] = value
; kw_args
--; }
7020 if (unlikely(kw_args
> 0)) {
7021 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds
, __pyx_pyargnames
, 0, values
, pos_args
, "savitzky_golay") < 0)) __PYX_ERR(0, 267, __pyx_L3_error
)
7024 switch (PyTuple_GET_SIZE(__pyx_args
)) {
7025 case 5: values
[4] = PyTuple_GET_ITEM(__pyx_args
, 4);
7027 case 4: values
[3] = PyTuple_GET_ITEM(__pyx_args
, 3);
7029 case 3: values
[2] = PyTuple_GET_ITEM(__pyx_args
, 2);
7030 values
[1] = PyTuple_GET_ITEM(__pyx_args
, 1);
7031 values
[0] = PyTuple_GET_ITEM(__pyx_args
, 0);
7033 default: goto __pyx_L5_argtuple_error
;
7036 __pyx_v_y
= ((PyArrayObject
*)values
[0]);
7037 __pyx_v_window_size
= __Pyx_PyInt_As_int(values
[1]); if (unlikely((__pyx_v_window_size
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L3_error
)
7038 __pyx_v_order
= __Pyx_PyInt_As_int(values
[2]); if (unlikely((__pyx_v_order
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 268, __pyx_L3_error
)
7040 __pyx_v_deriv
= __Pyx_PyInt_As_int(values
[3]); if (unlikely((__pyx_v_deriv
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 268, __pyx_L3_error
)
7042 __pyx_v_deriv
= ((int)0);
7045 __pyx_v_rate
= __Pyx_PyInt_As_int(values
[4]); if (unlikely((__pyx_v_rate
== (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 268, __pyx_L3_error
)
7047 __pyx_v_rate
= ((int)1);
7050 goto __pyx_L4_argument_unpacking_done
;
7051 __pyx_L5_argtuple_error
:;
7052 __Pyx_RaiseArgtupleInvalid("savitzky_golay", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args
)); __PYX_ERR(0, 267, __pyx_L3_error
)
7054 __Pyx_AddTraceback("MACS2.Signal.savitzky_golay", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
7055 __Pyx_RefNannyFinishContext();
7057 __pyx_L4_argument_unpacking_done
:;
7058 if (unlikely(!__Pyx_ArgTypeTest(((PyObject
*)__pyx_v_y
), __pyx_ptype_5numpy_ndarray
, 1, "y", 0))) __PYX_ERR(0, 267, __pyx_L1_error
)
7059 __pyx_r
= __pyx_pf_5MACS2_6Signal_8savitzky_golay(__pyx_self
, __pyx_v_y
, __pyx_v_window_size
, __pyx_v_order
, __pyx_v_deriv
, __pyx_v_rate
);
7061 /* function exit code */
7066 __Pyx_RefNannyFinishContext();
7070 static PyObject
*__pyx_pf_5MACS2_6Signal_8savitzky_golay(CYTHON_UNUSED PyObject
*__pyx_self
, PyArrayObject
*__pyx_v_y
, int __pyx_v_window_size
, int __pyx_v_order
, int __pyx_v_deriv
, int __pyx_v_rate
) {
7071 __Pyx_LocalBuf_ND __pyx_pybuffernd_y
;
7072 __Pyx_Buffer __pyx_pybuffer_y
;
7073 PyObject
*__pyx_r
= NULL
;
7074 __Pyx_TraceDeclarations
7075 __Pyx_RefNannyDeclarations
7076 PyObject
*__pyx_t_1
= NULL
;
7077 struct __pyx_opt_args_5MACS2_6Signal_savitzky_golay __pyx_t_2
;
7078 __Pyx_RefNannySetupContext("savitzky_golay", 0);
7079 __Pyx_TraceCall("savitzky_golay (wrapper)", __pyx_f
[0], 267, 0, __PYX_ERR(0, 267, __pyx_L1_error
));
7080 __pyx_pybuffer_y
.pybuffer
.buf
= NULL
;
7081 __pyx_pybuffer_y
.refcount
= 0;
7082 __pyx_pybuffernd_y
.data
= NULL
;
7083 __pyx_pybuffernd_y
.rcbuffer
= &__pyx_pybuffer_y
;
7085 __Pyx_BufFmt_StackElem __pyx_stack
[1];
7086 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
, (PyObject
*)__pyx_v_y
, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t
, PyBUF_FORMAT
| PyBUF_STRIDES
, 1, 0, __pyx_stack
) == -1)) __PYX_ERR(0, 267, __pyx_L1_error
)
7088 __pyx_pybuffernd_y
.diminfo
[0].strides
= __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.strides
[0]; __pyx_pybuffernd_y
.diminfo
[0].shape
= __pyx_pybuffernd_y
.rcbuffer
->pybuffer
.shape
[0];
7089 __Pyx_XDECREF(__pyx_r
);
7090 __pyx_t_2
.__pyx_n
= 2;
7091 __pyx_t_2
.deriv
= __pyx_v_deriv
;
7092 __pyx_t_2
.rate
= __pyx_v_rate
;
7093 __pyx_t_1
= ((PyObject
*)__pyx_f_5MACS2_6Signal_savitzky_golay(__pyx_v_y
, __pyx_v_window_size
, __pyx_v_order
, 0, &__pyx_t_2
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 267, __pyx_L1_error
)
7094 __Pyx_GOTREF(__pyx_t_1
);
7095 __pyx_r
= __pyx_t_1
;
7099 /* function exit code */
7101 __Pyx_XDECREF(__pyx_t_1
);
7102 { PyObject
*__pyx_type
, *__pyx_value
, *__pyx_tb
;
7103 __Pyx_PyThreadState_declare
7104 __Pyx_PyThreadState_assign
7105 __Pyx_ErrFetch(&__pyx_type
, &__pyx_value
, &__pyx_tb
);
7106 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
);
7107 __Pyx_ErrRestore(__pyx_type
, __pyx_value
, __pyx_tb
);}
7108 __Pyx_AddTraceback("MACS2.Signal.savitzky_golay", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
7112 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y
.rcbuffer
->pybuffer
);
7114 __Pyx_XGIVEREF(__pyx_r
);
7115 __Pyx_TraceReturn(__pyx_r
, 0);
7116 __Pyx_RefNannyFinishContext();
7120 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":258
7121 * # experimental exception made for __getbuffer__ and __releasebuffer__
7122 * # -- the details of this may change.
7123 * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
7124 * # This implementation of getbuffer is geared towards Cython
7125 * # requirements, and does not yet fulfill the PEP.
7128 /* Python wrapper */
7129 static CYTHON_UNUSED
int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
, int __pyx_v_flags
); /*proto*/
7130 static CYTHON_UNUSED
int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
, int __pyx_v_flags
) {
7132 __Pyx_RefNannyDeclarations
7133 __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
7134 __pyx_r
= __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject
*)__pyx_v_self
), ((Py_buffer
*)__pyx_v_info
), ((int)__pyx_v_flags
));
7136 /* function exit code */
7137 __Pyx_RefNannyFinishContext();
7141 static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
, int __pyx_v_flags
) {
7144 int __pyx_v_endian_detector
;
7145 int __pyx_v_little_endian
;
7148 PyArray_Descr
*__pyx_v_descr
= 0;
7151 __Pyx_TraceDeclarations
7152 __Pyx_RefNannyDeclarations
7155 PyObject
*__pyx_t_3
= NULL
;
7159 PyArray_Descr
*__pyx_t_7
;
7160 PyObject
*__pyx_t_8
= NULL
;
7162 if (__pyx_v_info
== NULL
) {
7163 PyErr_SetString(PyExc_BufferError
, "PyObject_GetBuffer: view==NULL argument is obsolete");
7166 __Pyx_RefNannySetupContext("__getbuffer__", 0);
7167 __pyx_v_info
->obj
= Py_None
; __Pyx_INCREF(Py_None
);
7168 __Pyx_GIVEREF(__pyx_v_info
->obj
);
7169 __Pyx_TraceCall("__getbuffer__", __pyx_f
[1], 258, 0, __PYX_ERR(1, 258, __pyx_L1_error
));
7171 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":265
7174 * cdef int endian_detector = 1 # <<<<<<<<<<<<<<
7175 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
7178 __pyx_v_endian_detector
= 1;
7180 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":266
7182 * cdef int endian_detector = 1
7183 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<<
7185 * ndim = PyArray_NDIM(self)
7187 __pyx_v_little_endian
= ((((char *)(&__pyx_v_endian_detector
))[0]) != 0);
7189 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":268
7190 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
7192 * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<<
7194 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
7196 __pyx_v_ndim
= PyArray_NDIM(__pyx_v_self
);
7198 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":270
7199 * ndim = PyArray_NDIM(self)
7201 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
7202 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
7203 * raise ValueError(u"ndarray is not C contiguous")
7205 __pyx_t_2
= (((__pyx_v_flags
& PyBUF_C_CONTIGUOUS
) == PyBUF_C_CONTIGUOUS
) != 0);
7208 __pyx_t_1
= __pyx_t_2
;
7209 goto __pyx_L4_bool_binop_done
;
7212 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":271
7214 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
7215 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): # <<<<<<<<<<<<<<
7216 * raise ValueError(u"ndarray is not C contiguous")
7219 __pyx_t_2
= ((!(PyArray_CHKFLAGS(__pyx_v_self
, NPY_ARRAY_C_CONTIGUOUS
) != 0)) != 0);
7220 __pyx_t_1
= __pyx_t_2
;
7221 __pyx_L4_bool_binop_done
:;
7223 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":270
7224 * ndim = PyArray_NDIM(self)
7226 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
7227 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
7228 * raise ValueError(u"ndarray is not C contiguous")
7230 if (unlikely(__pyx_t_1
)) {
7232 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":272
7233 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
7234 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
7235 * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<<
7237 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
7239 __pyx_t_3
= __Pyx_PyObject_Call(__pyx_builtin_ValueError
, __pyx_tuple__6
, NULL
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 272, __pyx_L1_error
)
7240 __Pyx_GOTREF(__pyx_t_3
);
7241 __Pyx_Raise(__pyx_t_3
, 0, 0, 0);
7242 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
7243 __PYX_ERR(1, 272, __pyx_L1_error
)
7245 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":270
7246 * ndim = PyArray_NDIM(self)
7248 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
7249 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
7250 * raise ValueError(u"ndarray is not C contiguous")
7254 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":274
7255 * raise ValueError(u"ndarray is not C contiguous")
7257 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
7258 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
7259 * raise ValueError(u"ndarray is not Fortran contiguous")
7261 __pyx_t_2
= (((__pyx_v_flags
& PyBUF_F_CONTIGUOUS
) == PyBUF_F_CONTIGUOUS
) != 0);
7264 __pyx_t_1
= __pyx_t_2
;
7265 goto __pyx_L7_bool_binop_done
;
7268 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":275
7270 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
7271 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): # <<<<<<<<<<<<<<
7272 * raise ValueError(u"ndarray is not Fortran contiguous")
7275 __pyx_t_2
= ((!(PyArray_CHKFLAGS(__pyx_v_self
, NPY_ARRAY_F_CONTIGUOUS
) != 0)) != 0);
7276 __pyx_t_1
= __pyx_t_2
;
7277 __pyx_L7_bool_binop_done
:;
7279 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":274
7280 * raise ValueError(u"ndarray is not C contiguous")
7282 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
7283 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
7284 * raise ValueError(u"ndarray is not Fortran contiguous")
7286 if (unlikely(__pyx_t_1
)) {
7288 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":276
7289 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
7290 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
7291 * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<<
7293 * info.buf = PyArray_DATA(self)
7295 __pyx_t_3
= __Pyx_PyObject_Call(__pyx_builtin_ValueError
, __pyx_tuple__7
, NULL
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 276, __pyx_L1_error
)
7296 __Pyx_GOTREF(__pyx_t_3
);
7297 __Pyx_Raise(__pyx_t_3
, 0, 0, 0);
7298 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
7299 __PYX_ERR(1, 276, __pyx_L1_error
)
7301 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":274
7302 * raise ValueError(u"ndarray is not C contiguous")
7304 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
7305 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
7306 * raise ValueError(u"ndarray is not Fortran contiguous")
7310 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":278
7311 * raise ValueError(u"ndarray is not Fortran contiguous")
7313 * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<<
7315 * if sizeof(npy_intp) != sizeof(Py_ssize_t):
7317 __pyx_v_info
->buf
= PyArray_DATA(__pyx_v_self
);
7319 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":279
7321 * info.buf = PyArray_DATA(self)
7322 * info.ndim = ndim # <<<<<<<<<<<<<<
7323 * if sizeof(npy_intp) != sizeof(Py_ssize_t):
7324 * # Allocate new buffer for strides and shape info.
7326 __pyx_v_info
->ndim
= __pyx_v_ndim
;
7328 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":280
7329 * info.buf = PyArray_DATA(self)
7331 * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
7332 * # Allocate new buffer for strides and shape info.
7333 * # This is allocated as one block, strides first.
7335 __pyx_t_1
= (((sizeof(npy_intp
)) != (sizeof(Py_ssize_t
))) != 0);
7338 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":283
7339 * # Allocate new buffer for strides and shape info.
7340 * # This is allocated as one block, strides first.
7341 * info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim) # <<<<<<<<<<<<<<
7342 * info.shape = info.strides + ndim
7343 * for i in range(ndim):
7345 __pyx_v_info
->strides
= ((Py_ssize_t
*)PyObject_Malloc((((sizeof(Py_ssize_t
)) * 2) * ((size_t)__pyx_v_ndim
))));
7347 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":284
7348 * # This is allocated as one block, strides first.
7349 * info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim)
7350 * info.shape = info.strides + ndim # <<<<<<<<<<<<<<
7351 * for i in range(ndim):
7352 * info.strides[i] = PyArray_STRIDES(self)[i]
7354 __pyx_v_info
->shape
= (__pyx_v_info
->strides
+ __pyx_v_ndim
);
7356 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":285
7357 * info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim)
7358 * info.shape = info.strides + ndim
7359 * for i in range(ndim): # <<<<<<<<<<<<<<
7360 * info.strides[i] = PyArray_STRIDES(self)[i]
7361 * info.shape[i] = PyArray_DIMS(self)[i]
7363 __pyx_t_4
= __pyx_v_ndim
;
7364 __pyx_t_5
= __pyx_t_4
;
7365 for (__pyx_t_6
= 0; __pyx_t_6
< __pyx_t_5
; __pyx_t_6
+=1) {
7366 __pyx_v_i
= __pyx_t_6
;
7368 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":286
7369 * info.shape = info.strides + ndim
7370 * for i in range(ndim):
7371 * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<<
7372 * info.shape[i] = PyArray_DIMS(self)[i]
7375 (__pyx_v_info
->strides
[__pyx_v_i
]) = (PyArray_STRIDES(__pyx_v_self
)[__pyx_v_i
]);
7377 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":287
7378 * for i in range(ndim):
7379 * info.strides[i] = PyArray_STRIDES(self)[i]
7380 * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<<
7382 * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
7384 (__pyx_v_info
->shape
[__pyx_v_i
]) = (PyArray_DIMS(__pyx_v_self
)[__pyx_v_i
]);
7387 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":280
7388 * info.buf = PyArray_DATA(self)
7390 * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
7391 * # Allocate new buffer for strides and shape info.
7392 * # This is allocated as one block, strides first.
7397 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":289
7398 * info.shape[i] = PyArray_DIMS(self)[i]
7400 * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) # <<<<<<<<<<<<<<
7401 * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
7402 * info.suboffsets = NULL
7405 __pyx_v_info
->strides
= ((Py_ssize_t
*)PyArray_STRIDES(__pyx_v_self
));
7407 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":290
7409 * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
7410 * info.shape = <Py_ssize_t*>PyArray_DIMS(self) # <<<<<<<<<<<<<<
7411 * info.suboffsets = NULL
7412 * info.itemsize = PyArray_ITEMSIZE(self)
7414 __pyx_v_info
->shape
= ((Py_ssize_t
*)PyArray_DIMS(__pyx_v_self
));
7418 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":291
7419 * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
7420 * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
7421 * info.suboffsets = NULL # <<<<<<<<<<<<<<
7422 * info.itemsize = PyArray_ITEMSIZE(self)
7423 * info.readonly = not PyArray_ISWRITEABLE(self)
7425 __pyx_v_info
->suboffsets
= NULL
;
7427 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":292
7428 * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
7429 * info.suboffsets = NULL
7430 * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<<
7431 * info.readonly = not PyArray_ISWRITEABLE(self)
7434 __pyx_v_info
->itemsize
= PyArray_ITEMSIZE(__pyx_v_self
);
7436 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":293
7437 * info.suboffsets = NULL
7438 * info.itemsize = PyArray_ITEMSIZE(self)
7439 * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<<
7443 __pyx_v_info
->readonly
= (!(PyArray_ISWRITEABLE(__pyx_v_self
) != 0));
7445 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":296
7448 * cdef char* f = NULL # <<<<<<<<<<<<<<
7449 * cdef dtype descr = <dtype>PyArray_DESCR(self)
7454 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":297
7456 * cdef char* f = NULL
7457 * cdef dtype descr = <dtype>PyArray_DESCR(self) # <<<<<<<<<<<<<<
7461 __pyx_t_7
= PyArray_DESCR(__pyx_v_self
);
7462 __pyx_t_3
= ((PyObject
*)__pyx_t_7
);
7463 __Pyx_INCREF(__pyx_t_3
);
7464 __pyx_v_descr
= ((PyArray_Descr
*)__pyx_t_3
);
7467 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":300
7470 * info.obj = self # <<<<<<<<<<<<<<
7472 * if not PyDataType_HASFIELDS(descr):
7474 __Pyx_INCREF(((PyObject
*)__pyx_v_self
));
7475 __Pyx_GIVEREF(((PyObject
*)__pyx_v_self
));
7476 __Pyx_GOTREF(__pyx_v_info
->obj
);
7477 __Pyx_DECREF(__pyx_v_info
->obj
);
7478 __pyx_v_info
->obj
= ((PyObject
*)__pyx_v_self
);
7480 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":302
7483 * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<<
7484 * t = descr.type_num
7485 * if ((descr.byteorder == c'>' and little_endian) or
7487 __pyx_t_1
= ((!(PyDataType_HASFIELDS(__pyx_v_descr
) != 0)) != 0);
7490 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":303
7492 * if not PyDataType_HASFIELDS(descr):
7493 * t = descr.type_num # <<<<<<<<<<<<<<
7494 * if ((descr.byteorder == c'>' and little_endian) or
7495 * (descr.byteorder == c'<' and not little_endian)):
7497 __pyx_t_4
= __pyx_v_descr
->type_num
;
7498 __pyx_v_t
= __pyx_t_4
;
7500 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":304
7501 * if not PyDataType_HASFIELDS(descr):
7502 * t = descr.type_num
7503 * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
7504 * (descr.byteorder == c'<' and not little_endian)):
7505 * raise ValueError(u"Non-native byte order not supported")
7507 __pyx_t_2
= ((__pyx_v_descr
->byteorder
== '>') != 0);
7509 goto __pyx_L15_next_or
;
7512 __pyx_t_2
= (__pyx_v_little_endian
!= 0);
7515 __pyx_t_1
= __pyx_t_2
;
7516 goto __pyx_L14_bool_binop_done
;
7520 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":305
7521 * t = descr.type_num
7522 * if ((descr.byteorder == c'>' and little_endian) or
7523 * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<<
7524 * raise ValueError(u"Non-native byte order not supported")
7525 * if t == NPY_BYTE: f = "b"
7527 __pyx_t_2
= ((__pyx_v_descr
->byteorder
== '<') != 0);
7530 __pyx_t_1
= __pyx_t_2
;
7531 goto __pyx_L14_bool_binop_done
;
7533 __pyx_t_2
= ((!(__pyx_v_little_endian
!= 0)) != 0);
7534 __pyx_t_1
= __pyx_t_2
;
7535 __pyx_L14_bool_binop_done
:;
7537 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":304
7538 * if not PyDataType_HASFIELDS(descr):
7539 * t = descr.type_num
7540 * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
7541 * (descr.byteorder == c'<' and not little_endian)):
7542 * raise ValueError(u"Non-native byte order not supported")
7544 if (unlikely(__pyx_t_1
)) {
7546 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":306
7547 * if ((descr.byteorder == c'>' and little_endian) or
7548 * (descr.byteorder == c'<' and not little_endian)):
7549 * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
7550 * if t == NPY_BYTE: f = "b"
7551 * elif t == NPY_UBYTE: f = "B"
7553 __pyx_t_3
= __Pyx_PyObject_Call(__pyx_builtin_ValueError
, __pyx_tuple__8
, NULL
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 306, __pyx_L1_error
)
7554 __Pyx_GOTREF(__pyx_t_3
);
7555 __Pyx_Raise(__pyx_t_3
, 0, 0, 0);
7556 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
7557 __PYX_ERR(1, 306, __pyx_L1_error
)
7559 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":304
7560 * if not PyDataType_HASFIELDS(descr):
7561 * t = descr.type_num
7562 * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
7563 * (descr.byteorder == c'<' and not little_endian)):
7564 * raise ValueError(u"Non-native byte order not supported")
7568 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":307
7569 * (descr.byteorder == c'<' and not little_endian)):
7570 * raise ValueError(u"Non-native byte order not supported")
7571 * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<<
7572 * elif t == NPY_UBYTE: f = "B"
7573 * elif t == NPY_SHORT: f = "h"
7575 switch (__pyx_v_t
) {
7577 __pyx_v_f
= ((char *)"b");
7581 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":308
7582 * raise ValueError(u"Non-native byte order not supported")
7583 * if t == NPY_BYTE: f = "b"
7584 * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<<
7585 * elif t == NPY_SHORT: f = "h"
7586 * elif t == NPY_USHORT: f = "H"
7588 __pyx_v_f
= ((char *)"B");
7592 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":309
7593 * if t == NPY_BYTE: f = "b"
7594 * elif t == NPY_UBYTE: f = "B"
7595 * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<<
7596 * elif t == NPY_USHORT: f = "H"
7597 * elif t == NPY_INT: f = "i"
7599 __pyx_v_f
= ((char *)"h");
7603 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":310
7604 * elif t == NPY_UBYTE: f = "B"
7605 * elif t == NPY_SHORT: f = "h"
7606 * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<<
7607 * elif t == NPY_INT: f = "i"
7608 * elif t == NPY_UINT: f = "I"
7610 __pyx_v_f
= ((char *)"H");
7614 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":311
7615 * elif t == NPY_SHORT: f = "h"
7616 * elif t == NPY_USHORT: f = "H"
7617 * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<<
7618 * elif t == NPY_UINT: f = "I"
7619 * elif t == NPY_LONG: f = "l"
7621 __pyx_v_f
= ((char *)"i");
7625 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":312
7626 * elif t == NPY_USHORT: f = "H"
7627 * elif t == NPY_INT: f = "i"
7628 * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<<
7629 * elif t == NPY_LONG: f = "l"
7630 * elif t == NPY_ULONG: f = "L"
7632 __pyx_v_f
= ((char *)"I");
7636 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":313
7637 * elif t == NPY_INT: f = "i"
7638 * elif t == NPY_UINT: f = "I"
7639 * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<<
7640 * elif t == NPY_ULONG: f = "L"
7641 * elif t == NPY_LONGLONG: f = "q"
7643 __pyx_v_f
= ((char *)"l");
7647 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":314
7648 * elif t == NPY_UINT: f = "I"
7649 * elif t == NPY_LONG: f = "l"
7650 * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<<
7651 * elif t == NPY_LONGLONG: f = "q"
7652 * elif t == NPY_ULONGLONG: f = "Q"
7654 __pyx_v_f
= ((char *)"L");
7658 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":315
7659 * elif t == NPY_LONG: f = "l"
7660 * elif t == NPY_ULONG: f = "L"
7661 * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<<
7662 * elif t == NPY_ULONGLONG: f = "Q"
7663 * elif t == NPY_FLOAT: f = "f"
7665 __pyx_v_f
= ((char *)"q");
7669 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":316
7670 * elif t == NPY_ULONG: f = "L"
7671 * elif t == NPY_LONGLONG: f = "q"
7672 * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<<
7673 * elif t == NPY_FLOAT: f = "f"
7674 * elif t == NPY_DOUBLE: f = "d"
7676 __pyx_v_f
= ((char *)"Q");
7680 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":317
7681 * elif t == NPY_LONGLONG: f = "q"
7682 * elif t == NPY_ULONGLONG: f = "Q"
7683 * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<<
7684 * elif t == NPY_DOUBLE: f = "d"
7685 * elif t == NPY_LONGDOUBLE: f = "g"
7687 __pyx_v_f
= ((char *)"f");
7691 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":318
7692 * elif t == NPY_ULONGLONG: f = "Q"
7693 * elif t == NPY_FLOAT: f = "f"
7694 * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<<
7695 * elif t == NPY_LONGDOUBLE: f = "g"
7696 * elif t == NPY_CFLOAT: f = "Zf"
7698 __pyx_v_f
= ((char *)"d");
7700 case NPY_LONGDOUBLE
:
7702 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":319
7703 * elif t == NPY_FLOAT: f = "f"
7704 * elif t == NPY_DOUBLE: f = "d"
7705 * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<<
7706 * elif t == NPY_CFLOAT: f = "Zf"
7707 * elif t == NPY_CDOUBLE: f = "Zd"
7709 __pyx_v_f
= ((char *)"g");
7713 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":320
7714 * elif t == NPY_DOUBLE: f = "d"
7715 * elif t == NPY_LONGDOUBLE: f = "g"
7716 * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<<
7717 * elif t == NPY_CDOUBLE: f = "Zd"
7718 * elif t == NPY_CLONGDOUBLE: f = "Zg"
7720 __pyx_v_f
= ((char *)"Zf");
7724 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":321
7725 * elif t == NPY_LONGDOUBLE: f = "g"
7726 * elif t == NPY_CFLOAT: f = "Zf"
7727 * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<<
7728 * elif t == NPY_CLONGDOUBLE: f = "Zg"
7729 * elif t == NPY_OBJECT: f = "O"
7731 __pyx_v_f
= ((char *)"Zd");
7733 case NPY_CLONGDOUBLE
:
7735 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":322
7736 * elif t == NPY_CFLOAT: f = "Zf"
7737 * elif t == NPY_CDOUBLE: f = "Zd"
7738 * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<<
7739 * elif t == NPY_OBJECT: f = "O"
7742 __pyx_v_f
= ((char *)"Zg");
7746 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":323
7747 * elif t == NPY_CDOUBLE: f = "Zd"
7748 * elif t == NPY_CLONGDOUBLE: f = "Zg"
7749 * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<<
7751 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
7753 __pyx_v_f
= ((char *)"O");
7757 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":325
7758 * elif t == NPY_OBJECT: f = "O"
7760 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<<
7764 __pyx_t_3
= __Pyx_PyInt_From_int(__pyx_v_t
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 325, __pyx_L1_error
)
7765 __Pyx_GOTREF(__pyx_t_3
);
7766 __pyx_t_8
= PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd
, __pyx_t_3
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(1, 325, __pyx_L1_error
)
7767 __Pyx_GOTREF(__pyx_t_8
);
7768 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
7769 __pyx_t_3
= __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError
, __pyx_t_8
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 325, __pyx_L1_error
)
7770 __Pyx_GOTREF(__pyx_t_3
);
7771 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
7772 __Pyx_Raise(__pyx_t_3
, 0, 0, 0);
7773 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
7774 __PYX_ERR(1, 325, __pyx_L1_error
)
7778 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":326
7780 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
7781 * info.format = f # <<<<<<<<<<<<<<
7785 __pyx_v_info
->format
= __pyx_v_f
;
7787 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":327
7788 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
7790 * return # <<<<<<<<<<<<<<
7792 * info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
7797 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":302
7800 * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<<
7801 * t = descr.type_num
7802 * if ((descr.byteorder == c'>' and little_endian) or
7806 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":329
7809 * info.format = <char*>PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<<
7810 * info.format[0] = c'^' # Native data types, manual alignment
7814 __pyx_v_info
->format
= ((char *)PyObject_Malloc(0xFF));
7816 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":330
7818 * info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
7819 * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<<
7821 * f = _util_dtypestring(descr, info.format + 1,
7823 (__pyx_v_info
->format
[0]) = '^';
7825 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":331
7826 * info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
7827 * info.format[0] = c'^' # Native data types, manual alignment
7828 * offset = 0 # <<<<<<<<<<<<<<
7829 * f = _util_dtypestring(descr, info.format + 1,
7830 * info.format + _buffer_format_string_len,
7834 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":332
7835 * info.format[0] = c'^' # Native data types, manual alignment
7837 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<<
7838 * info.format + _buffer_format_string_len,
7841 __pyx_t_9
= __pyx_f_5numpy__util_dtypestring(__pyx_v_descr
, (__pyx_v_info
->format
+ 1), (__pyx_v_info
->format
+ 0xFF), (&__pyx_v_offset
)); if (unlikely(__pyx_t_9
== ((char *)NULL
))) __PYX_ERR(1, 332, __pyx_L1_error
)
7842 __pyx_v_f
= __pyx_t_9
;
7844 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":335
7845 * info.format + _buffer_format_string_len,
7847 * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<<
7849 * def __releasebuffer__(ndarray self, Py_buffer* info):
7851 (__pyx_v_f
[0]) = '\x00';
7854 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":258
7855 * # experimental exception made for __getbuffer__ and __releasebuffer__
7856 * # -- the details of this may change.
7857 * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
7858 * # This implementation of getbuffer is geared towards Cython
7859 * # requirements, and does not yet fulfill the PEP.
7862 /* function exit code */
7866 __Pyx_XDECREF(__pyx_t_3
);
7867 __Pyx_XDECREF(__pyx_t_8
);
7868 __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
7870 if (__pyx_v_info
->obj
!= NULL
) {
7871 __Pyx_GOTREF(__pyx_v_info
->obj
);
7872 __Pyx_DECREF(__pyx_v_info
->obj
); __pyx_v_info
->obj
= 0;
7876 if (__pyx_v_info
->obj
== Py_None
) {
7877 __Pyx_GOTREF(__pyx_v_info
->obj
);
7878 __Pyx_DECREF(__pyx_v_info
->obj
); __pyx_v_info
->obj
= 0;
7881 __Pyx_XDECREF((PyObject
*)__pyx_v_descr
);
7882 __Pyx_TraceReturn(Py_None
, 0);
7883 __Pyx_RefNannyFinishContext();
7887 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":337
7888 * f[0] = c'\0' # Terminate format string
7890 * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
7891 * if PyArray_HASFIELDS(self):
7892 * PyObject_Free(info.format)
7895 /* Python wrapper */
7896 static CYTHON_UNUSED
void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
); /*proto*/
7897 static CYTHON_UNUSED
void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
) {
7898 __Pyx_RefNannyDeclarations
7899 __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
7900 __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject
*)__pyx_v_self
), ((Py_buffer
*)__pyx_v_info
));
7902 /* function exit code */
7903 __Pyx_RefNannyFinishContext();
7906 static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject
*__pyx_v_self
, Py_buffer
*__pyx_v_info
) {
7907 __Pyx_TraceDeclarations
7908 __Pyx_RefNannyDeclarations
7910 __Pyx_RefNannySetupContext("__releasebuffer__", 0);
7911 __Pyx_TraceCall("__releasebuffer__", __pyx_f
[1], 337, 0, __PYX_ERR(1, 337, __pyx_L1_error
));
7913 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":338
7915 * def __releasebuffer__(ndarray self, Py_buffer* info):
7916 * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
7917 * PyObject_Free(info.format)
7918 * if sizeof(npy_intp) != sizeof(Py_ssize_t):
7920 __pyx_t_1
= (PyArray_HASFIELDS(__pyx_v_self
) != 0);
7923 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":339
7924 * def __releasebuffer__(ndarray self, Py_buffer* info):
7925 * if PyArray_HASFIELDS(self):
7926 * PyObject_Free(info.format) # <<<<<<<<<<<<<<
7927 * if sizeof(npy_intp) != sizeof(Py_ssize_t):
7928 * PyObject_Free(info.strides)
7930 PyObject_Free(__pyx_v_info
->format
);
7932 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":338
7934 * def __releasebuffer__(ndarray self, Py_buffer* info):
7935 * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
7936 * PyObject_Free(info.format)
7937 * if sizeof(npy_intp) != sizeof(Py_ssize_t):
7941 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":340
7942 * if PyArray_HASFIELDS(self):
7943 * PyObject_Free(info.format)
7944 * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
7945 * PyObject_Free(info.strides)
7946 * # info.shape was stored after info.strides in the same block
7948 __pyx_t_1
= (((sizeof(npy_intp
)) != (sizeof(Py_ssize_t
))) != 0);
7951 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":341
7952 * PyObject_Free(info.format)
7953 * if sizeof(npy_intp) != sizeof(Py_ssize_t):
7954 * PyObject_Free(info.strides) # <<<<<<<<<<<<<<
7955 * # info.shape was stored after info.strides in the same block
7958 PyObject_Free(__pyx_v_info
->strides
);
7960 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":340
7961 * if PyArray_HASFIELDS(self):
7962 * PyObject_Free(info.format)
7963 * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
7964 * PyObject_Free(info.strides)
7965 * # info.shape was stored after info.strides in the same block
7969 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":337
7970 * f[0] = c'\0' # Terminate format string
7972 * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
7973 * if PyArray_HASFIELDS(self):
7974 * PyObject_Free(info.format)
7977 /* function exit code */
7980 __Pyx_WriteUnraisable("numpy.ndarray.__releasebuffer__", __pyx_clineno
, __pyx_lineno
, __pyx_filename
, 1, 0);
7982 __Pyx_TraceReturn(Py_None
, 0);
7983 __Pyx_RefNannyFinishContext();
7986 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":821
7987 * ctypedef npy_cdouble complex_t
7989 * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
7990 * return PyArray_MultiIterNew(1, <void*>a)
7994 static CYTHON_INLINE PyObject
*__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject
*__pyx_v_a
) {
7995 PyObject
*__pyx_r
= NULL
;
7996 __Pyx_TraceDeclarations
7997 __Pyx_RefNannyDeclarations
7998 PyObject
*__pyx_t_1
= NULL
;
7999 __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
8000 __Pyx_TraceCall("PyArray_MultiIterNew1", __pyx_f
[1], 821, 0, __PYX_ERR(1, 821, __pyx_L1_error
));
8002 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":822
8004 * cdef inline object PyArray_MultiIterNew1(a):
8005 * return PyArray_MultiIterNew(1, <void*>a) # <<<<<<<<<<<<<<
8007 * cdef inline object PyArray_MultiIterNew2(a, b):
8009 __Pyx_XDECREF(__pyx_r
);
8010 __pyx_t_1
= PyArray_MultiIterNew(1, ((void *)__pyx_v_a
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(1, 822, __pyx_L1_error
)
8011 __Pyx_GOTREF(__pyx_t_1
);
8012 __pyx_r
= __pyx_t_1
;
8016 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":821
8017 * ctypedef npy_cdouble complex_t
8019 * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
8020 * return PyArray_MultiIterNew(1, <void*>a)
8024 /* function exit code */
8026 __Pyx_XDECREF(__pyx_t_1
);
8027 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
8030 __Pyx_XGIVEREF(__pyx_r
);
8031 __Pyx_TraceReturn(__pyx_r
, 0);
8032 __Pyx_RefNannyFinishContext();
8036 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":824
8037 * return PyArray_MultiIterNew(1, <void*>a)
8039 * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
8040 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8044 static CYTHON_INLINE PyObject
*__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject
*__pyx_v_a
, PyObject
*__pyx_v_b
) {
8045 PyObject
*__pyx_r
= NULL
;
8046 __Pyx_TraceDeclarations
8047 __Pyx_RefNannyDeclarations
8048 PyObject
*__pyx_t_1
= NULL
;
8049 __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
8050 __Pyx_TraceCall("PyArray_MultiIterNew2", __pyx_f
[1], 824, 0, __PYX_ERR(1, 824, __pyx_L1_error
));
8052 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":825
8054 * cdef inline object PyArray_MultiIterNew2(a, b):
8055 * return PyArray_MultiIterNew(2, <void*>a, <void*>b) # <<<<<<<<<<<<<<
8057 * cdef inline object PyArray_MultiIterNew3(a, b, c):
8059 __Pyx_XDECREF(__pyx_r
);
8060 __pyx_t_1
= PyArray_MultiIterNew(2, ((void *)__pyx_v_a
), ((void *)__pyx_v_b
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(1, 825, __pyx_L1_error
)
8061 __Pyx_GOTREF(__pyx_t_1
);
8062 __pyx_r
= __pyx_t_1
;
8066 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":824
8067 * return PyArray_MultiIterNew(1, <void*>a)
8069 * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
8070 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8074 /* function exit code */
8076 __Pyx_XDECREF(__pyx_t_1
);
8077 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
8080 __Pyx_XGIVEREF(__pyx_r
);
8081 __Pyx_TraceReturn(__pyx_r
, 0);
8082 __Pyx_RefNannyFinishContext();
8086 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":827
8087 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8089 * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
8090 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
8094 static CYTHON_INLINE PyObject
*__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject
*__pyx_v_a
, PyObject
*__pyx_v_b
, PyObject
*__pyx_v_c
) {
8095 PyObject
*__pyx_r
= NULL
;
8096 __Pyx_TraceDeclarations
8097 __Pyx_RefNannyDeclarations
8098 PyObject
*__pyx_t_1
= NULL
;
8099 __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
8100 __Pyx_TraceCall("PyArray_MultiIterNew3", __pyx_f
[1], 827, 0, __PYX_ERR(1, 827, __pyx_L1_error
));
8102 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":828
8104 * cdef inline object PyArray_MultiIterNew3(a, b, c):
8105 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) # <<<<<<<<<<<<<<
8107 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
8109 __Pyx_XDECREF(__pyx_r
);
8110 __pyx_t_1
= PyArray_MultiIterNew(3, ((void *)__pyx_v_a
), ((void *)__pyx_v_b
), ((void *)__pyx_v_c
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(1, 828, __pyx_L1_error
)
8111 __Pyx_GOTREF(__pyx_t_1
);
8112 __pyx_r
= __pyx_t_1
;
8116 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":827
8117 * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8119 * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
8120 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
8124 /* function exit code */
8126 __Pyx_XDECREF(__pyx_t_1
);
8127 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
8130 __Pyx_XGIVEREF(__pyx_r
);
8131 __Pyx_TraceReturn(__pyx_r
, 0);
8132 __Pyx_RefNannyFinishContext();
8136 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":830
8137 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
8139 * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
8140 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
8144 static CYTHON_INLINE PyObject
*__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject
*__pyx_v_a
, PyObject
*__pyx_v_b
, PyObject
*__pyx_v_c
, PyObject
*__pyx_v_d
) {
8145 PyObject
*__pyx_r
= NULL
;
8146 __Pyx_TraceDeclarations
8147 __Pyx_RefNannyDeclarations
8148 PyObject
*__pyx_t_1
= NULL
;
8149 __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
8150 __Pyx_TraceCall("PyArray_MultiIterNew4", __pyx_f
[1], 830, 0, __PYX_ERR(1, 830, __pyx_L1_error
));
8152 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":831
8154 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
8155 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) # <<<<<<<<<<<<<<
8157 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
8159 __Pyx_XDECREF(__pyx_r
);
8160 __pyx_t_1
= PyArray_MultiIterNew(4, ((void *)__pyx_v_a
), ((void *)__pyx_v_b
), ((void *)__pyx_v_c
), ((void *)__pyx_v_d
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(1, 831, __pyx_L1_error
)
8161 __Pyx_GOTREF(__pyx_t_1
);
8162 __pyx_r
= __pyx_t_1
;
8166 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":830
8167 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
8169 * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
8170 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
8174 /* function exit code */
8176 __Pyx_XDECREF(__pyx_t_1
);
8177 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
8180 __Pyx_XGIVEREF(__pyx_r
);
8181 __Pyx_TraceReturn(__pyx_r
, 0);
8182 __Pyx_RefNannyFinishContext();
8186 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":833
8187 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
8189 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
8190 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
8194 static CYTHON_INLINE PyObject
*__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject
*__pyx_v_a
, PyObject
*__pyx_v_b
, PyObject
*__pyx_v_c
, PyObject
*__pyx_v_d
, PyObject
*__pyx_v_e
) {
8195 PyObject
*__pyx_r
= NULL
;
8196 __Pyx_TraceDeclarations
8197 __Pyx_RefNannyDeclarations
8198 PyObject
*__pyx_t_1
= NULL
;
8199 __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
8200 __Pyx_TraceCall("PyArray_MultiIterNew5", __pyx_f
[1], 833, 0, __PYX_ERR(1, 833, __pyx_L1_error
));
8202 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":834
8204 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
8205 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) # <<<<<<<<<<<<<<
8207 * cdef inline tuple PyDataType_SHAPE(dtype d):
8209 __Pyx_XDECREF(__pyx_r
);
8210 __pyx_t_1
= PyArray_MultiIterNew(5, ((void *)__pyx_v_a
), ((void *)__pyx_v_b
), ((void *)__pyx_v_c
), ((void *)__pyx_v_d
), ((void *)__pyx_v_e
)); if (unlikely(!__pyx_t_1
)) __PYX_ERR(1, 834, __pyx_L1_error
)
8211 __Pyx_GOTREF(__pyx_t_1
);
8212 __pyx_r
= __pyx_t_1
;
8216 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":833
8217 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
8219 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
8220 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
8224 /* function exit code */
8226 __Pyx_XDECREF(__pyx_t_1
);
8227 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
8230 __Pyx_XGIVEREF(__pyx_r
);
8231 __Pyx_TraceReturn(__pyx_r
, 0);
8232 __Pyx_RefNannyFinishContext();
8236 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":836
8237 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
8239 * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<<
8240 * if PyDataType_HASSUBARRAY(d):
8241 * return <tuple>d.subarray.shape
8244 static CYTHON_INLINE PyObject
*__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr
*__pyx_v_d
) {
8245 PyObject
*__pyx_r
= NULL
;
8246 __Pyx_TraceDeclarations
8247 __Pyx_RefNannyDeclarations
8249 __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
8250 __Pyx_TraceCall("PyDataType_SHAPE", __pyx_f
[1], 836, 0, __PYX_ERR(1, 836, __pyx_L1_error
));
8252 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":837
8254 * cdef inline tuple PyDataType_SHAPE(dtype d):
8255 * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<<
8256 * return <tuple>d.subarray.shape
8259 __pyx_t_1
= (PyDataType_HASSUBARRAY(__pyx_v_d
) != 0);
8262 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":838
8263 * cdef inline tuple PyDataType_SHAPE(dtype d):
8264 * if PyDataType_HASSUBARRAY(d):
8265 * return <tuple>d.subarray.shape # <<<<<<<<<<<<<<
8269 __Pyx_XDECREF(__pyx_r
);
8270 __Pyx_INCREF(((PyObject
*)__pyx_v_d
->subarray
->shape
));
8271 __pyx_r
= ((PyObject
*)__pyx_v_d
->subarray
->shape
);
8274 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":837
8276 * cdef inline tuple PyDataType_SHAPE(dtype d):
8277 * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<<
8278 * return <tuple>d.subarray.shape
8283 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":840
8284 * return <tuple>d.subarray.shape
8286 * return () # <<<<<<<<<<<<<<
8288 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
8291 __Pyx_XDECREF(__pyx_r
);
8292 __Pyx_INCREF(__pyx_empty_tuple
);
8293 __pyx_r
= __pyx_empty_tuple
;
8297 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":836
8298 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
8300 * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<<
8301 * if PyDataType_HASSUBARRAY(d):
8302 * return <tuple>d.subarray.shape
8305 /* function exit code */
8307 __Pyx_AddTraceback("numpy.PyDataType_SHAPE", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
8310 __Pyx_XGIVEREF(__pyx_r
);
8311 __Pyx_TraceReturn(__pyx_r
, 0);
8312 __Pyx_RefNannyFinishContext();
8316 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":842
8319 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<<
8320 * # Recursive utility function used in __getbuffer__ to get format
8321 * # string. The new location in the format string is returned.
8324 static CYTHON_INLINE
char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr
*__pyx_v_descr
, char *__pyx_v_f
, char *__pyx_v_end
, int *__pyx_v_offset
) {
8325 PyArray_Descr
*__pyx_v_child
= 0;
8326 int __pyx_v_endian_detector
;
8327 int __pyx_v_little_endian
;
8328 PyObject
*__pyx_v_fields
= 0;
8329 PyObject
*__pyx_v_childname
= NULL
;
8330 PyObject
*__pyx_v_new_offset
= NULL
;
8331 PyObject
*__pyx_v_t
= NULL
;
8333 __Pyx_TraceDeclarations
8334 __Pyx_RefNannyDeclarations
8335 PyObject
*__pyx_t_1
= NULL
;
8336 Py_ssize_t __pyx_t_2
;
8337 PyObject
*__pyx_t_3
= NULL
;
8338 PyObject
*__pyx_t_4
= NULL
;
8344 __Pyx_RefNannySetupContext("_util_dtypestring", 0);
8345 __Pyx_TraceCall("_util_dtypestring", __pyx_f
[1], 842, 0, __PYX_ERR(1, 842, __pyx_L1_error
));
8347 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":847
8350 * cdef int endian_detector = 1 # <<<<<<<<<<<<<<
8351 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
8354 __pyx_v_endian_detector
= 1;
8356 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":848
8358 * cdef int endian_detector = 1
8359 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<<
8363 __pyx_v_little_endian
= ((((char *)(&__pyx_v_endian_detector
))[0]) != 0);
8365 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":851
8368 * for childname in descr.names: # <<<<<<<<<<<<<<
8369 * fields = descr.fields[childname]
8370 * child, new_offset = fields
8372 if (unlikely(__pyx_v_descr
->names
== Py_None
)) {
8373 PyErr_SetString(PyExc_TypeError
, "'NoneType' object is not iterable");
8374 __PYX_ERR(1, 851, __pyx_L1_error
)
8376 __pyx_t_1
= __pyx_v_descr
->names
; __Pyx_INCREF(__pyx_t_1
); __pyx_t_2
= 0;
8378 if (__pyx_t_2
>= PyTuple_GET_SIZE(__pyx_t_1
)) break;
8379 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8380 __pyx_t_3
= PyTuple_GET_ITEM(__pyx_t_1
, __pyx_t_2
); __Pyx_INCREF(__pyx_t_3
); __pyx_t_2
++; if (unlikely(0 < 0)) __PYX_ERR(1, 851, __pyx_L1_error
)
8382 __pyx_t_3
= PySequence_ITEM(__pyx_t_1
, __pyx_t_2
); __pyx_t_2
++; if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 851, __pyx_L1_error
)
8383 __Pyx_GOTREF(__pyx_t_3
);
8385 __Pyx_XDECREF_SET(__pyx_v_childname
, __pyx_t_3
);
8388 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":852
8390 * for childname in descr.names:
8391 * fields = descr.fields[childname] # <<<<<<<<<<<<<<
8392 * child, new_offset = fields
8395 if (unlikely(__pyx_v_descr
->fields
== Py_None
)) {
8396 PyErr_SetString(PyExc_TypeError
, "'NoneType' object is not subscriptable");
8397 __PYX_ERR(1, 852, __pyx_L1_error
)
8399 __pyx_t_3
= __Pyx_PyDict_GetItem(__pyx_v_descr
->fields
, __pyx_v_childname
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 852, __pyx_L1_error
)
8400 __Pyx_GOTREF(__pyx_t_3
);
8401 if (!(likely(PyTuple_CheckExact(__pyx_t_3
))||((__pyx_t_3
) == Py_None
)||(PyErr_Format(PyExc_TypeError
, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3
)->tp_name
), 0))) __PYX_ERR(1, 852, __pyx_L1_error
)
8402 __Pyx_XDECREF_SET(__pyx_v_fields
, ((PyObject
*)__pyx_t_3
));
8405 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":853
8406 * for childname in descr.names:
8407 * fields = descr.fields[childname]
8408 * child, new_offset = fields # <<<<<<<<<<<<<<
8410 * if (end - f) - <int>(new_offset - offset[0]) < 15:
8412 if (likely(__pyx_v_fields
!= Py_None
)) {
8413 PyObject
* sequence
= __pyx_v_fields
;
8414 Py_ssize_t size
= __Pyx_PySequence_SIZE(sequence
);
8415 if (unlikely(size
!= 2)) {
8416 if (size
> 2) __Pyx_RaiseTooManyValuesError(2);
8417 else if (size
>= 0) __Pyx_RaiseNeedMoreValuesError(size
);
8418 __PYX_ERR(1, 853, __pyx_L1_error
)
8420 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8421 __pyx_t_3
= PyTuple_GET_ITEM(sequence
, 0);
8422 __pyx_t_4
= PyTuple_GET_ITEM(sequence
, 1);
8423 __Pyx_INCREF(__pyx_t_3
);
8424 __Pyx_INCREF(__pyx_t_4
);
8426 __pyx_t_3
= PySequence_ITEM(sequence
, 0); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 853, __pyx_L1_error
)
8427 __Pyx_GOTREF(__pyx_t_3
);
8428 __pyx_t_4
= PySequence_ITEM(sequence
, 1); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 853, __pyx_L1_error
)
8429 __Pyx_GOTREF(__pyx_t_4
);
8432 __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 853, __pyx_L1_error
)
8434 if (!(likely(((__pyx_t_3
) == Py_None
) || likely(__Pyx_TypeTest(__pyx_t_3
, __pyx_ptype_5numpy_dtype
))))) __PYX_ERR(1, 853, __pyx_L1_error
)
8435 __Pyx_XDECREF_SET(__pyx_v_child
, ((PyArray_Descr
*)__pyx_t_3
));
8437 __Pyx_XDECREF_SET(__pyx_v_new_offset
, __pyx_t_4
);
8440 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":855
8441 * child, new_offset = fields
8443 * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<<
8444 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
8447 __pyx_t_4
= __Pyx_PyInt_From_int((__pyx_v_offset
[0])); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 855, __pyx_L1_error
)
8448 __Pyx_GOTREF(__pyx_t_4
);
8449 __pyx_t_3
= PyNumber_Subtract(__pyx_v_new_offset
, __pyx_t_4
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 855, __pyx_L1_error
)
8450 __Pyx_GOTREF(__pyx_t_3
);
8451 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8452 __pyx_t_5
= __Pyx_PyInt_As_int(__pyx_t_3
); if (unlikely((__pyx_t_5
== (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 855, __pyx_L1_error
)
8453 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8454 __pyx_t_6
= ((((__pyx_v_end
- __pyx_v_f
) - ((int)__pyx_t_5
)) < 15) != 0);
8455 if (unlikely(__pyx_t_6
)) {
8457 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":856
8459 * if (end - f) - <int>(new_offset - offset[0]) < 15:
8460 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<<
8462 * if ((child.byteorder == c'>' and little_endian) or
8464 __pyx_t_3
= __Pyx_PyObject_Call(__pyx_builtin_RuntimeError
, __pyx_tuple__9
, NULL
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 856, __pyx_L1_error
)
8465 __Pyx_GOTREF(__pyx_t_3
);
8466 __Pyx_Raise(__pyx_t_3
, 0, 0, 0);
8467 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8468 __PYX_ERR(1, 856, __pyx_L1_error
)
8470 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":855
8471 * child, new_offset = fields
8473 * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<<
8474 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
8479 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":858
8480 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
8482 * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
8483 * (child.byteorder == c'<' and not little_endian)):
8484 * raise ValueError(u"Non-native byte order not supported")
8486 __pyx_t_7
= ((__pyx_v_child
->byteorder
== '>') != 0);
8488 goto __pyx_L8_next_or
;
8491 __pyx_t_7
= (__pyx_v_little_endian
!= 0);
8494 __pyx_t_6
= __pyx_t_7
;
8495 goto __pyx_L7_bool_binop_done
;
8499 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":859
8501 * if ((child.byteorder == c'>' and little_endian) or
8502 * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<<
8503 * raise ValueError(u"Non-native byte order not supported")
8504 * # One could encode it in the format string and have Cython
8506 __pyx_t_7
= ((__pyx_v_child
->byteorder
== '<') != 0);
8509 __pyx_t_6
= __pyx_t_7
;
8510 goto __pyx_L7_bool_binop_done
;
8512 __pyx_t_7
= ((!(__pyx_v_little_endian
!= 0)) != 0);
8513 __pyx_t_6
= __pyx_t_7
;
8514 __pyx_L7_bool_binop_done
:;
8516 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":858
8517 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
8519 * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
8520 * (child.byteorder == c'<' and not little_endian)):
8521 * raise ValueError(u"Non-native byte order not supported")
8523 if (unlikely(__pyx_t_6
)) {
8525 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":860
8526 * if ((child.byteorder == c'>' and little_endian) or
8527 * (child.byteorder == c'<' and not little_endian)):
8528 * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
8529 * # One could encode it in the format string and have Cython
8530 * # complain instead, BUT: < and > in format strings also imply
8532 __pyx_t_3
= __Pyx_PyObject_Call(__pyx_builtin_ValueError
, __pyx_tuple__8
, NULL
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 860, __pyx_L1_error
)
8533 __Pyx_GOTREF(__pyx_t_3
);
8534 __Pyx_Raise(__pyx_t_3
, 0, 0, 0);
8535 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8536 __PYX_ERR(1, 860, __pyx_L1_error
)
8538 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":858
8539 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
8541 * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
8542 * (child.byteorder == c'<' and not little_endian)):
8543 * raise ValueError(u"Non-native byte order not supported")
8547 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":870
8549 * # Output padding bytes
8550 * while offset[0] < new_offset: # <<<<<<<<<<<<<<
8551 * f[0] = 120 # "x"; pad byte
8555 __pyx_t_3
= __Pyx_PyInt_From_int((__pyx_v_offset
[0])); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 870, __pyx_L1_error
)
8556 __Pyx_GOTREF(__pyx_t_3
);
8557 __pyx_t_4
= PyObject_RichCompare(__pyx_t_3
, __pyx_v_new_offset
, Py_LT
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 870, __pyx_L1_error
)
8558 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8559 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 870, __pyx_L1_error
)
8560 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8561 if (!__pyx_t_6
) break;
8563 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":871
8564 * # Output padding bytes
8565 * while offset[0] < new_offset:
8566 * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<<
8570 (__pyx_v_f
[0]) = 0x78;
8572 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":872
8573 * while offset[0] < new_offset:
8574 * f[0] = 120 # "x"; pad byte
8575 * f += 1 # <<<<<<<<<<<<<<
8579 __pyx_v_f
= (__pyx_v_f
+ 1);
8581 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":873
8582 * f[0] = 120 # "x"; pad byte
8584 * offset[0] += 1 # <<<<<<<<<<<<<<
8586 * offset[0] += child.itemsize
8589 (__pyx_v_offset
[__pyx_t_8
]) = ((__pyx_v_offset
[__pyx_t_8
]) + 1);
8592 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":875
8595 * offset[0] += child.itemsize # <<<<<<<<<<<<<<
8597 * if not PyDataType_HASFIELDS(child):
8600 (__pyx_v_offset
[__pyx_t_8
]) = ((__pyx_v_offset
[__pyx_t_8
]) + __pyx_v_child
->elsize
);
8602 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":877
8603 * offset[0] += child.itemsize
8605 * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<<
8606 * t = child.type_num
8609 __pyx_t_6
= ((!(PyDataType_HASFIELDS(__pyx_v_child
) != 0)) != 0);
8612 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":878
8614 * if not PyDataType_HASFIELDS(child):
8615 * t = child.type_num # <<<<<<<<<<<<<<
8617 * raise RuntimeError(u"Format string allocated too short.")
8619 __pyx_t_4
= __Pyx_PyInt_From_int(__pyx_v_child
->type_num
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 878, __pyx_L1_error
)
8620 __Pyx_GOTREF(__pyx_t_4
);
8621 __Pyx_XDECREF_SET(__pyx_v_t
, __pyx_t_4
);
8624 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":879
8625 * if not PyDataType_HASFIELDS(child):
8626 * t = child.type_num
8627 * if end - f < 5: # <<<<<<<<<<<<<<
8628 * raise RuntimeError(u"Format string allocated too short.")
8631 __pyx_t_6
= (((__pyx_v_end
- __pyx_v_f
) < 5) != 0);
8632 if (unlikely(__pyx_t_6
)) {
8634 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":880
8635 * t = child.type_num
8637 * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<<
8639 * # Until ticket #99 is fixed, use integers to avoid warnings
8641 __pyx_t_4
= __Pyx_PyObject_Call(__pyx_builtin_RuntimeError
, __pyx_tuple__10
, NULL
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 880, __pyx_L1_error
)
8642 __Pyx_GOTREF(__pyx_t_4
);
8643 __Pyx_Raise(__pyx_t_4
, 0, 0, 0);
8644 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8645 __PYX_ERR(1, 880, __pyx_L1_error
)
8647 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":879
8648 * if not PyDataType_HASFIELDS(child):
8649 * t = child.type_num
8650 * if end - f < 5: # <<<<<<<<<<<<<<
8651 * raise RuntimeError(u"Format string allocated too short.")
8656 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":883
8658 * # Until ticket #99 is fixed, use integers to avoid warnings
8659 * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<<
8660 * elif t == NPY_UBYTE: f[0] = 66 #"B"
8661 * elif t == NPY_SHORT: f[0] = 104 #"h"
8663 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 883, __pyx_L1_error
)
8664 __Pyx_GOTREF(__pyx_t_4
);
8665 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 883, __pyx_L1_error
)
8666 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8667 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 883, __pyx_L1_error
)
8668 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8670 (__pyx_v_f
[0]) = 98;
8674 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":884
8675 * # Until ticket #99 is fixed, use integers to avoid warnings
8676 * if t == NPY_BYTE: f[0] = 98 #"b"
8677 * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<<
8678 * elif t == NPY_SHORT: f[0] = 104 #"h"
8679 * elif t == NPY_USHORT: f[0] = 72 #"H"
8681 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 884, __pyx_L1_error
)
8682 __Pyx_GOTREF(__pyx_t_3
);
8683 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 884, __pyx_L1_error
)
8684 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8685 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 884, __pyx_L1_error
)
8686 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8688 (__pyx_v_f
[0]) = 66;
8692 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":885
8693 * if t == NPY_BYTE: f[0] = 98 #"b"
8694 * elif t == NPY_UBYTE: f[0] = 66 #"B"
8695 * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<<
8696 * elif t == NPY_USHORT: f[0] = 72 #"H"
8697 * elif t == NPY_INT: f[0] = 105 #"i"
8699 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 885, __pyx_L1_error
)
8700 __Pyx_GOTREF(__pyx_t_4
);
8701 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 885, __pyx_L1_error
)
8702 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8703 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 885, __pyx_L1_error
)
8704 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8706 (__pyx_v_f
[0]) = 0x68;
8710 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":886
8711 * elif t == NPY_UBYTE: f[0] = 66 #"B"
8712 * elif t == NPY_SHORT: f[0] = 104 #"h"
8713 * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<<
8714 * elif t == NPY_INT: f[0] = 105 #"i"
8715 * elif t == NPY_UINT: f[0] = 73 #"I"
8717 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 886, __pyx_L1_error
)
8718 __Pyx_GOTREF(__pyx_t_3
);
8719 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 886, __pyx_L1_error
)
8720 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8721 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 886, __pyx_L1_error
)
8722 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8724 (__pyx_v_f
[0]) = 72;
8728 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":887
8729 * elif t == NPY_SHORT: f[0] = 104 #"h"
8730 * elif t == NPY_USHORT: f[0] = 72 #"H"
8731 * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<<
8732 * elif t == NPY_UINT: f[0] = 73 #"I"
8733 * elif t == NPY_LONG: f[0] = 108 #"l"
8735 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 887, __pyx_L1_error
)
8736 __Pyx_GOTREF(__pyx_t_4
);
8737 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 887, __pyx_L1_error
)
8738 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8739 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 887, __pyx_L1_error
)
8740 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8742 (__pyx_v_f
[0]) = 0x69;
8746 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":888
8747 * elif t == NPY_USHORT: f[0] = 72 #"H"
8748 * elif t == NPY_INT: f[0] = 105 #"i"
8749 * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<<
8750 * elif t == NPY_LONG: f[0] = 108 #"l"
8751 * elif t == NPY_ULONG: f[0] = 76 #"L"
8753 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 888, __pyx_L1_error
)
8754 __Pyx_GOTREF(__pyx_t_3
);
8755 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 888, __pyx_L1_error
)
8756 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8757 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 888, __pyx_L1_error
)
8758 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8760 (__pyx_v_f
[0]) = 73;
8764 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":889
8765 * elif t == NPY_INT: f[0] = 105 #"i"
8766 * elif t == NPY_UINT: f[0] = 73 #"I"
8767 * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<<
8768 * elif t == NPY_ULONG: f[0] = 76 #"L"
8769 * elif t == NPY_LONGLONG: f[0] = 113 #"q"
8771 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 889, __pyx_L1_error
)
8772 __Pyx_GOTREF(__pyx_t_4
);
8773 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 889, __pyx_L1_error
)
8774 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8775 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 889, __pyx_L1_error
)
8776 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8778 (__pyx_v_f
[0]) = 0x6C;
8782 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":890
8783 * elif t == NPY_UINT: f[0] = 73 #"I"
8784 * elif t == NPY_LONG: f[0] = 108 #"l"
8785 * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<<
8786 * elif t == NPY_LONGLONG: f[0] = 113 #"q"
8787 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
8789 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 890, __pyx_L1_error
)
8790 __Pyx_GOTREF(__pyx_t_3
);
8791 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 890, __pyx_L1_error
)
8792 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8793 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 890, __pyx_L1_error
)
8794 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8796 (__pyx_v_f
[0]) = 76;
8800 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":891
8801 * elif t == NPY_LONG: f[0] = 108 #"l"
8802 * elif t == NPY_ULONG: f[0] = 76 #"L"
8803 * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<<
8804 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
8805 * elif t == NPY_FLOAT: f[0] = 102 #"f"
8807 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 891, __pyx_L1_error
)
8808 __Pyx_GOTREF(__pyx_t_4
);
8809 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 891, __pyx_L1_error
)
8810 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8811 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 891, __pyx_L1_error
)
8812 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8814 (__pyx_v_f
[0]) = 0x71;
8818 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":892
8819 * elif t == NPY_ULONG: f[0] = 76 #"L"
8820 * elif t == NPY_LONGLONG: f[0] = 113 #"q"
8821 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<<
8822 * elif t == NPY_FLOAT: f[0] = 102 #"f"
8823 * elif t == NPY_DOUBLE: f[0] = 100 #"d"
8825 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 892, __pyx_L1_error
)
8826 __Pyx_GOTREF(__pyx_t_3
);
8827 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 892, __pyx_L1_error
)
8828 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8829 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 892, __pyx_L1_error
)
8830 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8832 (__pyx_v_f
[0]) = 81;
8836 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":893
8837 * elif t == NPY_LONGLONG: f[0] = 113 #"q"
8838 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
8839 * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<<
8840 * elif t == NPY_DOUBLE: f[0] = 100 #"d"
8841 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
8843 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 893, __pyx_L1_error
)
8844 __Pyx_GOTREF(__pyx_t_4
);
8845 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 893, __pyx_L1_error
)
8846 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8847 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 893, __pyx_L1_error
)
8848 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8850 (__pyx_v_f
[0]) = 0x66;
8854 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":894
8855 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
8856 * elif t == NPY_FLOAT: f[0] = 102 #"f"
8857 * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<<
8858 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
8859 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
8861 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 894, __pyx_L1_error
)
8862 __Pyx_GOTREF(__pyx_t_3
);
8863 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 894, __pyx_L1_error
)
8864 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8865 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 894, __pyx_L1_error
)
8866 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8868 (__pyx_v_f
[0]) = 0x64;
8872 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":895
8873 * elif t == NPY_FLOAT: f[0] = 102 #"f"
8874 * elif t == NPY_DOUBLE: f[0] = 100 #"d"
8875 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<<
8876 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
8877 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
8879 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 895, __pyx_L1_error
)
8880 __Pyx_GOTREF(__pyx_t_4
);
8881 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 895, __pyx_L1_error
)
8882 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8883 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 895, __pyx_L1_error
)
8884 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8886 (__pyx_v_f
[0]) = 0x67;
8890 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":896
8891 * elif t == NPY_DOUBLE: f[0] = 100 #"d"
8892 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
8893 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<<
8894 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
8895 * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
8897 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 896, __pyx_L1_error
)
8898 __Pyx_GOTREF(__pyx_t_3
);
8899 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 896, __pyx_L1_error
)
8900 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8901 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 896, __pyx_L1_error
)
8902 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8904 (__pyx_v_f
[0]) = 90;
8905 (__pyx_v_f
[1]) = 0x66;
8906 __pyx_v_f
= (__pyx_v_f
+ 1);
8910 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":897
8911 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
8912 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
8913 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<<
8914 * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
8915 * elif t == NPY_OBJECT: f[0] = 79 #"O"
8917 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 897, __pyx_L1_error
)
8918 __Pyx_GOTREF(__pyx_t_4
);
8919 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 897, __pyx_L1_error
)
8920 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8921 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 897, __pyx_L1_error
)
8922 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8924 (__pyx_v_f
[0]) = 90;
8925 (__pyx_v_f
[1]) = 0x64;
8926 __pyx_v_f
= (__pyx_v_f
+ 1);
8930 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":898
8931 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
8932 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
8933 * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<<
8934 * elif t == NPY_OBJECT: f[0] = 79 #"O"
8937 __pyx_t_3
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 898, __pyx_L1_error
)
8938 __Pyx_GOTREF(__pyx_t_3
);
8939 __pyx_t_4
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_3
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_4
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 898, __pyx_L1_error
)
8940 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8941 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_4
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 898, __pyx_L1_error
)
8942 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8944 (__pyx_v_f
[0]) = 90;
8945 (__pyx_v_f
[1]) = 0x67;
8946 __pyx_v_f
= (__pyx_v_f
+ 1);
8950 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":899
8951 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
8952 * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
8953 * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<<
8955 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
8957 __pyx_t_4
= __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 899, __pyx_L1_error
)
8958 __Pyx_GOTREF(__pyx_t_4
);
8959 __pyx_t_3
= PyObject_RichCompare(__pyx_v_t
, __pyx_t_4
, Py_EQ
); __Pyx_XGOTREF(__pyx_t_3
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 899, __pyx_L1_error
)
8960 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8961 __pyx_t_6
= __Pyx_PyObject_IsTrue(__pyx_t_3
); if (unlikely(__pyx_t_6
< 0)) __PYX_ERR(1, 899, __pyx_L1_error
)
8962 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8963 if (likely(__pyx_t_6
)) {
8964 (__pyx_v_f
[0]) = 79;
8968 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":901
8969 * elif t == NPY_OBJECT: f[0] = 79 #"O"
8971 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<<
8976 __pyx_t_3
= __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd
, __pyx_v_t
); if (unlikely(!__pyx_t_3
)) __PYX_ERR(1, 901, __pyx_L1_error
)
8977 __Pyx_GOTREF(__pyx_t_3
);
8978 __pyx_t_4
= __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError
, __pyx_t_3
); if (unlikely(!__pyx_t_4
)) __PYX_ERR(1, 901, __pyx_L1_error
)
8979 __Pyx_GOTREF(__pyx_t_4
);
8980 __Pyx_DECREF(__pyx_t_3
); __pyx_t_3
= 0;
8981 __Pyx_Raise(__pyx_t_4
, 0, 0, 0);
8982 __Pyx_DECREF(__pyx_t_4
); __pyx_t_4
= 0;
8983 __PYX_ERR(1, 901, __pyx_L1_error
)
8987 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":902
8989 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
8990 * f += 1 # <<<<<<<<<<<<<<
8992 * # Cython ignores struct boundary information ("T{...}"),
8994 __pyx_v_f
= (__pyx_v_f
+ 1);
8996 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":877
8997 * offset[0] += child.itemsize
8999 * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<<
9000 * t = child.type_num
9006 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":906
9007 * # Cython ignores struct boundary information ("T{...}"),
9008 * # so don't output it
9009 * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<<
9014 __pyx_t_9
= __pyx_f_5numpy__util_dtypestring(__pyx_v_child
, __pyx_v_f
, __pyx_v_end
, __pyx_v_offset
); if (unlikely(__pyx_t_9
== ((char *)NULL
))) __PYX_ERR(1, 906, __pyx_L1_error
)
9015 __pyx_v_f
= __pyx_t_9
;
9019 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":851
9022 * for childname in descr.names: # <<<<<<<<<<<<<<
9023 * fields = descr.fields[childname]
9024 * child, new_offset = fields
9027 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
9029 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":907
9030 * # so don't output it
9031 * f = _util_dtypestring(child, f, end, offset)
9032 * return f # <<<<<<<<<<<<<<
9036 __pyx_r
= __pyx_v_f
;
9039 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":842
9042 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<<
9043 * # Recursive utility function used in __getbuffer__ to get format
9044 * # string. The new location in the format string is returned.
9047 /* function exit code */
9049 __Pyx_XDECREF(__pyx_t_1
);
9050 __Pyx_XDECREF(__pyx_t_3
);
9051 __Pyx_XDECREF(__pyx_t_4
);
9052 __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9055 __Pyx_XDECREF((PyObject
*)__pyx_v_child
);
9056 __Pyx_XDECREF(__pyx_v_fields
);
9057 __Pyx_XDECREF(__pyx_v_childname
);
9058 __Pyx_XDECREF(__pyx_v_new_offset
);
9059 __Pyx_XDECREF(__pyx_v_t
);
9060 __Pyx_TraceReturn(Py_None
, 0);
9061 __Pyx_RefNannyFinishContext();
9065 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1022
9066 * int _import_umath() except -1
9068 * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
9069 * Py_INCREF(base) # important to do this before stealing the reference below!
9070 * PyArray_SetBaseObject(arr, base)
9073 static CYTHON_INLINE
void __pyx_f_5numpy_set_array_base(PyArrayObject
*__pyx_v_arr
, PyObject
*__pyx_v_base
) {
9074 __Pyx_TraceDeclarations
9075 __Pyx_RefNannyDeclarations
9076 __Pyx_RefNannySetupContext("set_array_base", 0);
9077 __Pyx_TraceCall("set_array_base", __pyx_f
[1], 1022, 0, __PYX_ERR(1, 1022, __pyx_L1_error
));
9079 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1023
9081 * cdef inline void set_array_base(ndarray arr, object base):
9082 * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<<
9083 * PyArray_SetBaseObject(arr, base)
9086 Py_INCREF(__pyx_v_base
);
9088 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1024
9089 * cdef inline void set_array_base(ndarray arr, object base):
9090 * Py_INCREF(base) # important to do this before stealing the reference below!
9091 * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<<
9093 * cdef inline object get_array_base(ndarray arr):
9095 (void)(PyArray_SetBaseObject(__pyx_v_arr
, __pyx_v_base
));
9097 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1022
9098 * int _import_umath() except -1
9100 * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
9101 * Py_INCREF(base) # important to do this before stealing the reference below!
9102 * PyArray_SetBaseObject(arr, base)
9105 /* function exit code */
9108 __Pyx_WriteUnraisable("numpy.set_array_base", __pyx_clineno
, __pyx_lineno
, __pyx_filename
, 1, 0);
9110 __Pyx_TraceReturn(Py_None
, 0);
9111 __Pyx_RefNannyFinishContext();
9114 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1026
9115 * PyArray_SetBaseObject(arr, base)
9117 * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
9118 * base = PyArray_BASE(arr)
9122 static CYTHON_INLINE PyObject
*__pyx_f_5numpy_get_array_base(PyArrayObject
*__pyx_v_arr
) {
9123 PyObject
*__pyx_v_base
;
9124 PyObject
*__pyx_r
= NULL
;
9125 __Pyx_TraceDeclarations
9126 __Pyx_RefNannyDeclarations
9128 __Pyx_RefNannySetupContext("get_array_base", 0);
9129 __Pyx_TraceCall("get_array_base", __pyx_f
[1], 1026, 0, __PYX_ERR(1, 1026, __pyx_L1_error
));
9131 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1027
9133 * cdef inline object get_array_base(ndarray arr):
9134 * base = PyArray_BASE(arr) # <<<<<<<<<<<<<<
9138 __pyx_v_base
= PyArray_BASE(__pyx_v_arr
);
9140 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1028
9141 * cdef inline object get_array_base(ndarray arr):
9142 * base = PyArray_BASE(arr)
9143 * if base is NULL: # <<<<<<<<<<<<<<
9145 * return <object>base
9147 __pyx_t_1
= ((__pyx_v_base
== NULL
) != 0);
9150 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1029
9151 * base = PyArray_BASE(arr)
9153 * return None # <<<<<<<<<<<<<<
9154 * return <object>base
9157 __Pyx_XDECREF(__pyx_r
);
9158 __pyx_r
= Py_None
; __Pyx_INCREF(Py_None
);
9161 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1028
9162 * cdef inline object get_array_base(ndarray arr):
9163 * base = PyArray_BASE(arr)
9164 * if base is NULL: # <<<<<<<<<<<<<<
9166 * return <object>base
9170 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1030
9173 * return <object>base # <<<<<<<<<<<<<<
9175 * # Versions of the import_* functions which are more suitable for
9177 __Pyx_XDECREF(__pyx_r
);
9178 __Pyx_INCREF(((PyObject
*)__pyx_v_base
));
9179 __pyx_r
= ((PyObject
*)__pyx_v_base
);
9182 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1026
9183 * PyArray_SetBaseObject(arr, base)
9185 * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
9186 * base = PyArray_BASE(arr)
9190 /* function exit code */
9192 __Pyx_AddTraceback("numpy.get_array_base", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9195 __Pyx_XGIVEREF(__pyx_r
);
9196 __Pyx_TraceReturn(__pyx_r
, 0);
9197 __Pyx_RefNannyFinishContext();
9201 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1034
9202 * # Versions of the import_* functions which are more suitable for
9204 * cdef inline int import_array() except -1: # <<<<<<<<<<<<<<
9209 static CYTHON_INLINE
int __pyx_f_5numpy_import_array(void) {
9211 __Pyx_TraceDeclarations
9212 __Pyx_RefNannyDeclarations
9213 PyObject
*__pyx_t_1
= NULL
;
9214 PyObject
*__pyx_t_2
= NULL
;
9215 PyObject
*__pyx_t_3
= NULL
;
9217 PyObject
*__pyx_t_5
= NULL
;
9218 PyObject
*__pyx_t_6
= NULL
;
9219 PyObject
*__pyx_t_7
= NULL
;
9220 PyObject
*__pyx_t_8
= NULL
;
9221 __Pyx_RefNannySetupContext("import_array", 0);
9222 __Pyx_TraceCall("import_array", __pyx_f
[1], 1034, 0, __PYX_ERR(1, 1034, __pyx_L1_error
));
9224 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1035
9226 * cdef inline int import_array() except -1:
9227 * try: # <<<<<<<<<<<<<<
9232 __Pyx_PyThreadState_declare
9233 __Pyx_PyThreadState_assign
9234 __Pyx_ExceptionSave(&__pyx_t_1
, &__pyx_t_2
, &__pyx_t_3
);
9235 __Pyx_XGOTREF(__pyx_t_1
);
9236 __Pyx_XGOTREF(__pyx_t_2
);
9237 __Pyx_XGOTREF(__pyx_t_3
);
9240 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1036
9241 * cdef inline int import_array() except -1:
9243 * _import_array() # <<<<<<<<<<<<<<
9245 * raise ImportError("numpy.core.multiarray failed to import")
9247 __pyx_t_4
= _import_array(); if (unlikely(__pyx_t_4
== ((int)-1))) __PYX_ERR(1, 1036, __pyx_L3_error
)
9249 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1035
9251 * cdef inline int import_array() except -1:
9252 * try: # <<<<<<<<<<<<<<
9257 __Pyx_XDECREF(__pyx_t_1
); __pyx_t_1
= 0;
9258 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
9259 __Pyx_XDECREF(__pyx_t_3
); __pyx_t_3
= 0;
9260 goto __pyx_L8_try_end
;
9263 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1037
9266 * except Exception: # <<<<<<<<<<<<<<
9267 * raise ImportError("numpy.core.multiarray failed to import")
9270 __pyx_t_4
= __Pyx_PyErr_ExceptionMatches(((PyObject
*)(&((PyTypeObject
*)PyExc_Exception
)[0])));
9272 __Pyx_AddTraceback("numpy.import_array", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9273 if (__Pyx_GetException(&__pyx_t_5
, &__pyx_t_6
, &__pyx_t_7
) < 0) __PYX_ERR(1, 1037, __pyx_L5_except_error
)
9274 __Pyx_GOTREF(__pyx_t_5
);
9275 __Pyx_GOTREF(__pyx_t_6
);
9276 __Pyx_GOTREF(__pyx_t_7
);
9278 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1038
9281 * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<<
9283 * cdef inline int import_umath() except -1:
9285 __pyx_t_8
= __Pyx_PyObject_Call(__pyx_builtin_ImportError
, __pyx_tuple__11
, NULL
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(1, 1038, __pyx_L5_except_error
)
9286 __Pyx_GOTREF(__pyx_t_8
);
9287 __Pyx_Raise(__pyx_t_8
, 0, 0, 0);
9288 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
9289 __PYX_ERR(1, 1038, __pyx_L5_except_error
)
9291 goto __pyx_L5_except_error
;
9292 __pyx_L5_except_error
:;
9294 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1035
9296 * cdef inline int import_array() except -1:
9297 * try: # <<<<<<<<<<<<<<
9301 __Pyx_XGIVEREF(__pyx_t_1
);
9302 __Pyx_XGIVEREF(__pyx_t_2
);
9303 __Pyx_XGIVEREF(__pyx_t_3
);
9304 __Pyx_ExceptionReset(__pyx_t_1
, __pyx_t_2
, __pyx_t_3
);
9305 goto __pyx_L1_error
;
9309 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1034
9310 * # Versions of the import_* functions which are more suitable for
9312 * cdef inline int import_array() except -1: # <<<<<<<<<<<<<<
9317 /* function exit code */
9321 __Pyx_XDECREF(__pyx_t_5
);
9322 __Pyx_XDECREF(__pyx_t_6
);
9323 __Pyx_XDECREF(__pyx_t_7
);
9324 __Pyx_XDECREF(__pyx_t_8
);
9325 __Pyx_AddTraceback("numpy.import_array", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9328 __Pyx_TraceReturn(Py_None
, 0);
9329 __Pyx_RefNannyFinishContext();
9333 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1040
9334 * raise ImportError("numpy.core.multiarray failed to import")
9336 * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<<
9341 static CYTHON_INLINE
int __pyx_f_5numpy_import_umath(void) {
9343 __Pyx_TraceDeclarations
9344 __Pyx_RefNannyDeclarations
9345 PyObject
*__pyx_t_1
= NULL
;
9346 PyObject
*__pyx_t_2
= NULL
;
9347 PyObject
*__pyx_t_3
= NULL
;
9349 PyObject
*__pyx_t_5
= NULL
;
9350 PyObject
*__pyx_t_6
= NULL
;
9351 PyObject
*__pyx_t_7
= NULL
;
9352 PyObject
*__pyx_t_8
= NULL
;
9353 __Pyx_RefNannySetupContext("import_umath", 0);
9354 __Pyx_TraceCall("import_umath", __pyx_f
[1], 1040, 0, __PYX_ERR(1, 1040, __pyx_L1_error
));
9356 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1041
9358 * cdef inline int import_umath() except -1:
9359 * try: # <<<<<<<<<<<<<<
9364 __Pyx_PyThreadState_declare
9365 __Pyx_PyThreadState_assign
9366 __Pyx_ExceptionSave(&__pyx_t_1
, &__pyx_t_2
, &__pyx_t_3
);
9367 __Pyx_XGOTREF(__pyx_t_1
);
9368 __Pyx_XGOTREF(__pyx_t_2
);
9369 __Pyx_XGOTREF(__pyx_t_3
);
9372 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1042
9373 * cdef inline int import_umath() except -1:
9375 * _import_umath() # <<<<<<<<<<<<<<
9377 * raise ImportError("numpy.core.umath failed to import")
9379 __pyx_t_4
= _import_umath(); if (unlikely(__pyx_t_4
== ((int)-1))) __PYX_ERR(1, 1042, __pyx_L3_error
)
9381 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1041
9383 * cdef inline int import_umath() except -1:
9384 * try: # <<<<<<<<<<<<<<
9389 __Pyx_XDECREF(__pyx_t_1
); __pyx_t_1
= 0;
9390 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
9391 __Pyx_XDECREF(__pyx_t_3
); __pyx_t_3
= 0;
9392 goto __pyx_L8_try_end
;
9395 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1043
9398 * except Exception: # <<<<<<<<<<<<<<
9399 * raise ImportError("numpy.core.umath failed to import")
9402 __pyx_t_4
= __Pyx_PyErr_ExceptionMatches(((PyObject
*)(&((PyTypeObject
*)PyExc_Exception
)[0])));
9404 __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9405 if (__Pyx_GetException(&__pyx_t_5
, &__pyx_t_6
, &__pyx_t_7
) < 0) __PYX_ERR(1, 1043, __pyx_L5_except_error
)
9406 __Pyx_GOTREF(__pyx_t_5
);
9407 __Pyx_GOTREF(__pyx_t_6
);
9408 __Pyx_GOTREF(__pyx_t_7
);
9410 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1044
9413 * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
9415 * cdef inline int import_ufunc() except -1:
9417 __pyx_t_8
= __Pyx_PyObject_Call(__pyx_builtin_ImportError
, __pyx_tuple__12
, NULL
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(1, 1044, __pyx_L5_except_error
)
9418 __Pyx_GOTREF(__pyx_t_8
);
9419 __Pyx_Raise(__pyx_t_8
, 0, 0, 0);
9420 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
9421 __PYX_ERR(1, 1044, __pyx_L5_except_error
)
9423 goto __pyx_L5_except_error
;
9424 __pyx_L5_except_error
:;
9426 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1041
9428 * cdef inline int import_umath() except -1:
9429 * try: # <<<<<<<<<<<<<<
9433 __Pyx_XGIVEREF(__pyx_t_1
);
9434 __Pyx_XGIVEREF(__pyx_t_2
);
9435 __Pyx_XGIVEREF(__pyx_t_3
);
9436 __Pyx_ExceptionReset(__pyx_t_1
, __pyx_t_2
, __pyx_t_3
);
9437 goto __pyx_L1_error
;
9441 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1040
9442 * raise ImportError("numpy.core.multiarray failed to import")
9444 * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<<
9449 /* function exit code */
9453 __Pyx_XDECREF(__pyx_t_5
);
9454 __Pyx_XDECREF(__pyx_t_6
);
9455 __Pyx_XDECREF(__pyx_t_7
);
9456 __Pyx_XDECREF(__pyx_t_8
);
9457 __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9460 __Pyx_TraceReturn(Py_None
, 0);
9461 __Pyx_RefNannyFinishContext();
9465 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1046
9466 * raise ImportError("numpy.core.umath failed to import")
9468 * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
9473 static CYTHON_INLINE
int __pyx_f_5numpy_import_ufunc(void) {
9475 __Pyx_TraceDeclarations
9476 __Pyx_RefNannyDeclarations
9477 PyObject
*__pyx_t_1
= NULL
;
9478 PyObject
*__pyx_t_2
= NULL
;
9479 PyObject
*__pyx_t_3
= NULL
;
9481 PyObject
*__pyx_t_5
= NULL
;
9482 PyObject
*__pyx_t_6
= NULL
;
9483 PyObject
*__pyx_t_7
= NULL
;
9484 PyObject
*__pyx_t_8
= NULL
;
9485 __Pyx_RefNannySetupContext("import_ufunc", 0);
9486 __Pyx_TraceCall("import_ufunc", __pyx_f
[1], 1046, 0, __PYX_ERR(1, 1046, __pyx_L1_error
));
9488 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1047
9490 * cdef inline int import_ufunc() except -1:
9491 * try: # <<<<<<<<<<<<<<
9496 __Pyx_PyThreadState_declare
9497 __Pyx_PyThreadState_assign
9498 __Pyx_ExceptionSave(&__pyx_t_1
, &__pyx_t_2
, &__pyx_t_3
);
9499 __Pyx_XGOTREF(__pyx_t_1
);
9500 __Pyx_XGOTREF(__pyx_t_2
);
9501 __Pyx_XGOTREF(__pyx_t_3
);
9504 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1048
9505 * cdef inline int import_ufunc() except -1:
9507 * _import_umath() # <<<<<<<<<<<<<<
9509 * raise ImportError("numpy.core.umath failed to import")
9511 __pyx_t_4
= _import_umath(); if (unlikely(__pyx_t_4
== ((int)-1))) __PYX_ERR(1, 1048, __pyx_L3_error
)
9513 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1047
9515 * cdef inline int import_ufunc() except -1:
9516 * try: # <<<<<<<<<<<<<<
9521 __Pyx_XDECREF(__pyx_t_1
); __pyx_t_1
= 0;
9522 __Pyx_XDECREF(__pyx_t_2
); __pyx_t_2
= 0;
9523 __Pyx_XDECREF(__pyx_t_3
); __pyx_t_3
= 0;
9524 goto __pyx_L8_try_end
;
9527 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1049
9530 * except Exception: # <<<<<<<<<<<<<<
9531 * raise ImportError("numpy.core.umath failed to import")
9533 __pyx_t_4
= __Pyx_PyErr_ExceptionMatches(((PyObject
*)(&((PyTypeObject
*)PyExc_Exception
)[0])));
9535 __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9536 if (__Pyx_GetException(&__pyx_t_5
, &__pyx_t_6
, &__pyx_t_7
) < 0) __PYX_ERR(1, 1049, __pyx_L5_except_error
)
9537 __Pyx_GOTREF(__pyx_t_5
);
9538 __Pyx_GOTREF(__pyx_t_6
);
9539 __Pyx_GOTREF(__pyx_t_7
);
9541 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1050
9544 * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
9546 __pyx_t_8
= __Pyx_PyObject_Call(__pyx_builtin_ImportError
, __pyx_tuple__12
, NULL
); if (unlikely(!__pyx_t_8
)) __PYX_ERR(1, 1050, __pyx_L5_except_error
)
9547 __Pyx_GOTREF(__pyx_t_8
);
9548 __Pyx_Raise(__pyx_t_8
, 0, 0, 0);
9549 __Pyx_DECREF(__pyx_t_8
); __pyx_t_8
= 0;
9550 __PYX_ERR(1, 1050, __pyx_L5_except_error
)
9552 goto __pyx_L5_except_error
;
9553 __pyx_L5_except_error
:;
9555 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1047
9557 * cdef inline int import_ufunc() except -1:
9558 * try: # <<<<<<<<<<<<<<
9562 __Pyx_XGIVEREF(__pyx_t_1
);
9563 __Pyx_XGIVEREF(__pyx_t_2
);
9564 __Pyx_XGIVEREF(__pyx_t_3
);
9565 __Pyx_ExceptionReset(__pyx_t_1
, __pyx_t_2
, __pyx_t_3
);
9566 goto __pyx_L1_error
;
9570 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1046
9571 * raise ImportError("numpy.core.umath failed to import")
9573 * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
9578 /* function exit code */
9582 __Pyx_XDECREF(__pyx_t_5
);
9583 __Pyx_XDECREF(__pyx_t_6
);
9584 __Pyx_XDECREF(__pyx_t_7
);
9585 __Pyx_XDECREF(__pyx_t_8
);
9586 __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
9589 __Pyx_TraceReturn(Py_None
, 0);
9590 __Pyx_RefNannyFinishContext();
9594 static PyMethodDef __pyx_methods
[] = {
9595 {"maxima", (PyCFunction
)(void*)(PyCFunctionWithKeywords
)__pyx_pw_5MACS2_6Signal_1maxima
, METH_VARARGS
|METH_KEYWORDS
, __pyx_doc_5MACS2_6Signal_maxima
},
9596 {"enforce_peakyness", (PyCFunction
)(void*)(PyCFunctionWithKeywords
)__pyx_pw_5MACS2_6Signal_3enforce_peakyness
, METH_VARARGS
|METH_KEYWORDS
, __pyx_doc_5MACS2_6Signal_2enforce_peakyness
},
9597 {"enforce_valleys", (PyCFunction
)(void*)(PyCFunctionWithKeywords
)__pyx_pw_5MACS2_6Signal_5enforce_valleys
, METH_VARARGS
|METH_KEYWORDS
, __pyx_doc_5MACS2_6Signal_4enforce_valleys
},
9598 {"savitzky_golay_order2_deriv1", (PyCFunction
)(void*)(PyCFunctionWithKeywords
)__pyx_pw_5MACS2_6Signal_7savitzky_golay_order2_deriv1
, METH_VARARGS
|METH_KEYWORDS
, __pyx_doc_5MACS2_6Signal_6savitzky_golay_order2_deriv1
},
9599 {"savitzky_golay", (PyCFunction
)(void*)(PyCFunctionWithKeywords
)__pyx_pw_5MACS2_6Signal_9savitzky_golay
, METH_VARARGS
|METH_KEYWORDS
, __pyx_doc_5MACS2_6Signal_8savitzky_golay
},
9603 #if PY_MAJOR_VERSION >= 3
9604 #if CYTHON_PEP489_MULTI_PHASE_INIT
9605 static PyObject
* __pyx_pymod_create(PyObject
*spec
, PyModuleDef
*def
); /*proto*/
9606 static int __pyx_pymod_exec_Signal(PyObject
* module
); /*proto*/
9607 static PyModuleDef_Slot __pyx_moduledef_slots
[] = {
9608 {Py_mod_create
, (void*)__pyx_pymod_create
},
9609 {Py_mod_exec
, (void*)__pyx_pymod_exec_Signal
},
9614 static struct PyModuleDef __pyx_moduledef
= {
9615 PyModuleDef_HEAD_INIT
,
9617 __pyx_k_Module_Description_functions_to
, /* m_doc */
9618 #if CYTHON_PEP489_MULTI_PHASE_INIT
9623 __pyx_methods
/* m_methods */,
9624 #if CYTHON_PEP489_MULTI_PHASE_INIT
9625 __pyx_moduledef_slots
, /* m_slots */
9627 NULL
, /* m_reload */
9629 NULL
, /* m_traverse */
9634 #ifndef CYTHON_SMALL_CODE
9635 #if defined(__clang__)
9636 #define CYTHON_SMALL_CODE
9637 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
9638 #define CYTHON_SMALL_CODE __attribute__((cold))
9640 #define CYTHON_SMALL_CODE
9644 static __Pyx_StringTabEntry __pyx_string_tab
[] = {
9645 {&__pyx_kp_u_Format_string_allocated_too_shor
, __pyx_k_Format_string_allocated_too_shor
, sizeof(__pyx_k_Format_string_allocated_too_shor
), 0, 1, 0, 0},
9646 {&__pyx_kp_u_Format_string_allocated_too_shor_2
, __pyx_k_Format_string_allocated_too_shor_2
, sizeof(__pyx_k_Format_string_allocated_too_shor_2
), 0, 1, 0, 0},
9647 {&__pyx_n_s_ImportError
, __pyx_k_ImportError
, sizeof(__pyx_k_ImportError
), 0, 0, 1, 1},
9648 {&__pyx_kp_u_Non_native_byte_order_not_suppor
, __pyx_k_Non_native_byte_order_not_suppor
, sizeof(__pyx_k_Non_native_byte_order_not_suppor
), 0, 1, 0, 0},
9649 {&__pyx_n_s_RuntimeError
, __pyx_k_RuntimeError
, sizeof(__pyx_k_RuntimeError
), 0, 0, 1, 1},
9650 {&__pyx_n_s_TypeError
, __pyx_k_TypeError
, sizeof(__pyx_k_TypeError
), 0, 0, 1, 1},
9651 {&__pyx_n_s_ValueError
, __pyx_k_ValueError
, sizeof(__pyx_k_ValueError
), 0, 0, 1, 1},
9652 {&__pyx_n_s_abs
, __pyx_k_abs
, sizeof(__pyx_k_abs
), 0, 0, 1, 1},
9653 {&__pyx_n_s_any
, __pyx_k_any
, sizeof(__pyx_k_any
), 0, 0, 1, 1},
9654 {&__pyx_n_s_array
, __pyx_k_array
, sizeof(__pyx_k_array
), 0, 0, 1, 1},
9655 {&__pyx_n_s_astype
, __pyx_k_astype
, sizeof(__pyx_k_astype
), 0, 0, 1, 1},
9656 {&__pyx_n_s_cline_in_traceback
, __pyx_k_cline_in_traceback
, sizeof(__pyx_k_cline_in_traceback
), 0, 0, 1, 1},
9657 {&__pyx_n_s_concatenate
, __pyx_k_concatenate
, sizeof(__pyx_k_concatenate
), 0, 0, 1, 1},
9658 {&__pyx_n_s_convolve
, __pyx_k_convolve
, sizeof(__pyx_k_convolve
), 0, 0, 1, 1},
9659 {&__pyx_n_s_copy
, __pyx_k_copy
, sizeof(__pyx_k_copy
), 0, 0, 1, 1},
9660 {&__pyx_n_s_deriv
, __pyx_k_deriv
, sizeof(__pyx_k_deriv
), 0, 0, 1, 1},
9661 {&__pyx_n_s_diff
, __pyx_k_diff
, sizeof(__pyx_k_diff
), 0, 0, 1, 1},
9662 {&__pyx_n_s_dtype
, __pyx_k_dtype
, sizeof(__pyx_k_dtype
), 0, 0, 1, 1},
9663 {&__pyx_n_s_factorial
, __pyx_k_factorial
, sizeof(__pyx_k_factorial
), 0, 0, 1, 1},
9664 {&__pyx_n_u_float32
, __pyx_k_float32
, sizeof(__pyx_k_float32
), 0, 1, 0, 1},
9665 {&__pyx_n_u_float64
, __pyx_k_float64
, sizeof(__pyx_k_float64
), 0, 1, 0, 1},
9666 {&__pyx_n_s_import
, __pyx_k_import
, sizeof(__pyx_k_import
), 0, 0, 1, 1},
9667 {&__pyx_n_s_int
, __pyx_k_int
, sizeof(__pyx_k_int
), 0, 0, 1, 1},
9668 {&__pyx_n_u_int32
, __pyx_k_int32
, sizeof(__pyx_k_int32
), 0, 1, 0, 1},
9669 {&__pyx_n_u_int64
, __pyx_k_int64
, sizeof(__pyx_k_int64
), 0, 1, 0, 1},
9670 {&__pyx_n_s_linalg
, __pyx_k_linalg
, sizeof(__pyx_k_linalg
), 0, 0, 1, 1},
9671 {&__pyx_n_s_main
, __pyx_k_main
, sizeof(__pyx_k_main
), 0, 0, 1, 1},
9672 {&__pyx_n_s_math
, __pyx_k_math
, sizeof(__pyx_k_math
), 0, 0, 1, 1},
9673 {&__pyx_n_s_mathfactorial
, __pyx_k_mathfactorial
, sizeof(__pyx_k_mathfactorial
), 0, 0, 1, 1},
9674 {&__pyx_n_s_mathsqrt
, __pyx_k_mathsqrt
, sizeof(__pyx_k_mathsqrt
), 0, 0, 1, 1},
9675 {&__pyx_n_s_maxima
, __pyx_k_maxima
, sizeof(__pyx_k_maxima
), 0, 0, 1, 1},
9676 {&__pyx_n_s_min
, __pyx_k_min
, sizeof(__pyx_k_min
), 0, 0, 1, 1},
9677 {&__pyx_n_s_min_valley
, __pyx_k_min_valley
, sizeof(__pyx_k_min_valley
), 0, 0, 1, 1},
9678 {&__pyx_n_s_mode
, __pyx_k_mode
, sizeof(__pyx_k_mode
), 0, 0, 1, 1},
9679 {&__pyx_n_s_name
, __pyx_k_name
, sizeof(__pyx_k_name
), 0, 0, 1, 1},
9680 {&__pyx_kp_u_ndarray_is_not_C_contiguous
, __pyx_k_ndarray_is_not_C_contiguous
, sizeof(__pyx_k_ndarray_is_not_C_contiguous
), 0, 1, 0, 0},
9681 {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou
, __pyx_k_ndarray_is_not_Fortran_contiguou
, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou
), 0, 1, 0, 0},
9682 {&__pyx_n_s_np
, __pyx_k_np
, sizeof(__pyx_k_np
), 0, 0, 1, 1},
9683 {&__pyx_n_s_numpy
, __pyx_k_numpy
, sizeof(__pyx_k_numpy
), 0, 0, 1, 1},
9684 {&__pyx_kp_u_numpy_core_multiarray_failed_to
, __pyx_k_numpy_core_multiarray_failed_to
, sizeof(__pyx_k_numpy_core_multiarray_failed_to
), 0, 1, 0, 0},
9685 {&__pyx_kp_u_numpy_core_umath_failed_to_impor
, __pyx_k_numpy_core_umath_failed_to_impor
, sizeof(__pyx_k_numpy_core_umath_failed_to_impor
), 0, 1, 0, 0},
9686 {&__pyx_n_s_order
, __pyx_k_order
, sizeof(__pyx_k_order
), 0, 0, 1, 1},
9687 {&__pyx_n_s_pinv
, __pyx_k_pinv
, sizeof(__pyx_k_pinv
), 0, 0, 1, 1},
9688 {&__pyx_n_s_range
, __pyx_k_range
, sizeof(__pyx_k_range
), 0, 0, 1, 1},
9689 {&__pyx_n_s_rate
, __pyx_k_rate
, sizeof(__pyx_k_rate
), 0, 0, 1, 1},
9690 {&__pyx_n_s_refcheck
, __pyx_k_refcheck
, sizeof(__pyx_k_refcheck
), 0, 0, 1, 1},
9691 {&__pyx_n_s_resize
, __pyx_k_resize
, sizeof(__pyx_k_resize
), 0, 0, 1, 1},
9692 {&__pyx_n_s_round
, __pyx_k_round
, sizeof(__pyx_k_round
), 0, 0, 1, 1},
9693 {&__pyx_n_s_shape
, __pyx_k_shape
, sizeof(__pyx_k_shape
), 0, 0, 1, 1},
9694 {&__pyx_n_s_sign
, __pyx_k_sign
, sizeof(__pyx_k_sign
), 0, 0, 1, 1},
9695 {&__pyx_n_s_signal
, __pyx_k_signal
, sizeof(__pyx_k_signal
), 0, 0, 1, 1},
9696 {&__pyx_n_s_sqrt
, __pyx_k_sqrt
, sizeof(__pyx_k_sqrt
), 0, 0, 1, 1},
9697 {&__pyx_n_s_summits
, __pyx_k_summits
, sizeof(__pyx_k_summits
), 0, 0, 1, 1},
9698 {&__pyx_n_s_test
, __pyx_k_test
, sizeof(__pyx_k_test
), 0, 0, 1, 1},
9699 {&__pyx_n_s_unique
, __pyx_k_unique
, sizeof(__pyx_k_unique
), 0, 0, 1, 1},
9700 {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd
, __pyx_k_unknown_dtype_code_in_numpy_pxd
, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd
), 0, 1, 0, 0},
9701 {&__pyx_n_u_valid
, __pyx_k_valid
, sizeof(__pyx_k_valid
), 0, 1, 0, 1},
9702 {&__pyx_n_s_where
, __pyx_k_where
, sizeof(__pyx_k_where
), 0, 0, 1, 1},
9703 {&__pyx_n_s_window_size
, __pyx_k_window_size
, sizeof(__pyx_k_window_size
), 0, 0, 1, 1},
9704 {&__pyx_kp_u_window_size_and_order_have_to_be
, __pyx_k_window_size_and_order_have_to_be
, sizeof(__pyx_k_window_size_and_order_have_to_be
), 0, 1, 0, 0},
9705 {&__pyx_kp_u_window_size_is_too_small_for_the
, __pyx_k_window_size_is_too_small_for_the
, sizeof(__pyx_k_window_size_is_too_small_for_the
), 0, 1, 0, 0},
9706 {&__pyx_kp_u_window_size_size_must_be_a_posit
, __pyx_k_window_size_size_must_be_a_posit
, sizeof(__pyx_k_window_size_size_must_be_a_posit
), 0, 1, 0, 0},
9707 {&__pyx_n_s_y
, __pyx_k_y
, sizeof(__pyx_k_y
), 0, 0, 1, 1},
9708 {&__pyx_n_s_zeros
, __pyx_k_zeros
, sizeof(__pyx_k_zeros
), 0, 0, 1, 1},
9709 {0, 0, 0, 0, 0, 0, 0}
9711 static CYTHON_SMALL_CODE
int __Pyx_InitCachedBuiltins(void) {
9712 __pyx_builtin_range
= __Pyx_GetBuiltinName(__pyx_n_s_range
); if (!__pyx_builtin_range
) __PYX_ERR(0, 49, __pyx_L1_error
)
9713 __pyx_builtin_ValueError
= __Pyx_GetBuiltinName(__pyx_n_s_ValueError
); if (!__pyx_builtin_ValueError
) __PYX_ERR(0, 327, __pyx_L1_error
)
9714 __pyx_builtin_TypeError
= __Pyx_GetBuiltinName(__pyx_n_s_TypeError
); if (!__pyx_builtin_TypeError
) __PYX_ERR(0, 330, __pyx_L1_error
)
9715 __pyx_builtin_RuntimeError
= __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError
); if (!__pyx_builtin_RuntimeError
) __PYX_ERR(1, 856, __pyx_L1_error
)
9716 __pyx_builtin_ImportError
= __Pyx_GetBuiltinName(__pyx_n_s_ImportError
); if (!__pyx_builtin_ImportError
) __PYX_ERR(1, 1038, __pyx_L1_error
)
9722 static CYTHON_SMALL_CODE
int __Pyx_InitCachedConstants(void) {
9723 __Pyx_RefNannyDeclarations
9724 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
9726 /* "MACS2/Signal.pyx":44
9728 * if n == 0 or n == 1:
9729 * ret = np.ndarray(0, 'int32') # <<<<<<<<<<<<<<
9733 __pyx_tuple_
= PyTuple_Pack(2, __pyx_int_0
, __pyx_n_u_int32
); if (unlikely(!__pyx_tuple_
)) __PYX_ERR(0, 44, __pyx_L1_error
)
9734 __Pyx_GOTREF(__pyx_tuple_
);
9735 __Pyx_GIVEREF(__pyx_tuple_
);
9737 /* "MACS2/Signal.pyx":257
9738 * # pad the signal at the extremes with
9739 * # values taken from the signal itself
9740 * firstvals = signal[0] - np.abs(signal[1:half_window+1][::-1] - signal[0]) # <<<<<<<<<<<<<<
9741 * lastvals = signal[-1] + np.abs(signal[-half_window-1:-1][::-1] - signal[-1])
9742 * signal = np.concatenate((firstvals, signal, lastvals))
9744 __pyx_slice__2
= PySlice_New(Py_None
, Py_None
, __pyx_int_neg_1
); if (unlikely(!__pyx_slice__2
)) __PYX_ERR(0, 257, __pyx_L1_error
)
9745 __Pyx_GOTREF(__pyx_slice__2
);
9746 __Pyx_GIVEREF(__pyx_slice__2
);
9748 /* "MACS2/Signal.pyx":328
9749 * order = np.abs( np.int( order ) )
9750 * except ValueError, msg:
9751 * raise ValueError("window_size and order have to be of type int") # <<<<<<<<<<<<<<
9752 * if window_size % 2 != 1 or window_size < 1:
9753 * raise TypeError("window_size size must be a positive odd number")
9755 __pyx_tuple__3
= PyTuple_Pack(1, __pyx_kp_u_window_size_and_order_have_to_be
); if (unlikely(!__pyx_tuple__3
)) __PYX_ERR(0, 328, __pyx_L1_error
)
9756 __Pyx_GOTREF(__pyx_tuple__3
);
9757 __Pyx_GIVEREF(__pyx_tuple__3
);
9759 /* "MACS2/Signal.pyx":330
9760 * raise ValueError("window_size and order have to be of type int")
9761 * if window_size % 2 != 1 or window_size < 1:
9762 * raise TypeError("window_size size must be a positive odd number") # <<<<<<<<<<<<<<
9763 * if window_size < order + 2:
9764 * raise TypeError("window_size is too small for the polynomials order")
9766 __pyx_tuple__4
= PyTuple_Pack(1, __pyx_kp_u_window_size_size_must_be_a_posit
); if (unlikely(!__pyx_tuple__4
)) __PYX_ERR(0, 330, __pyx_L1_error
)
9767 __Pyx_GOTREF(__pyx_tuple__4
);
9768 __Pyx_GIVEREF(__pyx_tuple__4
);
9770 /* "MACS2/Signal.pyx":332
9771 * raise TypeError("window_size size must be a positive odd number")
9772 * if window_size < order + 2:
9773 * raise TypeError("window_size is too small for the polynomials order") # <<<<<<<<<<<<<<
9774 * half_window = ( window_size -1 ) // 2
9775 * # precompute coefficients
9777 __pyx_tuple__5
= PyTuple_Pack(1, __pyx_kp_u_window_size_is_too_small_for_the
); if (unlikely(!__pyx_tuple__5
)) __PYX_ERR(0, 332, __pyx_L1_error
)
9778 __Pyx_GOTREF(__pyx_tuple__5
);
9779 __Pyx_GIVEREF(__pyx_tuple__5
);
9781 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":272
9782 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
9783 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
9784 * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<<
9786 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
9788 __pyx_tuple__6
= PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous
); if (unlikely(!__pyx_tuple__6
)) __PYX_ERR(1, 272, __pyx_L1_error
)
9789 __Pyx_GOTREF(__pyx_tuple__6
);
9790 __Pyx_GIVEREF(__pyx_tuple__6
);
9792 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":276
9793 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
9794 * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
9795 * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<<
9797 * info.buf = PyArray_DATA(self)
9799 __pyx_tuple__7
= PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou
); if (unlikely(!__pyx_tuple__7
)) __PYX_ERR(1, 276, __pyx_L1_error
)
9800 __Pyx_GOTREF(__pyx_tuple__7
);
9801 __Pyx_GIVEREF(__pyx_tuple__7
);
9803 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":306
9804 * if ((descr.byteorder == c'>' and little_endian) or
9805 * (descr.byteorder == c'<' and not little_endian)):
9806 * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
9807 * if t == NPY_BYTE: f = "b"
9808 * elif t == NPY_UBYTE: f = "B"
9810 __pyx_tuple__8
= PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor
); if (unlikely(!__pyx_tuple__8
)) __PYX_ERR(1, 306, __pyx_L1_error
)
9811 __Pyx_GOTREF(__pyx_tuple__8
);
9812 __Pyx_GIVEREF(__pyx_tuple__8
);
9814 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":856
9816 * if (end - f) - <int>(new_offset - offset[0]) < 15:
9817 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<<
9819 * if ((child.byteorder == c'>' and little_endian) or
9821 __pyx_tuple__9
= PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor
); if (unlikely(!__pyx_tuple__9
)) __PYX_ERR(1, 856, __pyx_L1_error
)
9822 __Pyx_GOTREF(__pyx_tuple__9
);
9823 __Pyx_GIVEREF(__pyx_tuple__9
);
9825 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":880
9826 * t = child.type_num
9828 * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<<
9830 * # Until ticket #99 is fixed, use integers to avoid warnings
9832 __pyx_tuple__10
= PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2
); if (unlikely(!__pyx_tuple__10
)) __PYX_ERR(1, 880, __pyx_L1_error
)
9833 __Pyx_GOTREF(__pyx_tuple__10
);
9834 __Pyx_GIVEREF(__pyx_tuple__10
);
9836 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1038
9839 * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<<
9841 * cdef inline int import_umath() except -1:
9843 __pyx_tuple__11
= PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to
); if (unlikely(!__pyx_tuple__11
)) __PYX_ERR(1, 1038, __pyx_L1_error
)
9844 __Pyx_GOTREF(__pyx_tuple__11
);
9845 __Pyx_GIVEREF(__pyx_tuple__11
);
9847 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1044
9850 * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
9852 * cdef inline int import_ufunc() except -1:
9854 __pyx_tuple__12
= PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor
); if (unlikely(!__pyx_tuple__12
)) __PYX_ERR(1, 1044, __pyx_L1_error
)
9855 __Pyx_GOTREF(__pyx_tuple__12
);
9856 __Pyx_GIVEREF(__pyx_tuple__12
);
9857 __Pyx_RefNannyFinishContext();
9860 __Pyx_RefNannyFinishContext();
9864 static CYTHON_SMALL_CODE
int __Pyx_InitGlobals(void) {
9865 if (__Pyx_InitStrings(__pyx_string_tab
) < 0) __PYX_ERR(0, 1, __pyx_L1_error
);
9866 __pyx_int_0
= PyInt_FromLong(0); if (unlikely(!__pyx_int_0
)) __PYX_ERR(0, 1, __pyx_L1_error
)
9867 __pyx_int_1
= PyInt_FromLong(1); if (unlikely(!__pyx_int_1
)) __PYX_ERR(0, 1, __pyx_L1_error
)
9868 __pyx_int_6
= PyInt_FromLong(6); if (unlikely(!__pyx_int_6
)) __PYX_ERR(0, 1, __pyx_L1_error
)
9869 __pyx_int_16
= PyInt_FromLong(16); if (unlikely(!__pyx_int_16
)) __PYX_ERR(0, 1, __pyx_L1_error
)
9870 __pyx_int_neg_1
= PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1
)) __PYX_ERR(0, 1, __pyx_L1_error
)
9876 static CYTHON_SMALL_CODE
int __Pyx_modinit_global_init_code(void); /*proto*/
9877 static CYTHON_SMALL_CODE
int __Pyx_modinit_variable_export_code(void); /*proto*/
9878 static CYTHON_SMALL_CODE
int __Pyx_modinit_function_export_code(void); /*proto*/
9879 static CYTHON_SMALL_CODE
int __Pyx_modinit_type_init_code(void); /*proto*/
9880 static CYTHON_SMALL_CODE
int __Pyx_modinit_type_import_code(void); /*proto*/
9881 static CYTHON_SMALL_CODE
int __Pyx_modinit_variable_import_code(void); /*proto*/
9882 static CYTHON_SMALL_CODE
int __Pyx_modinit_function_import_code(void); /*proto*/
9884 static int __Pyx_modinit_global_init_code(void) {
9885 __Pyx_RefNannyDeclarations
9886 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
9887 /*--- Global init code ---*/
9888 __Pyx_RefNannyFinishContext();
9892 static int __Pyx_modinit_variable_export_code(void) {
9893 __Pyx_RefNannyDeclarations
9894 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
9895 /*--- Variable export code ---*/
9896 __Pyx_RefNannyFinishContext();
9900 static int __Pyx_modinit_function_export_code(void) {
9901 __Pyx_RefNannyDeclarations
9902 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
9903 /*--- Function export code ---*/
9904 __Pyx_RefNannyFinishContext();
9908 static int __Pyx_modinit_type_init_code(void) {
9909 __Pyx_RefNannyDeclarations
9910 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
9911 /*--- Type init code ---*/
9912 __Pyx_RefNannyFinishContext();
9916 static int __Pyx_modinit_type_import_code(void) {
9917 __Pyx_RefNannyDeclarations
9918 PyObject
*__pyx_t_1
= NULL
;
9919 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
9920 /*--- Type import code ---*/
9921 __pyx_t_1
= PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(2, 9, __pyx_L1_error
)
9922 __Pyx_GOTREF(__pyx_t_1
);
9923 __pyx_ptype_7cpython_4type_type
= __Pyx_ImportType(__pyx_t_1
, __Pyx_BUILTIN_MODULE_NAME
, "type",
9924 #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
9925 sizeof(PyTypeObject
),
9927 sizeof(PyHeapTypeObject
),
9929 __Pyx_ImportType_CheckSize_Warn
);
9930 if (!__pyx_ptype_7cpython_4type_type
) __PYX_ERR(2, 9, __pyx_L1_error
)
9931 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
9932 __pyx_t_1
= PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(3, 8, __pyx_L1_error
)
9933 __Pyx_GOTREF(__pyx_t_1
);
9934 __pyx_ptype_7cpython_4bool_bool
= __Pyx_ImportType(__pyx_t_1
, __Pyx_BUILTIN_MODULE_NAME
, "bool", sizeof(PyBoolObject
), __Pyx_ImportType_CheckSize_Warn
);
9935 if (!__pyx_ptype_7cpython_4bool_bool
) __PYX_ERR(3, 8, __pyx_L1_error
)
9936 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
9937 __pyx_t_1
= PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(4, 15, __pyx_L1_error
)
9938 __Pyx_GOTREF(__pyx_t_1
);
9939 __pyx_ptype_7cpython_7complex_complex
= __Pyx_ImportType(__pyx_t_1
, __Pyx_BUILTIN_MODULE_NAME
, "complex", sizeof(PyComplexObject
), __Pyx_ImportType_CheckSize_Warn
);
9940 if (!__pyx_ptype_7cpython_7complex_complex
) __PYX_ERR(4, 15, __pyx_L1_error
)
9941 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
9942 __pyx_t_1
= PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1
)) __PYX_ERR(1, 206, __pyx_L1_error
)
9943 __Pyx_GOTREF(__pyx_t_1
);
9944 __pyx_ptype_5numpy_dtype
= __Pyx_ImportType(__pyx_t_1
, "numpy", "dtype", sizeof(PyArray_Descr
), __Pyx_ImportType_CheckSize_Ignore
);
9945 if (!__pyx_ptype_5numpy_dtype
) __PYX_ERR(1, 206, __pyx_L1_error
)
9946 __pyx_ptype_5numpy_flatiter
= __Pyx_ImportType(__pyx_t_1
, "numpy", "flatiter", sizeof(PyArrayIterObject
), __Pyx_ImportType_CheckSize_Warn
);
9947 if (!__pyx_ptype_5numpy_flatiter
) __PYX_ERR(1, 229, __pyx_L1_error
)
9948 __pyx_ptype_5numpy_broadcast
= __Pyx_ImportType(__pyx_t_1
, "numpy", "broadcast", sizeof(PyArrayMultiIterObject
), __Pyx_ImportType_CheckSize_Warn
);
9949 if (!__pyx_ptype_5numpy_broadcast
) __PYX_ERR(1, 233, __pyx_L1_error
)
9950 __pyx_ptype_5numpy_ndarray
= __Pyx_ImportType(__pyx_t_1
, "numpy", "ndarray", sizeof(PyArrayObject
), __Pyx_ImportType_CheckSize_Ignore
);
9951 if (!__pyx_ptype_5numpy_ndarray
) __PYX_ERR(1, 242, __pyx_L1_error
)
9952 __pyx_ptype_5numpy_ufunc
= __Pyx_ImportType(__pyx_t_1
, "numpy", "ufunc", sizeof(PyUFuncObject
), __Pyx_ImportType_CheckSize_Warn
);
9953 if (!__pyx_ptype_5numpy_ufunc
) __PYX_ERR(1, 918, __pyx_L1_error
)
9954 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
9955 __Pyx_RefNannyFinishContext();
9958 __Pyx_XDECREF(__pyx_t_1
);
9959 __Pyx_RefNannyFinishContext();
9963 static int __Pyx_modinit_variable_import_code(void) {
9964 __Pyx_RefNannyDeclarations
9965 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
9966 /*--- Variable import code ---*/
9967 __Pyx_RefNannyFinishContext();
9971 static int __Pyx_modinit_function_import_code(void) {
9972 __Pyx_RefNannyDeclarations
9973 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
9974 /*--- Function import code ---*/
9975 __Pyx_RefNannyFinishContext();
9980 #if PY_MAJOR_VERSION < 3
9981 #ifdef CYTHON_NO_PYINIT_EXPORT
9982 #define __Pyx_PyMODINIT_FUNC void
9984 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
9987 #ifdef CYTHON_NO_PYINIT_EXPORT
9988 #define __Pyx_PyMODINIT_FUNC PyObject *
9990 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
9995 #if PY_MAJOR_VERSION < 3
9996 __Pyx_PyMODINIT_FUNC
initSignal(void) CYTHON_SMALL_CODE
; /*proto*/
9997 __Pyx_PyMODINIT_FUNC
initSignal(void)
9999 __Pyx_PyMODINIT_FUNC
PyInit_Signal(void) CYTHON_SMALL_CODE
; /*proto*/
10000 __Pyx_PyMODINIT_FUNC
PyInit_Signal(void)
10001 #if CYTHON_PEP489_MULTI_PHASE_INIT
10003 return PyModuleDef_Init(&__pyx_moduledef
);
10005 static CYTHON_SMALL_CODE
int __Pyx_check_single_interpreter(void) {
10006 #if PY_VERSION_HEX >= 0x030700A1
10007 static PY_INT64_T main_interpreter_id
= -1;
10008 PY_INT64_T current_id
= PyInterpreterState_GetID(PyThreadState_Get()->interp
);
10009 if (main_interpreter_id
== -1) {
10010 main_interpreter_id
= current_id
;
10011 return (unlikely(current_id
== -1)) ? -1 : 0;
10012 } else if (unlikely(main_interpreter_id
!= current_id
))
10014 static PyInterpreterState
*main_interpreter
= NULL
;
10015 PyInterpreterState
*current_interpreter
= PyThreadState_Get()->interp
;
10016 if (!main_interpreter
) {
10017 main_interpreter
= current_interpreter
;
10018 } else if (unlikely(main_interpreter
!= current_interpreter
))
10023 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
10028 static CYTHON_SMALL_CODE
int __Pyx_copy_spec_to_module(PyObject
*spec
, PyObject
*moddict
, const char* from_name
, const char* to_name
, int allow_none
) {
10029 PyObject
*value
= PyObject_GetAttrString(spec
, from_name
);
10031 if (likely(value
)) {
10032 if (allow_none
|| value
!= Py_None
) {
10033 result
= PyDict_SetItemString(moddict
, to_name
, value
);
10036 } else if (PyErr_ExceptionMatches(PyExc_AttributeError
)) {
10043 static CYTHON_SMALL_CODE PyObject
* __pyx_pymod_create(PyObject
*spec
, CYTHON_UNUSED PyModuleDef
*def
) {
10044 PyObject
*module
= NULL
, *moddict
, *modname
;
10045 if (__Pyx_check_single_interpreter())
10048 return __Pyx_NewRef(__pyx_m
);
10049 modname
= PyObject_GetAttrString(spec
, "name");
10050 if (unlikely(!modname
)) goto bad
;
10051 module
= PyModule_NewObject(modname
);
10052 Py_DECREF(modname
);
10053 if (unlikely(!module
)) goto bad
;
10054 moddict
= PyModule_GetDict(module
);
10055 if (unlikely(!moddict
)) goto bad
;
10056 if (unlikely(__Pyx_copy_spec_to_module(spec
, moddict
, "loader", "__loader__", 1) < 0)) goto bad
;
10057 if (unlikely(__Pyx_copy_spec_to_module(spec
, moddict
, "origin", "__file__", 1) < 0)) goto bad
;
10058 if (unlikely(__Pyx_copy_spec_to_module(spec
, moddict
, "parent", "__package__", 1) < 0)) goto bad
;
10059 if (unlikely(__Pyx_copy_spec_to_module(spec
, moddict
, "submodule_search_locations", "__path__", 0) < 0)) goto bad
;
10062 Py_XDECREF(module
);
10067 static CYTHON_SMALL_CODE
int __pyx_pymod_exec_Signal(PyObject
*__pyx_pyinit_module
)
10071 __Pyx_TraceDeclarations
10072 PyObject
*__pyx_t_1
= NULL
;
10073 PyObject
*__pyx_t_2
= NULL
;
10074 __Pyx_RefNannyDeclarations
10075 #if CYTHON_PEP489_MULTI_PHASE_INIT
10077 if (__pyx_m
== __pyx_pyinit_module
) return 0;
10078 PyErr_SetString(PyExc_RuntimeError
, "Module 'Signal' has already been imported. Re-initialisation is not supported.");
10081 #elif PY_MAJOR_VERSION >= 3
10082 if (__pyx_m
) return __Pyx_NewRef(__pyx_m
);
10084 #if CYTHON_REFNANNY
10085 __Pyx_RefNanny
= __Pyx_RefNannyImportAPI("refnanny");
10086 if (!__Pyx_RefNanny
) {
10088 __Pyx_RefNanny
= __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
10089 if (!__Pyx_RefNanny
)
10090 Py_FatalError("failed to import 'refnanny' module");
10093 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_Signal(void)", 0);
10094 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10095 #ifdef __Pxy_PyFrame_Initialize_Offsets
10096 __Pxy_PyFrame_Initialize_Offsets();
10098 __pyx_empty_tuple
= PyTuple_New(0); if (unlikely(!__pyx_empty_tuple
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10099 __pyx_empty_bytes
= PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10100 __pyx_empty_unicode
= PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10101 #ifdef __Pyx_CyFunction_USED
10102 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10104 #ifdef __Pyx_FusedFunction_USED
10105 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10107 #ifdef __Pyx_Coroutine_USED
10108 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10110 #ifdef __Pyx_Generator_USED
10111 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10113 #ifdef __Pyx_AsyncGen_USED
10114 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10116 #ifdef __Pyx_StopAsyncIteration_USED
10117 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10119 /*--- Library function declarations ---*/
10120 /*--- Threads initialization code ---*/
10121 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
10122 #ifdef WITH_THREAD /* Python build with threading support? */
10123 PyEval_InitThreads();
10126 /*--- Module creation code ---*/
10127 #if CYTHON_PEP489_MULTI_PHASE_INIT
10128 __pyx_m
= __pyx_pyinit_module
;
10129 Py_INCREF(__pyx_m
);
10131 #if PY_MAJOR_VERSION < 3
10132 __pyx_m
= Py_InitModule4("Signal", __pyx_methods
, __pyx_k_Module_Description_functions_to
, 0, PYTHON_API_VERSION
); Py_XINCREF(__pyx_m
);
10134 __pyx_m
= PyModule_Create(&__pyx_moduledef
);
10136 if (unlikely(!__pyx_m
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10138 __pyx_d
= PyModule_GetDict(__pyx_m
); if (unlikely(!__pyx_d
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10139 Py_INCREF(__pyx_d
);
10140 __pyx_b
= PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME
); if (unlikely(!__pyx_b
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10141 Py_INCREF(__pyx_b
);
10142 __pyx_cython_runtime
= PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10143 Py_INCREF(__pyx_cython_runtime
);
10144 if (PyObject_SetAttrString(__pyx_m
, "__builtins__", __pyx_b
) < 0) __PYX_ERR(0, 1, __pyx_L1_error
);
10145 /*--- Initialize various global constants etc. ---*/
10146 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10147 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
10148 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10150 if (__pyx_module_is_main_MACS2__Signal
) {
10151 if (PyObject_SetAttr(__pyx_m
, __pyx_n_s_name
, __pyx_n_s_main
) < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10153 #if PY_MAJOR_VERSION >= 3
10155 PyObject
*modules
= PyImport_GetModuleDict(); if (unlikely(!modules
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10156 if (!PyDict_GetItemString(modules
, "MACS2.Signal")) {
10157 if (unlikely(PyDict_SetItemString(modules
, "MACS2.Signal", __pyx_m
) < 0)) __PYX_ERR(0, 1, __pyx_L1_error
)
10161 /*--- Builtin init code ---*/
10162 if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error
;
10163 /*--- Constants init code ---*/
10164 if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error
;
10165 /*--- Global type/function init code ---*/
10166 (void)__Pyx_modinit_global_init_code();
10167 (void)__Pyx_modinit_variable_export_code();
10168 (void)__Pyx_modinit_function_export_code();
10169 (void)__Pyx_modinit_type_init_code();
10170 if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error
;
10171 (void)__Pyx_modinit_variable_import_code();
10172 (void)__Pyx_modinit_function_import_code();
10173 /*--- Execution code ---*/
10174 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
10175 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10177 __Pyx_TraceCall("__Pyx_PyMODINIT_FUNC PyInit_Signal(void)", __pyx_f
[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error
));
10179 /* "MACS2/Signal.pyx":14
10181 * # smoothing function
10182 * import numpy as np # <<<<<<<<<<<<<<
10183 * cimport numpy as np
10184 * from cpython cimport bool
10186 __pyx_t_1
= __Pyx_Import(__pyx_n_s_numpy
, 0, 0); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 14, __pyx_L1_error
)
10187 __Pyx_GOTREF(__pyx_t_1
);
10188 if (PyDict_SetItem(__pyx_d
, __pyx_n_s_np
, __pyx_t_1
) < 0) __PYX_ERR(0, 14, __pyx_L1_error
)
10189 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
10191 /* "MACS2/Signal.pyx":17
10192 * cimport numpy as np
10193 * from cpython cimport bool
10194 * from math import sqrt as mathsqrt # <<<<<<<<<<<<<<
10195 * from math import factorial as mathfactorial
10198 __pyx_t_1
= PyList_New(1); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 17, __pyx_L1_error
)
10199 __Pyx_GOTREF(__pyx_t_1
);
10200 __Pyx_INCREF(__pyx_n_s_sqrt
);
10201 __Pyx_GIVEREF(__pyx_n_s_sqrt
);
10202 PyList_SET_ITEM(__pyx_t_1
, 0, __pyx_n_s_sqrt
);
10203 __pyx_t_2
= __Pyx_Import(__pyx_n_s_math
, __pyx_t_1
, 0); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 17, __pyx_L1_error
)
10204 __Pyx_GOTREF(__pyx_t_2
);
10205 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
10206 __pyx_t_1
= __Pyx_ImportFrom(__pyx_t_2
, __pyx_n_s_sqrt
); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 17, __pyx_L1_error
)
10207 __Pyx_GOTREF(__pyx_t_1
);
10208 if (PyDict_SetItem(__pyx_d
, __pyx_n_s_mathsqrt
, __pyx_t_1
) < 0) __PYX_ERR(0, 17, __pyx_L1_error
)
10209 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
10210 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
10212 /* "MACS2/Signal.pyx":18
10213 * from cpython cimport bool
10214 * from math import sqrt as mathsqrt
10215 * from math import factorial as mathfactorial # <<<<<<<<<<<<<<
10217 * cpdef np.ndarray[np.int32_t, ndim=1] maxima(np.ndarray[np.float32_t, ndim=1] signal,
10219 __pyx_t_2
= PyList_New(1); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 18, __pyx_L1_error
)
10220 __Pyx_GOTREF(__pyx_t_2
);
10221 __Pyx_INCREF(__pyx_n_s_factorial
);
10222 __Pyx_GIVEREF(__pyx_n_s_factorial
);
10223 PyList_SET_ITEM(__pyx_t_2
, 0, __pyx_n_s_factorial
);
10224 __pyx_t_1
= __Pyx_Import(__pyx_n_s_math
, __pyx_t_2
, 0); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 18, __pyx_L1_error
)
10225 __Pyx_GOTREF(__pyx_t_1
);
10226 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
10227 __pyx_t_2
= __Pyx_ImportFrom(__pyx_t_1
, __pyx_n_s_factorial
); if (unlikely(!__pyx_t_2
)) __PYX_ERR(0, 18, __pyx_L1_error
)
10228 __Pyx_GOTREF(__pyx_t_2
);
10229 if (PyDict_SetItem(__pyx_d
, __pyx_n_s_mathfactorial
, __pyx_t_2
) < 0) __PYX_ERR(0, 18, __pyx_L1_error
)
10230 __Pyx_DECREF(__pyx_t_2
); __pyx_t_2
= 0;
10231 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
10233 /* "MACS2/Signal.pyx":1
10234 * # cython: language_level=3 # <<<<<<<<<<<<<<
10235 * # cython: profile=True
10236 * # Time-stamp: <2019-12-18 16:49:03 taoliu>
10238 __pyx_t_1
= __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1
)) __PYX_ERR(0, 1, __pyx_L1_error
)
10239 __Pyx_GOTREF(__pyx_t_1
);
10240 if (PyDict_SetItem(__pyx_d
, __pyx_n_s_test
, __pyx_t_1
) < 0) __PYX_ERR(0, 1, __pyx_L1_error
)
10241 __Pyx_DECREF(__pyx_t_1
); __pyx_t_1
= 0;
10243 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1046
10244 * raise ImportError("numpy.core.umath failed to import")
10246 * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
10250 __Pyx_TraceReturn(Py_None
, 0);
10252 /*--- Wrapped vars code ---*/
10256 __Pyx_XDECREF(__pyx_t_1
);
10257 __Pyx_XDECREF(__pyx_t_2
);
10260 __Pyx_AddTraceback("init MACS2.Signal", __pyx_clineno
, __pyx_lineno
, __pyx_filename
);
10263 } else if (!PyErr_Occurred()) {
10264 PyErr_SetString(PyExc_ImportError
, "init MACS2.Signal");
10267 __Pyx_RefNannyFinishContext();
10268 #if CYTHON_PEP489_MULTI_PHASE_INIT
10269 return (__pyx_m
!= NULL
) ? 0 : -1;
10270 #elif PY_MAJOR_VERSION >= 3
10277 /* --- Runtime support code --- */
10279 #if CYTHON_REFNANNY
10280 static __Pyx_RefNannyAPIStruct
*__Pyx_RefNannyImportAPI(const char *modname
) {
10281 PyObject
*m
= NULL
, *p
= NULL
;
10283 m
= PyImport_ImportModule(modname
);
10285 p
= PyObject_GetAttrString(m
, "RefNannyAPI");
10287 r
= PyLong_AsVoidPtr(p
);
10291 return (__Pyx_RefNannyAPIStruct
*)r
;
10295 /* PyObjectGetAttrStr */
10296 #if CYTHON_USE_TYPE_SLOTS
10297 static CYTHON_INLINE PyObject
* __Pyx_PyObject_GetAttrStr(PyObject
* obj
, PyObject
* attr_name
) {
10298 PyTypeObject
* tp
= Py_TYPE(obj
);
10299 if (likely(tp
->tp_getattro
))
10300 return tp
->tp_getattro(obj
, attr_name
);
10301 #if PY_MAJOR_VERSION < 3
10302 if (likely(tp
->tp_getattr
))
10303 return tp
->tp_getattr(obj
, PyString_AS_STRING(attr_name
));
10305 return PyObject_GetAttr(obj
, attr_name
);
10309 /* GetBuiltinName */
10310 static PyObject
*__Pyx_GetBuiltinName(PyObject
*name
) {
10311 PyObject
* result
= __Pyx_PyObject_GetAttrStr(__pyx_b
, name
);
10312 if (unlikely(!result
)) {
10313 PyErr_Format(PyExc_NameError
,
10314 #if PY_MAJOR_VERSION >= 3
10315 "name '%U' is not defined", name
);
10317 "name '%.200s' is not defined", PyString_AS_STRING(name
));
10323 /* PyErrFetchRestore */
10324 #if CYTHON_FAST_THREAD_STATE
10325 static CYTHON_INLINE
void __Pyx_ErrRestoreInState(PyThreadState
*tstate
, PyObject
*type
, PyObject
*value
, PyObject
*tb
) {
10326 PyObject
*tmp_type
, *tmp_value
, *tmp_tb
;
10327 tmp_type
= tstate
->curexc_type
;
10328 tmp_value
= tstate
->curexc_value
;
10329 tmp_tb
= tstate
->curexc_traceback
;
10330 tstate
->curexc_type
= type
;
10331 tstate
->curexc_value
= value
;
10332 tstate
->curexc_traceback
= tb
;
10333 Py_XDECREF(tmp_type
);
10334 Py_XDECREF(tmp_value
);
10335 Py_XDECREF(tmp_tb
);
10337 static CYTHON_INLINE
void __Pyx_ErrFetchInState(PyThreadState
*tstate
, PyObject
**type
, PyObject
**value
, PyObject
**tb
) {
10338 *type
= tstate
->curexc_type
;
10339 *value
= tstate
->curexc_value
;
10340 *tb
= tstate
->curexc_traceback
;
10341 tstate
->curexc_type
= 0;
10342 tstate
->curexc_value
= 0;
10343 tstate
->curexc_traceback
= 0;
10349 static int __Pyx_TraceSetupAndCall(PyCodeObject
** code
,
10350 PyFrameObject
** frame
,
10351 PyThreadState
* tstate
,
10352 const char *funcname
,
10353 const char *srcfile
,
10355 PyObject
*type
, *value
, *traceback
;
10357 if (*frame
== NULL
|| !CYTHON_PROFILE_REUSE_FRAME
) {
10358 if (*code
== NULL
) {
10359 *code
= __Pyx_createFrameCodeObject(funcname
, srcfile
, firstlineno
);
10360 if (*code
== NULL
) return 0;
10362 *frame
= PyFrame_New(
10363 tstate
, /*PyThreadState *tstate*/
10364 *code
, /*PyCodeObject *code*/
10365 __pyx_d
, /*PyObject *globals*/
10366 0 /*PyObject *locals*/
10368 if (*frame
== NULL
) return 0;
10369 if (CYTHON_TRACE
&& (*frame
)->f_trace
== NULL
) {
10370 Py_INCREF(Py_None
);
10371 (*frame
)->f_trace
= Py_None
;
10373 #if PY_VERSION_HEX < 0x030400B1
10375 (*frame
)->f_tstate
= tstate
;
10378 __Pyx_PyFrame_SetLineNumber(*frame
, firstlineno
);
10381 tstate
->use_tracing
= 0;
10382 __Pyx_ErrFetchInState(tstate
, &type
, &value
, &traceback
);
10384 if (tstate
->c_tracefunc
)
10385 retval
= tstate
->c_tracefunc(tstate
->c_traceobj
, *frame
, PyTrace_CALL
, NULL
) == 0;
10386 if (retval
&& tstate
->c_profilefunc
)
10388 retval
= tstate
->c_profilefunc(tstate
->c_profileobj
, *frame
, PyTrace_CALL
, NULL
) == 0;
10389 tstate
->use_tracing
= (tstate
->c_profilefunc
||
10390 (CYTHON_TRACE
&& tstate
->c_tracefunc
));
10393 __Pyx_ErrRestoreInState(tstate
, type
, value
, traceback
);
10394 return tstate
->use_tracing
&& retval
;
10398 Py_XDECREF(traceback
);
10402 static PyCodeObject
*__Pyx_createFrameCodeObject(const char *funcname
, const char *srcfile
, int firstlineno
) {
10403 PyCodeObject
*py_code
= 0;
10404 #if PY_MAJOR_VERSION >= 3
10405 py_code
= PyCode_NewEmpty(srcfile
, funcname
, firstlineno
);
10406 if (likely(py_code
)) {
10407 py_code
->co_flags
|= CO_OPTIMIZED
| CO_NEWLOCALS
;
10410 PyObject
*py_srcfile
= 0;
10411 PyObject
*py_funcname
= 0;
10412 py_funcname
= PyString_FromString(funcname
);
10413 if (unlikely(!py_funcname
)) goto bad
;
10414 py_srcfile
= PyString_FromString(srcfile
);
10415 if (unlikely(!py_srcfile
)) goto bad
;
10416 py_code
= PyCode_New(
10420 CO_OPTIMIZED
| CO_NEWLOCALS
,
10421 __pyx_empty_bytes
, /*PyObject *code,*/
10422 __pyx_empty_tuple
, /*PyObject *consts,*/
10423 __pyx_empty_tuple
, /*PyObject *names,*/
10424 __pyx_empty_tuple
, /*PyObject *varnames,*/
10425 __pyx_empty_tuple
, /*PyObject *freevars,*/
10426 __pyx_empty_tuple
, /*PyObject *cellvars,*/
10427 py_srcfile
, /*PyObject *filename,*/
10428 py_funcname
, /*PyObject *name,*/
10430 __pyx_empty_bytes
/*PyObject *lnotab*/
10433 Py_XDECREF(py_srcfile
);
10434 Py_XDECREF(py_funcname
);
10440 /* IsLittleEndian */
10441 static CYTHON_INLINE
int __Pyx_Is_Little_Endian(void)
10447 S
.u32
= 0x01020304;
10448 return S
.u8
[0] == 4;
10451 /* BufferFormatCheck */
10452 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context
* ctx
,
10453 __Pyx_BufFmt_StackElem
* stack
,
10454 __Pyx_TypeInfo
* type
) {
10455 stack
[0].field
= &ctx
->root
;
10456 stack
[0].parent_offset
= 0;
10457 ctx
->root
.type
= type
;
10458 ctx
->root
.name
= "buffer dtype";
10459 ctx
->root
.offset
= 0;
10461 ctx
->head
->field
= &ctx
->root
;
10462 ctx
->fmt_offset
= 0;
10463 ctx
->head
->parent_offset
= 0;
10464 ctx
->new_packmode
= '@';
10465 ctx
->enc_packmode
= '@';
10466 ctx
->new_count
= 1;
10467 ctx
->enc_count
= 0;
10469 ctx
->is_complex
= 0;
10470 ctx
->is_valid_array
= 0;
10471 ctx
->struct_alignment
= 0;
10472 while (type
->typegroup
== 'S') {
10474 ctx
->head
->field
= type
->fields
;
10475 ctx
->head
->parent_offset
= 0;
10476 type
= type
->fields
->type
;
10479 static int __Pyx_BufFmt_ParseNumber(const char** ts
) {
10481 const char* t
= *ts
;
10482 if (*t
< '0' || *t
> '9') {
10485 count
= *t
++ - '0';
10486 while (*t
>= '0' && *t
<= '9') {
10488 count
+= *t
++ - '0';
10494 static int __Pyx_BufFmt_ExpectNumber(const char **ts
) {
10495 int number
= __Pyx_BufFmt_ParseNumber(ts
);
10497 PyErr_Format(PyExc_ValueError
,\
10498 "Does not understand character buffer dtype format string ('%c')", **ts
);
10501 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch
) {
10502 PyErr_Format(PyExc_ValueError
,
10503 "Unexpected format string character: '%c'", ch
);
10505 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch
, int is_complex
) {
10507 case '?': return "'bool'";
10508 case 'c': return "'char'";
10509 case 'b': return "'signed char'";
10510 case 'B': return "'unsigned char'";
10511 case 'h': return "'short'";
10512 case 'H': return "'unsigned short'";
10513 case 'i': return "'int'";
10514 case 'I': return "'unsigned int'";
10515 case 'l': return "'long'";
10516 case 'L': return "'unsigned long'";
10517 case 'q': return "'long long'";
10518 case 'Q': return "'unsigned long long'";
10519 case 'f': return (is_complex
? "'complex float'" : "'float'");
10520 case 'd': return (is_complex
? "'complex double'" : "'double'");
10521 case 'g': return (is_complex
? "'complex long double'" : "'long double'");
10522 case 'T': return "a struct";
10523 case 'O': return "Python object";
10524 case 'P': return "a pointer";
10525 case 's': case 'p': return "a string";
10526 case 0: return "end";
10527 default: return "unparseable format string";
10530 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch
, int is_complex
) {
10532 case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
10533 case 'h': case 'H': return 2;
10534 case 'i': case 'I': case 'l': case 'L': return 4;
10535 case 'q': case 'Q': return 8;
10536 case 'f': return (is_complex
? 8 : 4);
10537 case 'd': return (is_complex
? 16 : 8);
10539 PyErr_SetString(PyExc_ValueError
, "Python does not define a standard format string size for long double ('g')..");
10542 case 'O': case 'P': return sizeof(void*);
10544 __Pyx_BufFmt_RaiseUnexpectedChar(ch
);
10548 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch
, int is_complex
) {
10550 case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
10551 case 'h': case 'H': return sizeof(short);
10552 case 'i': case 'I': return sizeof(int);
10553 case 'l': case 'L': return sizeof(long);
10554 #ifdef HAVE_LONG_LONG
10555 case 'q': case 'Q': return sizeof(PY_LONG_LONG
);
10557 case 'f': return sizeof(float) * (is_complex
? 2 : 1);
10558 case 'd': return sizeof(double) * (is_complex
? 2 : 1);
10559 case 'g': return sizeof(long double) * (is_complex
? 2 : 1);
10560 case 'O': case 'P': return sizeof(void*);
10562 __Pyx_BufFmt_RaiseUnexpectedChar(ch
);
10567 typedef struct { char c
; short x
; } __Pyx_st_short
;
10568 typedef struct { char c
; int x
; } __Pyx_st_int
;
10569 typedef struct { char c
; long x
; } __Pyx_st_long
;
10570 typedef struct { char c
; float x
; } __Pyx_st_float
;
10571 typedef struct { char c
; double x
; } __Pyx_st_double
;
10572 typedef struct { char c
; long double x
; } __Pyx_st_longdouble
;
10573 typedef struct { char c
; void *x
; } __Pyx_st_void_p
;
10574 #ifdef HAVE_LONG_LONG
10575 typedef struct { char c
; PY_LONG_LONG x
; } __Pyx_st_longlong
;
10577 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch
, CYTHON_UNUSED
int is_complex
) {
10579 case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
10580 case 'h': case 'H': return sizeof(__Pyx_st_short
) - sizeof(short);
10581 case 'i': case 'I': return sizeof(__Pyx_st_int
) - sizeof(int);
10582 case 'l': case 'L': return sizeof(__Pyx_st_long
) - sizeof(long);
10583 #ifdef HAVE_LONG_LONG
10584 case 'q': case 'Q': return sizeof(__Pyx_st_longlong
) - sizeof(PY_LONG_LONG
);
10586 case 'f': return sizeof(__Pyx_st_float
) - sizeof(float);
10587 case 'd': return sizeof(__Pyx_st_double
) - sizeof(double);
10588 case 'g': return sizeof(__Pyx_st_longdouble
) - sizeof(long double);
10589 case 'P': case 'O': return sizeof(__Pyx_st_void_p
) - sizeof(void*);
10591 __Pyx_BufFmt_RaiseUnexpectedChar(ch
);
10595 /* These are for computing the padding at the end of the struct to align
10596 on the first member of the struct. This will probably the same as above,
10597 but we don't have any guarantees.
10599 typedef struct { short x
; char c
; } __Pyx_pad_short
;
10600 typedef struct { int x
; char c
; } __Pyx_pad_int
;
10601 typedef struct { long x
; char c
; } __Pyx_pad_long
;
10602 typedef struct { float x
; char c
; } __Pyx_pad_float
;
10603 typedef struct { double x
; char c
; } __Pyx_pad_double
;
10604 typedef struct { long double x
; char c
; } __Pyx_pad_longdouble
;
10605 typedef struct { void *x
; char c
; } __Pyx_pad_void_p
;
10606 #ifdef HAVE_LONG_LONG
10607 typedef struct { PY_LONG_LONG x
; char c
; } __Pyx_pad_longlong
;
10609 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch
, CYTHON_UNUSED
int is_complex
) {
10611 case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
10612 case 'h': case 'H': return sizeof(__Pyx_pad_short
) - sizeof(short);
10613 case 'i': case 'I': return sizeof(__Pyx_pad_int
) - sizeof(int);
10614 case 'l': case 'L': return sizeof(__Pyx_pad_long
) - sizeof(long);
10615 #ifdef HAVE_LONG_LONG
10616 case 'q': case 'Q': return sizeof(__Pyx_pad_longlong
) - sizeof(PY_LONG_LONG
);
10618 case 'f': return sizeof(__Pyx_pad_float
) - sizeof(float);
10619 case 'd': return sizeof(__Pyx_pad_double
) - sizeof(double);
10620 case 'g': return sizeof(__Pyx_pad_longdouble
) - sizeof(long double);
10621 case 'P': case 'O': return sizeof(__Pyx_pad_void_p
) - sizeof(void*);
10623 __Pyx_BufFmt_RaiseUnexpectedChar(ch
);
10627 static char __Pyx_BufFmt_TypeCharToGroup(char ch
, int is_complex
) {
10631 case 'b': case 'h': case 'i':
10632 case 'l': case 'q': case 's': case 'p':
10634 case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
10636 case 'f': case 'd': case 'g':
10637 return (is_complex
? 'C' : 'R');
10643 __Pyx_BufFmt_RaiseUnexpectedChar(ch
);
10648 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context
* ctx
) {
10649 if (ctx
->head
== NULL
|| ctx
->head
->field
== &ctx
->root
) {
10650 const char* expected
;
10652 if (ctx
->head
== NULL
) {
10656 expected
= ctx
->head
->field
->type
->name
;
10659 PyErr_Format(PyExc_ValueError
,
10660 "Buffer dtype mismatch, expected %s%s%s but got %s",
10661 quote
, expected
, quote
,
10662 __Pyx_BufFmt_DescribeTypeChar(ctx
->enc_type
, ctx
->is_complex
));
10664 __Pyx_StructField
* field
= ctx
->head
->field
;
10665 __Pyx_StructField
* parent
= (ctx
->head
- 1)->field
;
10666 PyErr_Format(PyExc_ValueError
,
10667 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
10668 field
->type
->name
, __Pyx_BufFmt_DescribeTypeChar(ctx
->enc_type
, ctx
->is_complex
),
10669 parent
->type
->name
, field
->name
);
10672 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context
* ctx
) {
10674 size_t size
, offset
, arraysize
= 1;
10675 if (ctx
->enc_type
== 0) return 0;
10676 if (ctx
->head
->field
->type
->arraysize
[0]) {
10678 if (ctx
->enc_type
== 's' || ctx
->enc_type
== 'p') {
10679 ctx
->is_valid_array
= ctx
->head
->field
->type
->ndim
== 1;
10681 if (ctx
->enc_count
!= ctx
->head
->field
->type
->arraysize
[0]) {
10682 PyErr_Format(PyExc_ValueError
,
10683 "Expected a dimension of size %zu, got %zu",
10684 ctx
->head
->field
->type
->arraysize
[0], ctx
->enc_count
);
10688 if (!ctx
->is_valid_array
) {
10689 PyErr_Format(PyExc_ValueError
, "Expected %d dimensions, got %d",
10690 ctx
->head
->field
->type
->ndim
, ndim
);
10693 for (i
= 0; i
< ctx
->head
->field
->type
->ndim
; i
++) {
10694 arraysize
*= ctx
->head
->field
->type
->arraysize
[i
];
10696 ctx
->is_valid_array
= 0;
10697 ctx
->enc_count
= 1;
10699 group
= __Pyx_BufFmt_TypeCharToGroup(ctx
->enc_type
, ctx
->is_complex
);
10701 __Pyx_StructField
* field
= ctx
->head
->field
;
10702 __Pyx_TypeInfo
* type
= field
->type
;
10703 if (ctx
->enc_packmode
== '@' || ctx
->enc_packmode
== '^') {
10704 size
= __Pyx_BufFmt_TypeCharToNativeSize(ctx
->enc_type
, ctx
->is_complex
);
10706 size
= __Pyx_BufFmt_TypeCharToStandardSize(ctx
->enc_type
, ctx
->is_complex
);
10708 if (ctx
->enc_packmode
== '@') {
10709 size_t align_at
= __Pyx_BufFmt_TypeCharToAlignment(ctx
->enc_type
, ctx
->is_complex
);
10710 size_t align_mod_offset
;
10711 if (align_at
== 0) return -1;
10712 align_mod_offset
= ctx
->fmt_offset
% align_at
;
10713 if (align_mod_offset
> 0) ctx
->fmt_offset
+= align_at
- align_mod_offset
;
10714 if (ctx
->struct_alignment
== 0)
10715 ctx
->struct_alignment
= __Pyx_BufFmt_TypeCharToPadding(ctx
->enc_type
,
10718 if (type
->size
!= size
|| type
->typegroup
!= group
) {
10719 if (type
->typegroup
== 'C' && type
->fields
!= NULL
) {
10720 size_t parent_offset
= ctx
->head
->parent_offset
+ field
->offset
;
10722 ctx
->head
->field
= type
->fields
;
10723 ctx
->head
->parent_offset
= parent_offset
;
10726 if ((type
->typegroup
== 'H' || group
== 'H') && type
->size
== size
) {
10728 __Pyx_BufFmt_RaiseExpected(ctx
);
10732 offset
= ctx
->head
->parent_offset
+ field
->offset
;
10733 if (ctx
->fmt_offset
!= offset
) {
10734 PyErr_Format(PyExc_ValueError
,
10735 "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T
"d but %" CYTHON_FORMAT_SSIZE_T
"d expected",
10736 (Py_ssize_t
)ctx
->fmt_offset
, (Py_ssize_t
)offset
);
10739 ctx
->fmt_offset
+= size
;
10741 ctx
->fmt_offset
+= (arraysize
- 1) * size
;
10744 if (field
== &ctx
->root
) {
10746 if (ctx
->enc_count
!= 0) {
10747 __Pyx_BufFmt_RaiseExpected(ctx
);
10752 ctx
->head
->field
= ++field
;
10753 if (field
->type
== NULL
) {
10755 field
= ctx
->head
->field
;
10757 } else if (field
->type
->typegroup
== 'S') {
10758 size_t parent_offset
= ctx
->head
->parent_offset
+ field
->offset
;
10759 if (field
->type
->fields
->type
== NULL
) continue;
10760 field
= field
->type
->fields
;
10762 ctx
->head
->field
= field
;
10763 ctx
->head
->parent_offset
= parent_offset
;
10769 } while (ctx
->enc_count
);
10771 ctx
->is_complex
= 0;
10775 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context
* ctx
, const char** tsp
)
10777 const char *ts
= *tsp
;
10779 int ndim
= ctx
->head
->field
->type
->ndim
;
10782 if (ctx
->new_count
!= 1) {
10783 PyErr_SetString(PyExc_ValueError
,
10784 "Cannot handle repeated arrays in format string");
10787 if (__Pyx_BufFmt_ProcessTypeChunk(ctx
) == -1) return NULL
;
10788 while (*ts
&& *ts
!= ')') {
10790 case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue;
10793 number
= __Pyx_BufFmt_ExpectNumber(&ts
);
10794 if (number
== -1) return NULL
;
10795 if (i
< ndim
&& (size_t) number
!= ctx
->head
->field
->type
->arraysize
[i
])
10796 return PyErr_Format(PyExc_ValueError
,
10797 "Expected a dimension of size %zu, got %d",
10798 ctx
->head
->field
->type
->arraysize
[i
], number
);
10799 if (*ts
!= ',' && *ts
!= ')')
10800 return PyErr_Format(PyExc_ValueError
,
10801 "Expected a comma in format string, got '%c'", *ts
);
10802 if (*ts
== ',') ts
++;
10806 return PyErr_Format(PyExc_ValueError
, "Expected %d dimension(s), got %d",
10807 ctx
->head
->field
->type
->ndim
, i
);
10809 PyErr_SetString(PyExc_ValueError
,
10810 "Unexpected end of format string, expected ')'");
10813 ctx
->is_valid_array
= 1;
10814 ctx
->new_count
= 1;
10818 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context
* ctx
, const char* ts
) {
10823 if (ctx
->enc_type
!= 0 && ctx
->head
== NULL
) {
10824 __Pyx_BufFmt_RaiseExpected(ctx
);
10827 if (__Pyx_BufFmt_ProcessTypeChunk(ctx
) == -1) return NULL
;
10828 if (ctx
->head
!= NULL
) {
10829 __Pyx_BufFmt_RaiseExpected(ctx
);
10839 if (!__Pyx_Is_Little_Endian()) {
10840 PyErr_SetString(PyExc_ValueError
, "Little-endian buffer not supported on big-endian compiler");
10843 ctx
->new_packmode
= '=';
10848 if (__Pyx_Is_Little_Endian()) {
10849 PyErr_SetString(PyExc_ValueError
, "Big-endian buffer not supported on little-endian compiler");
10852 ctx
->new_packmode
= '=';
10858 ctx
->new_packmode
= *ts
++;
10862 const char* ts_after_sub
;
10863 size_t i
, struct_count
= ctx
->new_count
;
10864 size_t struct_alignment
= ctx
->struct_alignment
;
10865 ctx
->new_count
= 1;
10868 PyErr_SetString(PyExc_ValueError
, "Buffer acquisition: Expected '{' after 'T'");
10871 if (__Pyx_BufFmt_ProcessTypeChunk(ctx
) == -1) return NULL
;
10873 ctx
->enc_count
= 0;
10874 ctx
->struct_alignment
= 0;
10877 for (i
= 0; i
!= struct_count
; ++i
) {
10878 ts_after_sub
= __Pyx_BufFmt_CheckString(ctx
, ts
);
10879 if (!ts_after_sub
) return NULL
;
10882 if (struct_alignment
) ctx
->struct_alignment
= struct_alignment
;
10887 size_t alignment
= ctx
->struct_alignment
;
10889 if (__Pyx_BufFmt_ProcessTypeChunk(ctx
) == -1) return NULL
;
10891 if (alignment
&& ctx
->fmt_offset
% alignment
) {
10892 ctx
->fmt_offset
+= alignment
- (ctx
->fmt_offset
% alignment
);
10897 if (__Pyx_BufFmt_ProcessTypeChunk(ctx
) == -1) return NULL
;
10898 ctx
->fmt_offset
+= ctx
->new_count
;
10899 ctx
->new_count
= 1;
10900 ctx
->enc_count
= 0;
10902 ctx
->enc_packmode
= ctx
->new_packmode
;
10908 if (*ts
!= 'f' && *ts
!= 'd' && *ts
!= 'g') {
10909 __Pyx_BufFmt_RaiseUnexpectedChar('Z');
10912 CYTHON_FALLTHROUGH
;
10913 case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
10914 case 'l': case 'L': case 'q': case 'Q':
10915 case 'f': case 'd': case 'g':
10916 case 'O': case 'p':
10917 if (ctx
->enc_type
== *ts
&& got_Z
== ctx
->is_complex
&&
10918 ctx
->enc_packmode
== ctx
->new_packmode
) {
10919 ctx
->enc_count
+= ctx
->new_count
;
10920 ctx
->new_count
= 1;
10925 CYTHON_FALLTHROUGH
;
10927 if (__Pyx_BufFmt_ProcessTypeChunk(ctx
) == -1) return NULL
;
10928 ctx
->enc_count
= ctx
->new_count
;
10929 ctx
->enc_packmode
= ctx
->new_packmode
;
10930 ctx
->enc_type
= *ts
;
10931 ctx
->is_complex
= got_Z
;
10933 ctx
->new_count
= 1;
10938 while(*ts
!= ':') ++ts
;
10942 if (!__pyx_buffmt_parse_array(ctx
, &ts
)) return NULL
;
10946 int number
= __Pyx_BufFmt_ExpectNumber(&ts
);
10947 if (number
== -1) return NULL
;
10948 ctx
->new_count
= (size_t)number
;
10954 /* BufferGetAndValidate */
10955 static CYTHON_INLINE
void __Pyx_SafeReleaseBuffer(Py_buffer
* info
) {
10956 if (unlikely(info
->buf
== NULL
)) return;
10957 if (info
->suboffsets
== __Pyx_minusones
) info
->suboffsets
= NULL
;
10958 __Pyx_ReleaseBuffer(info
);
10960 static void __Pyx_ZeroBuffer(Py_buffer
* buf
) {
10963 buf
->strides
= __Pyx_zeros
;
10964 buf
->shape
= __Pyx_zeros
;
10965 buf
->suboffsets
= __Pyx_minusones
;
10967 static int __Pyx__GetBufferAndValidate(
10968 Py_buffer
* buf
, PyObject
* obj
, __Pyx_TypeInfo
* dtype
, int flags
,
10969 int nd
, int cast
, __Pyx_BufFmt_StackElem
* stack
)
10972 if (unlikely(__Pyx_GetBuffer(obj
, buf
, flags
) == -1)) {
10973 __Pyx_ZeroBuffer(buf
);
10976 if (unlikely(buf
->ndim
!= nd
)) {
10977 PyErr_Format(PyExc_ValueError
,
10978 "Buffer has wrong number of dimensions (expected %d, got %d)",
10983 __Pyx_BufFmt_Context ctx
;
10984 __Pyx_BufFmt_Init(&ctx
, stack
, dtype
);
10985 if (!__Pyx_BufFmt_CheckString(&ctx
, buf
->format
)) goto fail
;
10987 if (unlikely((size_t)buf
->itemsize
!= dtype
->size
)) {
10988 PyErr_Format(PyExc_ValueError
,
10989 "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T
"d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T
"d byte%s)",
10990 buf
->itemsize
, (buf
->itemsize
> 1) ? "s" : "",
10991 dtype
->name
, (Py_ssize_t
)dtype
->size
, (dtype
->size
> 1) ? "s" : "");
10994 if (buf
->suboffsets
== NULL
) buf
->suboffsets
= __Pyx_minusones
;
10997 __Pyx_SafeReleaseBuffer(buf
);
11002 static CYTHON_INLINE
long __Pyx_div_long(long a
, long b
) {
11005 q
-= ((r
!= 0) & ((r
^ b
) < 0));
11009 /* PyCFunctionFastCall */
11010 #if CYTHON_FAST_PYCCALL
11011 static CYTHON_INLINE PyObject
* __Pyx_PyCFunction_FastCall(PyObject
*func_obj
, PyObject
**args
, Py_ssize_t nargs
) {
11012 PyCFunctionObject
*func
= (PyCFunctionObject
*)func_obj
;
11013 PyCFunction meth
= PyCFunction_GET_FUNCTION(func
);
11014 PyObject
*self
= PyCFunction_GET_SELF(func
);
11015 int flags
= PyCFunction_GET_FLAGS(func
);
11016 assert(PyCFunction_Check(func
));
11017 assert(METH_FASTCALL
== (flags
& ~(METH_CLASS
| METH_STATIC
| METH_COEXIST
| METH_KEYWORDS
| METH_STACKLESS
)));
11018 assert(nargs
>= 0);
11019 assert(nargs
== 0 || args
!= NULL
);
11020 /* _PyCFunction_FastCallDict() must not be called with an exception set,
11021 because it may clear it (directly or indirectly) and so the
11022 caller loses its exception */
11023 assert(!PyErr_Occurred());
11024 if ((PY_VERSION_HEX
< 0x030700A0) || unlikely(flags
& METH_KEYWORDS
)) {
11025 return (*((__Pyx_PyCFunctionFastWithKeywords
)(void*)meth
)) (self
, args
, nargs
, NULL
);
11027 return (*((__Pyx_PyCFunctionFast
)(void*)meth
)) (self
, args
, nargs
);
11032 /* PyFunctionFastCall */
11033 #if CYTHON_FAST_PYCALL
11034 static PyObject
* __Pyx_PyFunction_FastCallNoKw(PyCodeObject
*co
, PyObject
**args
, Py_ssize_t na
,
11035 PyObject
*globals
) {
11037 PyThreadState
*tstate
= __Pyx_PyThreadState_Current
;
11038 PyObject
**fastlocals
;
11041 assert(globals
!= NULL
);
11042 /* XXX Perhaps we should create a specialized
11043 PyFrame_New() that doesn't take locals, but does
11044 take builtins without sanity checking them.
11046 assert(tstate
!= NULL
);
11047 f
= PyFrame_New(tstate
, co
, globals
, NULL
);
11051 fastlocals
= __Pyx_PyFrame_GetLocalsplus(f
);
11052 for (i
= 0; i
< na
; i
++) {
11054 fastlocals
[i
] = *args
++;
11056 result
= PyEval_EvalFrameEx(f
,0);
11057 ++tstate
->recursion_depth
;
11059 --tstate
->recursion_depth
;
11062 #if 1 || PY_VERSION_HEX < 0x030600B1
11063 static PyObject
*__Pyx_PyFunction_FastCallDict(PyObject
*func
, PyObject
**args
, Py_ssize_t nargs
, PyObject
*kwargs
) {
11064 PyCodeObject
*co
= (PyCodeObject
*)PyFunction_GET_CODE(func
);
11065 PyObject
*globals
= PyFunction_GET_GLOBALS(func
);
11066 PyObject
*argdefs
= PyFunction_GET_DEFAULTS(func
);
11068 #if PY_MAJOR_VERSION >= 3
11071 PyObject
*kwtuple
, **k
;
11076 assert(kwargs
== NULL
|| PyDict_Check(kwargs
));
11077 nk
= kwargs
? PyDict_Size(kwargs
) : 0;
11078 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
11082 #if PY_MAJOR_VERSION >= 3
11083 co
->co_kwonlyargcount
== 0 &&
11085 likely(kwargs
== NULL
|| nk
== 0) &&
11086 co
->co_flags
== (CO_OPTIMIZED
| CO_NEWLOCALS
| CO_NOFREE
)) {
11087 if (argdefs
== NULL
&& co
->co_argcount
== nargs
) {
11088 result
= __Pyx_PyFunction_FastCallNoKw(co
, args
, nargs
, globals
);
11091 else if (nargs
== 0 && argdefs
!= NULL
11092 && co
->co_argcount
== Py_SIZE(argdefs
)) {
11093 /* function called with no arguments, but all parameters have
11094 a default value: use default values as arguments .*/
11095 args
= &PyTuple_GET_ITEM(argdefs
, 0);
11096 result
=__Pyx_PyFunction_FastCallNoKw(co
, args
, Py_SIZE(argdefs
), globals
);
11100 if (kwargs
!= NULL
) {
11102 kwtuple
= PyTuple_New(2 * nk
);
11103 if (kwtuple
== NULL
) {
11107 k
= &PyTuple_GET_ITEM(kwtuple
, 0);
11109 while (PyDict_Next(kwargs
, &pos
, &k
[i
], &k
[i
+1])) {
11120 closure
= PyFunction_GET_CLOSURE(func
);
11121 #if PY_MAJOR_VERSION >= 3
11122 kwdefs
= PyFunction_GET_KW_DEFAULTS(func
);
11124 if (argdefs
!= NULL
) {
11125 d
= &PyTuple_GET_ITEM(argdefs
, 0);
11126 nd
= Py_SIZE(argdefs
);
11132 #if PY_MAJOR_VERSION >= 3
11133 result
= PyEval_EvalCodeEx((PyObject
*)co
, globals
, (PyObject
*)NULL
,
11136 d
, (int)nd
, kwdefs
, closure
);
11138 result
= PyEval_EvalCodeEx(co
, globals
, (PyObject
*)NULL
,
11141 d
, (int)nd
, closure
);
11143 Py_XDECREF(kwtuple
);
11145 Py_LeaveRecursiveCall();
11152 #if CYTHON_COMPILING_IN_CPYTHON
11153 static CYTHON_INLINE PyObject
* __Pyx_PyObject_Call(PyObject
*func
, PyObject
*arg
, PyObject
*kw
) {
11155 ternaryfunc call
= func
->ob_type
->tp_call
;
11156 if (unlikely(!call
))
11157 return PyObject_Call(func
, arg
, kw
);
11158 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
11160 result
= (*call
)(func
, arg
, kw
);
11161 Py_LeaveRecursiveCall();
11162 if (unlikely(!result
) && unlikely(!PyErr_Occurred())) {
11165 "NULL result without error in PyObject_Call");
11171 /* PyObjectCall2Args */
11172 static CYTHON_UNUSED PyObject
* __Pyx_PyObject_Call2Args(PyObject
* function
, PyObject
* arg1
, PyObject
* arg2
) {
11173 PyObject
*args
, *result
= NULL
;
11174 #if CYTHON_FAST_PYCALL
11175 if (PyFunction_Check(function
)) {
11176 PyObject
*args
[2] = {arg1
, arg2
};
11177 return __Pyx_PyFunction_FastCall(function
, args
, 2);
11180 #if CYTHON_FAST_PYCCALL
11181 if (__Pyx_PyFastCFunction_Check(function
)) {
11182 PyObject
*args
[2] = {arg1
, arg2
};
11183 return __Pyx_PyCFunction_FastCall(function
, args
, 2);
11186 args
= PyTuple_New(2);
11187 if (unlikely(!args
)) goto done
;
11189 PyTuple_SET_ITEM(args
, 0, arg1
);
11191 PyTuple_SET_ITEM(args
, 1, arg2
);
11192 Py_INCREF(function
);
11193 result
= __Pyx_PyObject_Call(function
, args
, NULL
);
11195 Py_DECREF(function
);
11200 /* PyObjectCallMethO */
11201 #if CYTHON_COMPILING_IN_CPYTHON
11202 static CYTHON_INLINE PyObject
* __Pyx_PyObject_CallMethO(PyObject
*func
, PyObject
*arg
) {
11203 PyObject
*self
, *result
;
11205 cfunc
= PyCFunction_GET_FUNCTION(func
);
11206 self
= PyCFunction_GET_SELF(func
);
11207 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
11209 result
= cfunc(self
, arg
);
11210 Py_LeaveRecursiveCall();
11211 if (unlikely(!result
) && unlikely(!PyErr_Occurred())) {
11214 "NULL result without error in PyObject_Call");
11220 /* PyObjectCallOneArg */
11221 #if CYTHON_COMPILING_IN_CPYTHON
11222 static PyObject
* __Pyx__PyObject_CallOneArg(PyObject
*func
, PyObject
*arg
) {
11224 PyObject
*args
= PyTuple_New(1);
11225 if (unlikely(!args
)) return NULL
;
11227 PyTuple_SET_ITEM(args
, 0, arg
);
11228 result
= __Pyx_PyObject_Call(func
, args
, NULL
);
11232 static CYTHON_INLINE PyObject
* __Pyx_PyObject_CallOneArg(PyObject
*func
, PyObject
*arg
) {
11233 #if CYTHON_FAST_PYCALL
11234 if (PyFunction_Check(func
)) {
11235 return __Pyx_PyFunction_FastCall(func
, &arg
, 1);
11238 if (likely(PyCFunction_Check(func
))) {
11239 if (likely(PyCFunction_GET_FLAGS(func
) & METH_O
)) {
11240 return __Pyx_PyObject_CallMethO(func
, arg
);
11241 #if CYTHON_FAST_PYCCALL
11242 } else if (PyCFunction_GET_FLAGS(func
) & METH_FASTCALL
) {
11243 return __Pyx_PyCFunction_FastCall(func
, &arg
, 1);
11247 return __Pyx__PyObject_CallOneArg(func
, arg
);
11250 static CYTHON_INLINE PyObject
* __Pyx_PyObject_CallOneArg(PyObject
*func
, PyObject
*arg
) {
11252 PyObject
*args
= PyTuple_Pack(1, arg
);
11253 if (unlikely(!args
)) return NULL
;
11254 result
= __Pyx_PyObject_Call(func
, args
, NULL
);
11261 static CYTHON_INLINE
int __Pyx_TypeTest(PyObject
*obj
, PyTypeObject
*type
) {
11262 if (unlikely(!type
)) {
11263 PyErr_SetString(PyExc_SystemError
, "Missing type object");
11266 if (likely(__Pyx_TypeCheck(obj
, type
)))
11268 PyErr_Format(PyExc_TypeError
, "Cannot convert %.200s to %.200s",
11269 Py_TYPE(obj
)->tp_name
, type
->tp_name
);
11273 /* BufferFallbackError */
11274 static void __Pyx_RaiseBufferFallbackError(void) {
11275 PyErr_SetString(PyExc_ValueError
,
11276 "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
11279 /* PyDictVersioning */
11280 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
11281 static CYTHON_INLINE PY_UINT64_T
__Pyx_get_tp_dict_version(PyObject
*obj
) {
11282 PyObject
*dict
= Py_TYPE(obj
)->tp_dict
;
11283 return likely(dict
) ? __PYX_GET_DICT_VERSION(dict
) : 0;
11285 static CYTHON_INLINE PY_UINT64_T
__Pyx_get_object_dict_version(PyObject
*obj
) {
11286 PyObject
**dictptr
= NULL
;
11287 Py_ssize_t offset
= Py_TYPE(obj
)->tp_dictoffset
;
11289 #if CYTHON_COMPILING_IN_CPYTHON
11290 dictptr
= (likely(offset
> 0)) ? (PyObject
**) ((char *)obj
+ offset
) : _PyObject_GetDictPtr(obj
);
11292 dictptr
= _PyObject_GetDictPtr(obj
);
11295 return (dictptr
&& *dictptr
) ? __PYX_GET_DICT_VERSION(*dictptr
) : 0;
11297 static CYTHON_INLINE
int __Pyx_object_dict_version_matches(PyObject
* obj
, PY_UINT64_T tp_dict_version
, PY_UINT64_T obj_dict_version
) {
11298 PyObject
*dict
= Py_TYPE(obj
)->tp_dict
;
11299 if (unlikely(!dict
) || unlikely(tp_dict_version
!= __PYX_GET_DICT_VERSION(dict
)))
11301 return obj_dict_version
== __Pyx_get_object_dict_version(obj
);
11305 /* GetModuleGlobalName */
11306 #if CYTHON_USE_DICT_VERSIONS
11307 static PyObject
*__Pyx__GetModuleGlobalName(PyObject
*name
, PY_UINT64_T
*dict_version
, PyObject
**dict_cached_value
)
11309 static CYTHON_INLINE PyObject
*__Pyx__GetModuleGlobalName(PyObject
*name
)
11313 #if !CYTHON_AVOID_BORROWED_REFS
11314 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
11315 result
= _PyDict_GetItem_KnownHash(__pyx_d
, name
, ((PyASCIIObject
*) name
)->hash
);
11316 __PYX_UPDATE_DICT_CACHE(__pyx_d
, result
, *dict_cached_value
, *dict_version
)
11317 if (likely(result
)) {
11318 return __Pyx_NewRef(result
);
11319 } else if (unlikely(PyErr_Occurred())) {
11323 result
= PyDict_GetItem(__pyx_d
, name
);
11324 __PYX_UPDATE_DICT_CACHE(__pyx_d
, result
, *dict_cached_value
, *dict_version
)
11325 if (likely(result
)) {
11326 return __Pyx_NewRef(result
);
11330 result
= PyObject_GetItem(__pyx_d
, name
);
11331 __PYX_UPDATE_DICT_CACHE(__pyx_d
, result
, *dict_cached_value
, *dict_version
)
11332 if (likely(result
)) {
11333 return __Pyx_NewRef(result
);
11337 return __Pyx_GetBuiltinName(name
);
11341 static PyObject
*__Pyx_GetItemInt_Generic(PyObject
*o
, PyObject
* j
) {
11343 if (!j
) return NULL
;
11344 r
= PyObject_GetItem(o
, j
);
11348 static CYTHON_INLINE PyObject
*__Pyx_GetItemInt_List_Fast(PyObject
*o
, Py_ssize_t i
,
11349 CYTHON_NCP_UNUSED
int wraparound
,
11350 CYTHON_NCP_UNUSED
int boundscheck
) {
11351 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11352 Py_ssize_t wrapped_i
= i
;
11353 if (wraparound
& unlikely(i
< 0)) {
11354 wrapped_i
+= PyList_GET_SIZE(o
);
11356 if ((!boundscheck
) || likely(__Pyx_is_valid_index(wrapped_i
, PyList_GET_SIZE(o
)))) {
11357 PyObject
*r
= PyList_GET_ITEM(o
, wrapped_i
);
11361 return __Pyx_GetItemInt_Generic(o
, PyInt_FromSsize_t(i
));
11363 return PySequence_GetItem(o
, i
);
11366 static CYTHON_INLINE PyObject
*__Pyx_GetItemInt_Tuple_Fast(PyObject
*o
, Py_ssize_t i
,
11367 CYTHON_NCP_UNUSED
int wraparound
,
11368 CYTHON_NCP_UNUSED
int boundscheck
) {
11369 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11370 Py_ssize_t wrapped_i
= i
;
11371 if (wraparound
& unlikely(i
< 0)) {
11372 wrapped_i
+= PyTuple_GET_SIZE(o
);
11374 if ((!boundscheck
) || likely(__Pyx_is_valid_index(wrapped_i
, PyTuple_GET_SIZE(o
)))) {
11375 PyObject
*r
= PyTuple_GET_ITEM(o
, wrapped_i
);
11379 return __Pyx_GetItemInt_Generic(o
, PyInt_FromSsize_t(i
));
11381 return PySequence_GetItem(o
, i
);
11384 static CYTHON_INLINE PyObject
*__Pyx_GetItemInt_Fast(PyObject
*o
, Py_ssize_t i
, int is_list
,
11385 CYTHON_NCP_UNUSED
int wraparound
,
11386 CYTHON_NCP_UNUSED
int boundscheck
) {
11387 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
11388 if (is_list
|| PyList_CheckExact(o
)) {
11389 Py_ssize_t n
= ((!wraparound
) | likely(i
>= 0)) ? i
: i
+ PyList_GET_SIZE(o
);
11390 if ((!boundscheck
) || (likely(__Pyx_is_valid_index(n
, PyList_GET_SIZE(o
))))) {
11391 PyObject
*r
= PyList_GET_ITEM(o
, n
);
11396 else if (PyTuple_CheckExact(o
)) {
11397 Py_ssize_t n
= ((!wraparound
) | likely(i
>= 0)) ? i
: i
+ PyTuple_GET_SIZE(o
);
11398 if ((!boundscheck
) || likely(__Pyx_is_valid_index(n
, PyTuple_GET_SIZE(o
)))) {
11399 PyObject
*r
= PyTuple_GET_ITEM(o
, n
);
11404 PySequenceMethods
*m
= Py_TYPE(o
)->tp_as_sequence
;
11405 if (likely(m
&& m
->sq_item
)) {
11406 if (wraparound
&& unlikely(i
< 0) && likely(m
->sq_length
)) {
11407 Py_ssize_t l
= m
->sq_length(o
);
11408 if (likely(l
>= 0)) {
11411 if (!PyErr_ExceptionMatches(PyExc_OverflowError
))
11416 return m
->sq_item(o
, i
);
11420 if (is_list
|| PySequence_Check(o
)) {
11421 return PySequence_GetItem(o
, i
);
11424 return __Pyx_GetItemInt_Generic(o
, PyInt_FromSsize_t(i
));
11427 /* RaiseDoubleKeywords */
11428 static void __Pyx_RaiseDoubleKeywordsError(
11429 const char* func_name
,
11432 PyErr_Format(PyExc_TypeError
,
11433 #if PY_MAJOR_VERSION >= 3
11434 "%s() got multiple values for keyword argument '%U'", func_name
, kw_name
);
11436 "%s() got multiple values for keyword argument '%s'", func_name
,
11437 PyString_AsString(kw_name
));
11441 /* ParseKeywords */
11442 static int __Pyx_ParseOptionalKeywords(
11444 PyObject
**argnames
[],
11446 PyObject
*values
[],
11447 Py_ssize_t num_pos_args
,
11448 const char* function_name
)
11450 PyObject
*key
= 0, *value
= 0;
11451 Py_ssize_t pos
= 0;
11453 PyObject
*** first_kw_arg
= argnames
+ num_pos_args
;
11454 while (PyDict_Next(kwds
, &pos
, &key
, &value
)) {
11455 name
= first_kw_arg
;
11456 while (*name
&& (**name
!= key
)) name
++;
11458 values
[name
-argnames
] = value
;
11461 name
= first_kw_arg
;
11462 #if PY_MAJOR_VERSION < 3
11463 if (likely(PyString_CheckExact(key
)) || likely(PyString_Check(key
))) {
11465 if ((CYTHON_COMPILING_IN_PYPY
|| PyString_GET_SIZE(**name
) == PyString_GET_SIZE(key
))
11466 && _PyString_Eq(**name
, key
)) {
11467 values
[name
-argnames
] = value
;
11472 if (*name
) continue;
11474 PyObject
*** argname
= argnames
;
11475 while (argname
!= first_kw_arg
) {
11476 if ((**argname
== key
) || (
11477 (CYTHON_COMPILING_IN_PYPY
|| PyString_GET_SIZE(**argname
) == PyString_GET_SIZE(key
))
11478 && _PyString_Eq(**argname
, key
))) {
11479 goto arg_passed_twice
;
11486 if (likely(PyUnicode_Check(key
))) {
11488 int cmp
= (**name
== key
) ? 0 :
11489 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
11490 (PyUnicode_GET_SIZE(**name
) != PyUnicode_GET_SIZE(key
)) ? 1 :
11492 PyUnicode_Compare(**name
, key
);
11493 if (cmp
< 0 && unlikely(PyErr_Occurred())) goto bad
;
11495 values
[name
-argnames
] = value
;
11500 if (*name
) continue;
11502 PyObject
*** argname
= argnames
;
11503 while (argname
!= first_kw_arg
) {
11504 int cmp
= (**argname
== key
) ? 0 :
11505 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
11506 (PyUnicode_GET_SIZE(**argname
) != PyUnicode_GET_SIZE(key
)) ? 1 :
11508 PyUnicode_Compare(**argname
, key
);
11509 if (cmp
< 0 && unlikely(PyErr_Occurred())) goto bad
;
11510 if (cmp
== 0) goto arg_passed_twice
;
11515 goto invalid_keyword_type
;
11517 if (unlikely(PyDict_SetItem(kwds2
, key
, value
))) goto bad
;
11519 goto invalid_keyword
;
11524 __Pyx_RaiseDoubleKeywordsError(function_name
, key
);
11526 invalid_keyword_type
:
11527 PyErr_Format(PyExc_TypeError
,
11528 "%.200s() keywords must be strings", function_name
);
11531 PyErr_Format(PyExc_TypeError
,
11532 #if PY_MAJOR_VERSION < 3
11533 "%.200s() got an unexpected keyword argument '%.200s'",
11534 function_name
, PyString_AsString(key
));
11536 "%s() got an unexpected keyword argument '%U'",
11537 function_name
, key
);
11543 /* RaiseArgTupleInvalid */
11544 static void __Pyx_RaiseArgtupleInvalid(
11545 const char* func_name
,
11547 Py_ssize_t num_min
,
11548 Py_ssize_t num_max
,
11549 Py_ssize_t num_found
)
11551 Py_ssize_t num_expected
;
11552 const char *more_or_less
;
11553 if (num_found
< num_min
) {
11554 num_expected
= num_min
;
11555 more_or_less
= "at least";
11557 num_expected
= num_max
;
11558 more_or_less
= "at most";
11561 more_or_less
= "exactly";
11563 PyErr_Format(PyExc_TypeError
,
11564 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T
"d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T
"d given)",
11565 func_name
, more_or_less
, num_expected
,
11566 (num_expected
== 1) ? "" : "s", num_found
);
11570 static int __Pyx__ArgTypeTest(PyObject
*obj
, PyTypeObject
*type
, const char *name
, int exact
)
11572 if (unlikely(!type
)) {
11573 PyErr_SetString(PyExc_SystemError
, "Missing type object");
11577 #if PY_MAJOR_VERSION == 2
11578 if ((type
== &PyBaseString_Type
) && likely(__Pyx_PyBaseString_CheckExact(obj
))) return 1;
11582 if (likely(__Pyx_TypeCheck(obj
, type
))) return 1;
11584 PyErr_Format(PyExc_TypeError
,
11585 "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
11586 name
, type
->tp_name
, Py_TYPE(obj
)->tp_name
);
11590 /* BufferIndexError */
11591 static void __Pyx_RaiseBufferIndexError(int axis
) {
11592 PyErr_Format(PyExc_IndexError
,
11593 "Out of bounds on buffer access (axis %d)", axis
);
11596 /* ObjectGetItem */
11597 #if CYTHON_USE_TYPE_SLOTS
11598 static PyObject
*__Pyx_PyObject_GetIndex(PyObject
*obj
, PyObject
* index
) {
11600 Py_ssize_t key_value
;
11601 PySequenceMethods
*m
= Py_TYPE(obj
)->tp_as_sequence
;
11602 if (unlikely(!(m
&& m
->sq_item
))) {
11603 PyErr_Format(PyExc_TypeError
, "'%.200s' object is not subscriptable", Py_TYPE(obj
)->tp_name
);
11606 key_value
= __Pyx_PyIndex_AsSsize_t(index
);
11607 if (likely(key_value
!= -1 || !(runerr
= PyErr_Occurred()))) {
11608 return __Pyx_GetItemInt_Fast(obj
, key_value
, 0, 1, 1);
11610 if (PyErr_GivenExceptionMatches(runerr
, PyExc_OverflowError
)) {
11612 PyErr_Format(PyExc_IndexError
, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index
)->tp_name
);
11616 static PyObject
*__Pyx_PyObject_GetItem(PyObject
*obj
, PyObject
* key
) {
11617 PyMappingMethods
*m
= Py_TYPE(obj
)->tp_as_mapping
;
11618 if (likely(m
&& m
->mp_subscript
)) {
11619 return m
->mp_subscript(obj
, key
);
11621 return __Pyx_PyObject_GetIndex(obj
, key
);
11625 /* PyObjectCallNoArg */
11626 #if CYTHON_COMPILING_IN_CPYTHON
11627 static CYTHON_INLINE PyObject
* __Pyx_PyObject_CallNoArg(PyObject
*func
) {
11628 #if CYTHON_FAST_PYCALL
11629 if (PyFunction_Check(func
)) {
11630 return __Pyx_PyFunction_FastCall(func
, NULL
, 0);
11633 #ifdef __Pyx_CyFunction_USED
11634 if (likely(PyCFunction_Check(func
) || __Pyx_CyFunction_Check(func
)))
11636 if (likely(PyCFunction_Check(func
)))
11639 if (likely(PyCFunction_GET_FLAGS(func
) & METH_NOARGS
)) {
11640 return __Pyx_PyObject_CallMethO(func
, NULL
);
11643 return __Pyx_PyObject_Call(func
, __pyx_empty_tuple
, NULL
);
11647 /* WriteUnraisableException */
11648 static void __Pyx_WriteUnraisable(const char *name
, CYTHON_UNUSED
int clineno
,
11649 CYTHON_UNUSED
int lineno
, CYTHON_UNUSED
const char *filename
,
11650 int full_traceback
, CYTHON_UNUSED
int nogil
) {
11651 PyObject
*old_exc
, *old_val
, *old_tb
;
11653 __Pyx_PyThreadState_declare
11655 PyGILState_STATE state
;
11657 state
= PyGILState_Ensure();
11659 else state
= (PyGILState_STATE
)-1;
11662 __Pyx_PyThreadState_assign
11663 __Pyx_ErrFetch(&old_exc
, &old_val
, &old_tb
);
11664 if (full_traceback
) {
11665 Py_XINCREF(old_exc
);
11666 Py_XINCREF(old_val
);
11667 Py_XINCREF(old_tb
);
11668 __Pyx_ErrRestore(old_exc
, old_val
, old_tb
);
11671 #if PY_MAJOR_VERSION < 3
11672 ctx
= PyString_FromString(name
);
11674 ctx
= PyUnicode_FromString(name
);
11676 __Pyx_ErrRestore(old_exc
, old_val
, old_tb
);
11678 PyErr_WriteUnraisable(Py_None
);
11680 PyErr_WriteUnraisable(ctx
);
11685 PyGILState_Release(state
);
11690 #if !CYTHON_COMPILING_IN_PYPY
11691 static PyObject
* __Pyx_PyInt_AddObjC(PyObject
*op1
, PyObject
*op2
, CYTHON_UNUSED
long intval
, int inplace
, int zerodivision_check
) {
11693 (void)zerodivision_check
;
11694 #if PY_MAJOR_VERSION < 3
11695 if (likely(PyInt_CheckExact(op1
))) {
11696 const long b
= intval
;
11698 long a
= PyInt_AS_LONG(op1
);
11699 x
= (long)((unsigned long)a
+ b
);
11700 if (likely((x
^a
) >= 0 || (x
^b
) >= 0))
11701 return PyInt_FromLong(x
);
11702 return PyLong_Type
.tp_as_number
->nb_add(op1
, op2
);
11705 #if CYTHON_USE_PYLONG_INTERNALS
11706 if (likely(PyLong_CheckExact(op1
))) {
11707 const long b
= intval
;
11709 #ifdef HAVE_LONG_LONG
11710 const PY_LONG_LONG llb
= intval
;
11711 PY_LONG_LONG lla
, llx
;
11713 const digit
* digits
= ((PyLongObject
*)op1
)->ob_digit
;
11714 const Py_ssize_t size
= Py_SIZE(op1
);
11715 if (likely(__Pyx_sst_abs(size
) <= 1)) {
11716 a
= likely(size
) ? digits
[0] : 0;
11717 if (size
== -1) a
= -a
;
11721 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT
) {
11722 a
= -(long) (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0]));
11724 #ifdef HAVE_LONG_LONG
11725 } else if (8 * sizeof(PY_LONG_LONG
) - 1 > 2 * PyLong_SHIFT
) {
11726 lla
= -(PY_LONG_LONG
) (((((unsigned PY_LONG_LONG
)digits
[1]) << PyLong_SHIFT
) | (unsigned PY_LONG_LONG
)digits
[0]));
11730 CYTHON_FALLTHROUGH
;
11732 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT
) {
11733 a
= (long) (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0]));
11735 #ifdef HAVE_LONG_LONG
11736 } else if (8 * sizeof(PY_LONG_LONG
) - 1 > 2 * PyLong_SHIFT
) {
11737 lla
= (PY_LONG_LONG
) (((((unsigned PY_LONG_LONG
)digits
[1]) << PyLong_SHIFT
) | (unsigned PY_LONG_LONG
)digits
[0]));
11741 CYTHON_FALLTHROUGH
;
11743 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT
) {
11744 a
= -(long) (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0]));
11746 #ifdef HAVE_LONG_LONG
11747 } else if (8 * sizeof(PY_LONG_LONG
) - 1 > 3 * PyLong_SHIFT
) {
11748 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]));
11752 CYTHON_FALLTHROUGH
;
11754 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT
) {
11755 a
= (long) (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0]));
11757 #ifdef HAVE_LONG_LONG
11758 } else if (8 * sizeof(PY_LONG_LONG
) - 1 > 3 * PyLong_SHIFT
) {
11759 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]));
11763 CYTHON_FALLTHROUGH
;
11765 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT
) {
11766 a
= -(long) (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0]));
11768 #ifdef HAVE_LONG_LONG
11769 } else if (8 * sizeof(PY_LONG_LONG
) - 1 > 4 * PyLong_SHIFT
) {
11770 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]));
11774 CYTHON_FALLTHROUGH
;
11776 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT
) {
11777 a
= (long) (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0]));
11779 #ifdef HAVE_LONG_LONG
11780 } else if (8 * sizeof(PY_LONG_LONG
) - 1 > 4 * PyLong_SHIFT
) {
11781 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]));
11785 CYTHON_FALLTHROUGH
;
11786 default: return PyLong_Type
.tp_as_number
->nb_add(op1
, op2
);
11790 return PyLong_FromLong(x
);
11791 #ifdef HAVE_LONG_LONG
11794 return PyLong_FromLongLong(llx
);
11800 if (PyFloat_CheckExact(op1
)) {
11801 const long b
= intval
;
11802 double a
= PyFloat_AS_DOUBLE(op1
);
11804 PyFPE_START_PROTECT("add", return NULL
)
11805 result
= ((double)a
) + (double)b
;
11806 PyFPE_END_PROTECT(result
)
11807 return PyFloat_FromDouble(result
);
11809 return (inplace
? PyNumber_InPlaceAdd
: PyNumber_Add
)(op1
, op2
);
11814 static CYTHON_INLINE
long __Pyx_mod_long(long a
, long b
) {
11816 r
+= ((r
!= 0) & ((r
^ b
) < 0)) * b
;
11820 /* GetTopmostException */
11821 #if CYTHON_USE_EXC_INFO_STACK
11822 static _PyErr_StackItem
*
11823 __Pyx_PyErr_GetTopmostException(PyThreadState
*tstate
)
11825 _PyErr_StackItem
*exc_info
= tstate
->exc_info
;
11826 while ((exc_info
->exc_type
== NULL
|| exc_info
->exc_type
== Py_None
) &&
11827 exc_info
->previous_item
!= NULL
)
11829 exc_info
= exc_info
->previous_item
;
11835 /* SaveResetException */
11836 #if CYTHON_FAST_THREAD_STATE
11837 static CYTHON_INLINE
void __Pyx__ExceptionSave(PyThreadState
*tstate
, PyObject
**type
, PyObject
**value
, PyObject
**tb
) {
11838 #if CYTHON_USE_EXC_INFO_STACK
11839 _PyErr_StackItem
*exc_info
= __Pyx_PyErr_GetTopmostException(tstate
);
11840 *type
= exc_info
->exc_type
;
11841 *value
= exc_info
->exc_value
;
11842 *tb
= exc_info
->exc_traceback
;
11844 *type
= tstate
->exc_type
;
11845 *value
= tstate
->exc_value
;
11846 *tb
= tstate
->exc_traceback
;
11849 Py_XINCREF(*value
);
11852 static CYTHON_INLINE
void __Pyx__ExceptionReset(PyThreadState
*tstate
, PyObject
*type
, PyObject
*value
, PyObject
*tb
) {
11853 PyObject
*tmp_type
, *tmp_value
, *tmp_tb
;
11854 #if CYTHON_USE_EXC_INFO_STACK
11855 _PyErr_StackItem
*exc_info
= tstate
->exc_info
;
11856 tmp_type
= exc_info
->exc_type
;
11857 tmp_value
= exc_info
->exc_value
;
11858 tmp_tb
= exc_info
->exc_traceback
;
11859 exc_info
->exc_type
= type
;
11860 exc_info
->exc_value
= value
;
11861 exc_info
->exc_traceback
= tb
;
11863 tmp_type
= tstate
->exc_type
;
11864 tmp_value
= tstate
->exc_value
;
11865 tmp_tb
= tstate
->exc_traceback
;
11866 tstate
->exc_type
= type
;
11867 tstate
->exc_value
= value
;
11868 tstate
->exc_traceback
= tb
;
11870 Py_XDECREF(tmp_type
);
11871 Py_XDECREF(tmp_value
);
11872 Py_XDECREF(tmp_tb
);
11876 /* PyErrExceptionMatches */
11877 #if CYTHON_FAST_THREAD_STATE
11878 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject
*exc_type
, PyObject
*tuple
) {
11880 n
= PyTuple_GET_SIZE(tuple
);
11881 #if PY_MAJOR_VERSION >= 3
11882 for (i
=0; i
<n
; i
++) {
11883 if (exc_type
== PyTuple_GET_ITEM(tuple
, i
)) return 1;
11886 for (i
=0; i
<n
; i
++) {
11887 if (__Pyx_PyErr_GivenExceptionMatches(exc_type
, PyTuple_GET_ITEM(tuple
, i
))) return 1;
11891 static CYTHON_INLINE
int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState
* tstate
, PyObject
* err
) {
11892 PyObject
*exc_type
= tstate
->curexc_type
;
11893 if (exc_type
== err
) return 1;
11894 if (unlikely(!exc_type
)) return 0;
11895 if (unlikely(PyTuple_Check(err
)))
11896 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type
, err
);
11897 return __Pyx_PyErr_GivenExceptionMatches(exc_type
, err
);
11902 #if CYTHON_FAST_THREAD_STATE
11903 static int __Pyx__GetException(PyThreadState
*tstate
, PyObject
**type
, PyObject
**value
, PyObject
**tb
)
11905 static int __Pyx_GetException(PyObject
**type
, PyObject
**value
, PyObject
**tb
)
11908 PyObject
*local_type
, *local_value
, *local_tb
;
11909 #if CYTHON_FAST_THREAD_STATE
11910 PyObject
*tmp_type
, *tmp_value
, *tmp_tb
;
11911 local_type
= tstate
->curexc_type
;
11912 local_value
= tstate
->curexc_value
;
11913 local_tb
= tstate
->curexc_traceback
;
11914 tstate
->curexc_type
= 0;
11915 tstate
->curexc_value
= 0;
11916 tstate
->curexc_traceback
= 0;
11918 PyErr_Fetch(&local_type
, &local_value
, &local_tb
);
11920 PyErr_NormalizeException(&local_type
, &local_value
, &local_tb
);
11921 #if CYTHON_FAST_THREAD_STATE
11922 if (unlikely(tstate
->curexc_type
))
11924 if (unlikely(PyErr_Occurred()))
11927 #if PY_MAJOR_VERSION >= 3
11929 if (unlikely(PyException_SetTraceback(local_value
, local_tb
) < 0))
11933 Py_XINCREF(local_tb
);
11934 Py_XINCREF(local_type
);
11935 Py_XINCREF(local_value
);
11936 *type
= local_type
;
11937 *value
= local_value
;
11939 #if CYTHON_FAST_THREAD_STATE
11940 #if CYTHON_USE_EXC_INFO_STACK
11942 _PyErr_StackItem
*exc_info
= tstate
->exc_info
;
11943 tmp_type
= exc_info
->exc_type
;
11944 tmp_value
= exc_info
->exc_value
;
11945 tmp_tb
= exc_info
->exc_traceback
;
11946 exc_info
->exc_type
= local_type
;
11947 exc_info
->exc_value
= local_value
;
11948 exc_info
->exc_traceback
= local_tb
;
11951 tmp_type
= tstate
->exc_type
;
11952 tmp_value
= tstate
->exc_value
;
11953 tmp_tb
= tstate
->exc_traceback
;
11954 tstate
->exc_type
= local_type
;
11955 tstate
->exc_value
= local_value
;
11956 tstate
->exc_traceback
= local_tb
;
11958 Py_XDECREF(tmp_type
);
11959 Py_XDECREF(tmp_value
);
11960 Py_XDECREF(tmp_tb
);
11962 PyErr_SetExcInfo(local_type
, local_value
, local_tb
);
11969 Py_XDECREF(local_type
);
11970 Py_XDECREF(local_value
);
11971 Py_XDECREF(local_tb
);
11975 /* RaiseException */
11976 #if PY_MAJOR_VERSION < 3
11977 static void __Pyx_Raise(PyObject
*type
, PyObject
*value
, PyObject
*tb
,
11978 CYTHON_UNUSED PyObject
*cause
) {
11979 __Pyx_PyThreadState_declare
11981 if (!value
|| value
== Py_None
)
11985 if (!tb
|| tb
== Py_None
)
11989 if (!PyTraceBack_Check(tb
)) {
11990 PyErr_SetString(PyExc_TypeError
,
11991 "raise: arg 3 must be a traceback or None");
11995 if (PyType_Check(type
)) {
11996 #if CYTHON_COMPILING_IN_PYPY
11998 Py_INCREF(Py_None
);
12002 PyErr_NormalizeException(&type
, &value
, &tb
);
12005 PyErr_SetString(PyExc_TypeError
,
12006 "instance exception may not have a separate value");
12010 type
= (PyObject
*) Py_TYPE(type
);
12012 if (!PyType_IsSubtype((PyTypeObject
*)type
, (PyTypeObject
*)PyExc_BaseException
)) {
12013 PyErr_SetString(PyExc_TypeError
,
12014 "raise: exception class must be a subclass of BaseException");
12018 __Pyx_PyThreadState_assign
12019 __Pyx_ErrRestore(type
, value
, tb
);
12028 static void __Pyx_Raise(PyObject
*type
, PyObject
*value
, PyObject
*tb
, PyObject
*cause
) {
12029 PyObject
* owned_instance
= NULL
;
12030 if (tb
== Py_None
) {
12032 } else if (tb
&& !PyTraceBack_Check(tb
)) {
12033 PyErr_SetString(PyExc_TypeError
,
12034 "raise: arg 3 must be a traceback or None");
12037 if (value
== Py_None
)
12039 if (PyExceptionInstance_Check(type
)) {
12041 PyErr_SetString(PyExc_TypeError
,
12042 "instance exception may not have a separate value");
12046 type
= (PyObject
*) Py_TYPE(value
);
12047 } else if (PyExceptionClass_Check(type
)) {
12048 PyObject
*instance_class
= NULL
;
12049 if (value
&& PyExceptionInstance_Check(value
)) {
12050 instance_class
= (PyObject
*) Py_TYPE(value
);
12051 if (instance_class
!= type
) {
12052 int is_subclass
= PyObject_IsSubclass(instance_class
, type
);
12053 if (!is_subclass
) {
12054 instance_class
= NULL
;
12055 } else if (unlikely(is_subclass
== -1)) {
12058 type
= instance_class
;
12062 if (!instance_class
) {
12065 args
= PyTuple_New(0);
12066 else if (PyTuple_Check(value
)) {
12070 args
= PyTuple_Pack(1, value
);
12073 owned_instance
= PyObject_Call(type
, args
, NULL
);
12075 if (!owned_instance
)
12077 value
= owned_instance
;
12078 if (!PyExceptionInstance_Check(value
)) {
12079 PyErr_Format(PyExc_TypeError
,
12080 "calling %R should have returned an instance of "
12081 "BaseException, not %R",
12082 type
, Py_TYPE(value
));
12087 PyErr_SetString(PyExc_TypeError
,
12088 "raise: exception class must be a subclass of BaseException");
12092 PyObject
*fixed_cause
;
12093 if (cause
== Py_None
) {
12094 fixed_cause
= NULL
;
12095 } else if (PyExceptionClass_Check(cause
)) {
12096 fixed_cause
= PyObject_CallObject(cause
, NULL
);
12097 if (fixed_cause
== NULL
)
12099 } else if (PyExceptionInstance_Check(cause
)) {
12100 fixed_cause
= cause
;
12101 Py_INCREF(fixed_cause
);
12103 PyErr_SetString(PyExc_TypeError
,
12104 "exception causes must derive from "
12108 PyException_SetCause(value
, fixed_cause
);
12110 PyErr_SetObject(type
, value
);
12112 #if CYTHON_COMPILING_IN_PYPY
12113 PyObject
*tmp_type
, *tmp_value
, *tmp_tb
;
12114 PyErr_Fetch(&tmp_type
, &tmp_value
, &tmp_tb
);
12116 PyErr_Restore(tmp_type
, tmp_value
, tb
);
12117 Py_XDECREF(tmp_tb
);
12119 PyThreadState
*tstate
= __Pyx_PyThreadState_Current
;
12120 PyObject
* tmp_tb
= tstate
->curexc_traceback
;
12121 if (tb
!= tmp_tb
) {
12123 tstate
->curexc_traceback
= tb
;
12124 Py_XDECREF(tmp_tb
);
12129 Py_XDECREF(owned_instance
);
12135 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
12136 static PyObject
*__Pyx_PyDict_GetItem(PyObject
*d
, PyObject
* key
) {
12138 value
= PyDict_GetItemWithError(d
, key
);
12139 if (unlikely(!value
)) {
12140 if (!PyErr_Occurred()) {
12141 if (unlikely(PyTuple_Check(key
))) {
12142 PyObject
* args
= PyTuple_Pack(1, key
);
12143 if (likely(args
)) {
12144 PyErr_SetObject(PyExc_KeyError
, args
);
12148 PyErr_SetObject(PyExc_KeyError
, key
);
12158 /* RaiseTooManyValuesToUnpack */
12159 static CYTHON_INLINE
void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected
) {
12160 PyErr_Format(PyExc_ValueError
,
12161 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T
"d)", expected
);
12164 /* RaiseNeedMoreValuesToUnpack */
12165 static CYTHON_INLINE
void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index
) {
12166 PyErr_Format(PyExc_ValueError
,
12167 "need more than %" CYTHON_FORMAT_SSIZE_T
"d value%.1s to unpack",
12168 index
, (index
== 1) ? "" : "s");
12171 /* RaiseNoneIterError */
12172 static CYTHON_INLINE
void __Pyx_RaiseNoneNotIterableError(void) {
12173 PyErr_SetString(PyExc_TypeError
, "'NoneType' object is not iterable");
12177 #ifndef __PYX_HAVE_RT_ImportType
12178 #define __PYX_HAVE_RT_ImportType
12179 static PyTypeObject
*__Pyx_ImportType(PyObject
*module
, const char *module_name
, const char *class_name
,
12180 size_t size
, enum __Pyx_ImportType_CheckSize check_size
)
12182 PyObject
*result
= 0;
12184 Py_ssize_t basicsize
;
12185 #ifdef Py_LIMITED_API
12186 PyObject
*py_basicsize
;
12188 result
= PyObject_GetAttrString(module
, class_name
);
12191 if (!PyType_Check(result
)) {
12192 PyErr_Format(PyExc_TypeError
,
12193 "%.200s.%.200s is not a type object",
12194 module_name
, class_name
);
12197 #ifndef Py_LIMITED_API
12198 basicsize
= ((PyTypeObject
*)result
)->tp_basicsize
;
12200 py_basicsize
= PyObject_GetAttrString(result
, "__basicsize__");
12203 basicsize
= PyLong_AsSsize_t(py_basicsize
);
12204 Py_DECREF(py_basicsize
);
12206 if (basicsize
== (Py_ssize_t
)-1 && PyErr_Occurred())
12209 if ((size_t)basicsize
< size
) {
12210 PyErr_Format(PyExc_ValueError
,
12211 "%.200s.%.200s size changed, may indicate binary incompatibility. "
12212 "Expected %zd from C header, got %zd from PyObject",
12213 module_name
, class_name
, size
, basicsize
);
12216 if (check_size
== __Pyx_ImportType_CheckSize_Error
&& (size_t)basicsize
!= size
) {
12217 PyErr_Format(PyExc_ValueError
,
12218 "%.200s.%.200s size changed, may indicate binary incompatibility. "
12219 "Expected %zd from C header, got %zd from PyObject",
12220 module_name
, class_name
, size
, basicsize
);
12223 else if (check_size
== __Pyx_ImportType_CheckSize_Warn
&& (size_t)basicsize
> size
) {
12224 PyOS_snprintf(warning
, sizeof(warning
),
12225 "%s.%s size changed, may indicate binary incompatibility. "
12226 "Expected %zd from C header, got %zd from PyObject",
12227 module_name
, class_name
, size
, basicsize
);
12228 if (PyErr_WarnEx(NULL
, warning
, 0) < 0) goto bad
;
12230 return (PyTypeObject
*)result
;
12232 Py_XDECREF(result
);
12238 static PyObject
*__Pyx_Import(PyObject
*name
, PyObject
*from_list
, int level
) {
12239 PyObject
*empty_list
= 0;
12240 PyObject
*module
= 0;
12241 PyObject
*global_dict
= 0;
12242 PyObject
*empty_dict
= 0;
12244 #if PY_MAJOR_VERSION < 3
12245 PyObject
*py_import
;
12246 py_import
= __Pyx_PyObject_GetAttrStr(__pyx_b
, __pyx_n_s_import
);
12253 empty_list
= PyList_New(0);
12258 global_dict
= PyModule_GetDict(__pyx_m
);
12261 empty_dict
= PyDict_New();
12265 #if PY_MAJOR_VERSION >= 3
12267 if (strchr(__Pyx_MODULE_NAME
, '.')) {
12268 module
= PyImport_ImportModuleLevelObject(
12269 name
, global_dict
, empty_dict
, list
, 1);
12271 if (!PyErr_ExceptionMatches(PyExc_ImportError
))
12280 #if PY_MAJOR_VERSION < 3
12281 PyObject
*py_level
= PyInt_FromLong(level
);
12284 module
= PyObject_CallFunctionObjArgs(py_import
,
12285 name
, global_dict
, empty_dict
, list
, py_level
, (PyObject
*)NULL
);
12286 Py_DECREF(py_level
);
12288 module
= PyImport_ImportModuleLevelObject(
12289 name
, global_dict
, empty_dict
, list
, level
);
12294 #if PY_MAJOR_VERSION < 3
12295 Py_XDECREF(py_import
);
12297 Py_XDECREF(empty_list
);
12298 Py_XDECREF(empty_dict
);
12303 static PyObject
* __Pyx_ImportFrom(PyObject
* module
, PyObject
* name
) {
12304 PyObject
* value
= __Pyx_PyObject_GetAttrStr(module
, name
);
12305 if (unlikely(!value
) && PyErr_ExceptionMatches(PyExc_AttributeError
)) {
12306 PyErr_Format(PyExc_ImportError
,
12307 #if PY_MAJOR_VERSION < 3
12308 "cannot import name %.230s", PyString_AS_STRING(name
));
12310 "cannot import name %S", name
);
12316 /* CLineInTraceback */
12317 #ifndef CYTHON_CLINE_IN_TRACEBACK
12318 static int __Pyx_CLineForTraceback(PyThreadState
*tstate
, int c_line
) {
12319 PyObject
*use_cline
;
12320 PyObject
*ptype
, *pvalue
, *ptraceback
;
12321 #if CYTHON_COMPILING_IN_CPYTHON
12322 PyObject
**cython_runtime_dict
;
12324 if (unlikely(!__pyx_cython_runtime
)) {
12327 __Pyx_ErrFetchInState(tstate
, &ptype
, &pvalue
, &ptraceback
);
12328 #if CYTHON_COMPILING_IN_CPYTHON
12329 cython_runtime_dict
= _PyObject_GetDictPtr(__pyx_cython_runtime
);
12330 if (likely(cython_runtime_dict
)) {
12331 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
12332 use_cline
, *cython_runtime_dict
,
12333 __Pyx_PyDict_GetItemStr(*cython_runtime_dict
, __pyx_n_s_cline_in_traceback
))
12337 PyObject
*use_cline_obj
= __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime
, __pyx_n_s_cline_in_traceback
);
12338 if (use_cline_obj
) {
12339 use_cline
= PyObject_Not(use_cline_obj
) ? Py_False
: Py_True
;
12340 Py_DECREF(use_cline_obj
);
12348 PyObject_SetAttr(__pyx_cython_runtime
, __pyx_n_s_cline_in_traceback
, Py_False
);
12350 else if (use_cline
== Py_False
|| (use_cline
!= Py_True
&& PyObject_Not(use_cline
) != 0)) {
12353 __Pyx_ErrRestoreInState(tstate
, ptype
, pvalue
, ptraceback
);
12358 /* CodeObjectCache */
12359 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry
* entries
, int count
, int code_line
) {
12360 int start
= 0, mid
= 0, end
= count
- 1;
12361 if (end
>= 0 && code_line
> entries
[end
].code_line
) {
12364 while (start
< end
) {
12365 mid
= start
+ (end
- start
) / 2;
12366 if (code_line
< entries
[mid
].code_line
) {
12368 } else if (code_line
> entries
[mid
].code_line
) {
12374 if (code_line
<= entries
[mid
].code_line
) {
12380 static PyCodeObject
*__pyx_find_code_object(int code_line
) {
12381 PyCodeObject
* code_object
;
12383 if (unlikely(!code_line
) || unlikely(!__pyx_code_cache
.entries
)) {
12386 pos
= __pyx_bisect_code_objects(__pyx_code_cache
.entries
, __pyx_code_cache
.count
, code_line
);
12387 if (unlikely(pos
>= __pyx_code_cache
.count
) || unlikely(__pyx_code_cache
.entries
[pos
].code_line
!= code_line
)) {
12390 code_object
= __pyx_code_cache
.entries
[pos
].code_object
;
12391 Py_INCREF(code_object
);
12392 return code_object
;
12394 static void __pyx_insert_code_object(int code_line
, PyCodeObject
* code_object
) {
12396 __Pyx_CodeObjectCacheEntry
* entries
= __pyx_code_cache
.entries
;
12397 if (unlikely(!code_line
)) {
12400 if (unlikely(!entries
)) {
12401 entries
= (__Pyx_CodeObjectCacheEntry
*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry
));
12402 if (likely(entries
)) {
12403 __pyx_code_cache
.entries
= entries
;
12404 __pyx_code_cache
.max_count
= 64;
12405 __pyx_code_cache
.count
= 1;
12406 entries
[0].code_line
= code_line
;
12407 entries
[0].code_object
= code_object
;
12408 Py_INCREF(code_object
);
12412 pos
= __pyx_bisect_code_objects(__pyx_code_cache
.entries
, __pyx_code_cache
.count
, code_line
);
12413 if ((pos
< __pyx_code_cache
.count
) && unlikely(__pyx_code_cache
.entries
[pos
].code_line
== code_line
)) {
12414 PyCodeObject
* tmp
= entries
[pos
].code_object
;
12415 entries
[pos
].code_object
= code_object
;
12419 if (__pyx_code_cache
.count
== __pyx_code_cache
.max_count
) {
12420 int new_max
= __pyx_code_cache
.max_count
+ 64;
12421 entries
= (__Pyx_CodeObjectCacheEntry
*)PyMem_Realloc(
12422 __pyx_code_cache
.entries
, (size_t)new_max
*sizeof(__Pyx_CodeObjectCacheEntry
));
12423 if (unlikely(!entries
)) {
12426 __pyx_code_cache
.entries
= entries
;
12427 __pyx_code_cache
.max_count
= new_max
;
12429 for (i
=__pyx_code_cache
.count
; i
>pos
; i
--) {
12430 entries
[i
] = entries
[i
-1];
12432 entries
[pos
].code_line
= code_line
;
12433 entries
[pos
].code_object
= code_object
;
12434 __pyx_code_cache
.count
++;
12435 Py_INCREF(code_object
);
12439 #include "compile.h"
12440 #include "frameobject.h"
12441 #include "traceback.h"
12442 static PyCodeObject
* __Pyx_CreateCodeObjectForTraceback(
12443 const char *funcname
, int c_line
,
12444 int py_line
, const char *filename
) {
12445 PyCodeObject
*py_code
= 0;
12446 PyObject
*py_srcfile
= 0;
12447 PyObject
*py_funcname
= 0;
12448 #if PY_MAJOR_VERSION < 3
12449 py_srcfile
= PyString_FromString(filename
);
12451 py_srcfile
= PyUnicode_FromString(filename
);
12453 if (!py_srcfile
) goto bad
;
12455 #if PY_MAJOR_VERSION < 3
12456 py_funcname
= PyString_FromFormat( "%s (%s:%d)", funcname
, __pyx_cfilenm
, c_line
);
12458 py_funcname
= PyUnicode_FromFormat( "%s (%s:%d)", funcname
, __pyx_cfilenm
, c_line
);
12462 #if PY_MAJOR_VERSION < 3
12463 py_funcname
= PyString_FromString(funcname
);
12465 py_funcname
= PyUnicode_FromString(funcname
);
12468 if (!py_funcname
) goto bad
;
12469 py_code
= __Pyx_PyCode_New(
12475 __pyx_empty_bytes
, /*PyObject *code,*/
12476 __pyx_empty_tuple
, /*PyObject *consts,*/
12477 __pyx_empty_tuple
, /*PyObject *names,*/
12478 __pyx_empty_tuple
, /*PyObject *varnames,*/
12479 __pyx_empty_tuple
, /*PyObject *freevars,*/
12480 __pyx_empty_tuple
, /*PyObject *cellvars,*/
12481 py_srcfile
, /*PyObject *filename,*/
12482 py_funcname
, /*PyObject *name,*/
12484 __pyx_empty_bytes
/*PyObject *lnotab*/
12486 Py_DECREF(py_srcfile
);
12487 Py_DECREF(py_funcname
);
12490 Py_XDECREF(py_srcfile
);
12491 Py_XDECREF(py_funcname
);
12494 static void __Pyx_AddTraceback(const char *funcname
, int c_line
,
12495 int py_line
, const char *filename
) {
12496 PyCodeObject
*py_code
= 0;
12497 PyFrameObject
*py_frame
= 0;
12498 PyThreadState
*tstate
= __Pyx_PyThreadState_Current
;
12500 c_line
= __Pyx_CLineForTraceback(tstate
, c_line
);
12502 py_code
= __pyx_find_code_object(c_line
? -c_line
: py_line
);
12504 py_code
= __Pyx_CreateCodeObjectForTraceback(
12505 funcname
, c_line
, py_line
, filename
);
12506 if (!py_code
) goto bad
;
12507 __pyx_insert_code_object(c_line
? -c_line
: py_line
, py_code
);
12509 py_frame
= PyFrame_New(
12510 tstate
, /*PyThreadState *tstate,*/
12511 py_code
, /*PyCodeObject *code,*/
12512 __pyx_d
, /*PyObject *globals,*/
12513 0 /*PyObject *locals*/
12515 if (!py_frame
) goto bad
;
12516 __Pyx_PyFrame_SetLineNumber(py_frame
, py_line
);
12517 PyTraceBack_Here(py_frame
);
12519 Py_XDECREF(py_code
);
12520 Py_XDECREF(py_frame
);
12523 #if PY_MAJOR_VERSION < 3
12524 static int __Pyx_GetBuffer(PyObject
*obj
, Py_buffer
*view
, int flags
) {
12525 if (PyObject_CheckBuffer(obj
)) return PyObject_GetBuffer(obj
, view
, flags
);
12526 if (__Pyx_TypeCheck(obj
, __pyx_ptype_5numpy_ndarray
)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj
, view
, flags
);
12527 PyErr_Format(PyExc_TypeError
, "'%.200s' does not have the buffer interface", Py_TYPE(obj
)->tp_name
);
12530 static void __Pyx_ReleaseBuffer(Py_buffer
*view
) {
12531 PyObject
*obj
= view
->obj
;
12533 if (PyObject_CheckBuffer(obj
)) {
12534 PyBuffer_Release(view
);
12538 else if (__Pyx_TypeCheck(obj
, __pyx_ptype_5numpy_ndarray
)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj
, view
);
12545 /* CIntFromPyVerify */
12546 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
12547 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
12548 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
12549 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
12550 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
12552 func_type value = func_value;\
12553 if (sizeof(target_type) < sizeof(func_type)) {\
12554 if (unlikely(value != (func_type) (target_type) value)) {\
12555 func_type zero = 0;\
12556 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
12557 return (target_type) -1;\
12558 if (is_unsigned && unlikely(value < zero))\
12559 goto raise_neg_overflow;\
12561 goto raise_overflow;\
12564 return (target_type) value;\
12568 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_long(long value
) {
12569 const long neg_one
= (long) ((long) 0 - (long) 1), const_zero
= (long) 0;
12570 const int is_unsigned
= neg_one
> const_zero
;
12572 if (sizeof(long) < sizeof(long)) {
12573 return PyInt_FromLong((long) value
);
12574 } else if (sizeof(long) <= sizeof(unsigned long)) {
12575 return PyLong_FromUnsignedLong((unsigned long) value
);
12576 #ifdef HAVE_LONG_LONG
12577 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG
)) {
12578 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG
) value
);
12582 if (sizeof(long) <= sizeof(long)) {
12583 return PyInt_FromLong((long) value
);
12584 #ifdef HAVE_LONG_LONG
12585 } else if (sizeof(long) <= sizeof(PY_LONG_LONG
)) {
12586 return PyLong_FromLongLong((PY_LONG_LONG
) value
);
12591 int one
= 1; int little
= (int)*(unsigned char *)&one
;
12592 unsigned char *bytes
= (unsigned char *)&value
;
12593 return _PyLong_FromByteArray(bytes
, sizeof(long),
12594 little
, !is_unsigned
);
12599 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_npy_int32(npy_int32 value
) {
12600 const npy_int32 neg_one
= (npy_int32
) ((npy_int32
) 0 - (npy_int32
) 1), const_zero
= (npy_int32
) 0;
12601 const int is_unsigned
= neg_one
> const_zero
;
12603 if (sizeof(npy_int32
) < sizeof(long)) {
12604 return PyInt_FromLong((long) value
);
12605 } else if (sizeof(npy_int32
) <= sizeof(unsigned long)) {
12606 return PyLong_FromUnsignedLong((unsigned long) value
);
12607 #ifdef HAVE_LONG_LONG
12608 } else if (sizeof(npy_int32
) <= sizeof(unsigned PY_LONG_LONG
)) {
12609 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG
) value
);
12613 if (sizeof(npy_int32
) <= sizeof(long)) {
12614 return PyInt_FromLong((long) value
);
12615 #ifdef HAVE_LONG_LONG
12616 } else if (sizeof(npy_int32
) <= sizeof(PY_LONG_LONG
)) {
12617 return PyLong_FromLongLong((PY_LONG_LONG
) value
);
12622 int one
= 1; int little
= (int)*(unsigned char *)&one
;
12623 unsigned char *bytes
= (unsigned char *)&value
;
12624 return _PyLong_FromByteArray(bytes
, sizeof(npy_int32
),
12625 little
, !is_unsigned
);
12630 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_int(int value
) {
12631 const int neg_one
= (int) ((int) 0 - (int) 1), const_zero
= (int) 0;
12632 const int is_unsigned
= neg_one
> const_zero
;
12634 if (sizeof(int) < sizeof(long)) {
12635 return PyInt_FromLong((long) value
);
12636 } else if (sizeof(int) <= sizeof(unsigned long)) {
12637 return PyLong_FromUnsignedLong((unsigned long) value
);
12638 #ifdef HAVE_LONG_LONG
12639 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG
)) {
12640 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG
) value
);
12644 if (sizeof(int) <= sizeof(long)) {
12645 return PyInt_FromLong((long) value
);
12646 #ifdef HAVE_LONG_LONG
12647 } else if (sizeof(int) <= sizeof(PY_LONG_LONG
)) {
12648 return PyLong_FromLongLong((PY_LONG_LONG
) value
);
12653 int one
= 1; int little
= (int)*(unsigned char *)&one
;
12654 unsigned char *bytes
= (unsigned char *)&value
;
12655 return _PyLong_FromByteArray(bytes
, sizeof(int),
12656 little
, !is_unsigned
);
12661 static CYTHON_INLINE
long __Pyx_pow_long(long b
, long e
) {
12666 CYTHON_FALLTHROUGH
;
12669 CYTHON_FALLTHROUGH
;
12676 if (unlikely(e
<0)) return 0;
12679 while (likely(e
)) {
12680 t
*= (b
* (e
&1)) | ((~e
)&1);
12688 static CYTHON_INLINE
int __Pyx_pow_int(int b
, int e
) {
12693 CYTHON_FALLTHROUGH
;
12696 CYTHON_FALLTHROUGH
;
12703 if (unlikely(e
<0)) return 0;
12706 while (likely(e
)) {
12707 t
*= (b
* (e
&1)) | ((~e
)&1);
12715 #if CYTHON_CCOMPLEX
12717 static CYTHON_INLINE __pyx_t_float_complex
__pyx_t_float_complex_from_parts(float x
, float y
) {
12718 return ::std::complex< float >(x
, y
);
12721 static CYTHON_INLINE __pyx_t_float_complex
__pyx_t_float_complex_from_parts(float x
, float y
) {
12722 return x
+ y
*(__pyx_t_float_complex
)_Complex_I
;
12726 static CYTHON_INLINE __pyx_t_float_complex
__pyx_t_float_complex_from_parts(float x
, float y
) {
12727 __pyx_t_float_complex z
;
12735 #if CYTHON_CCOMPLEX
12737 static CYTHON_INLINE
int __Pyx_c_eq_float(__pyx_t_float_complex a
, __pyx_t_float_complex b
) {
12738 return (a
.real
== b
.real
) && (a
.imag
== b
.imag
);
12740 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_sum_float(__pyx_t_float_complex a
, __pyx_t_float_complex b
) {
12741 __pyx_t_float_complex z
;
12742 z
.real
= a
.real
+ b
.real
;
12743 z
.imag
= a
.imag
+ b
.imag
;
12746 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_diff_float(__pyx_t_float_complex a
, __pyx_t_float_complex b
) {
12747 __pyx_t_float_complex z
;
12748 z
.real
= a
.real
- b
.real
;
12749 z
.imag
= a
.imag
- b
.imag
;
12752 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_prod_float(__pyx_t_float_complex a
, __pyx_t_float_complex b
) {
12753 __pyx_t_float_complex z
;
12754 z
.real
= a
.real
* b
.real
- a
.imag
* b
.imag
;
12755 z
.imag
= a
.real
* b
.imag
+ a
.imag
* b
.real
;
12759 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_quot_float(__pyx_t_float_complex a
, __pyx_t_float_complex b
) {
12761 return __pyx_t_float_complex_from_parts(a
.real
/ b
.real
, a
.imag
/ b
.real
);
12762 } else if (fabsf(b
.real
) >= fabsf(b
.imag
)) {
12763 if (b
.real
== 0 && b
.imag
== 0) {
12764 return __pyx_t_float_complex_from_parts(a
.real
/ b
.real
, a
.imag
/ b
.imag
);
12766 float r
= b
.imag
/ b
.real
;
12767 float s
= (float)(1.0) / (b
.real
+ b
.imag
* r
);
12768 return __pyx_t_float_complex_from_parts(
12769 (a
.real
+ a
.imag
* r
) * s
, (a
.imag
- a
.real
* r
) * s
);
12772 float r
= b
.real
/ b
.imag
;
12773 float s
= (float)(1.0) / (b
.imag
+ b
.real
* r
);
12774 return __pyx_t_float_complex_from_parts(
12775 (a
.real
* r
+ a
.imag
) * s
, (a
.imag
* r
- a
.real
) * s
);
12779 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_quot_float(__pyx_t_float_complex a
, __pyx_t_float_complex b
) {
12781 return __pyx_t_float_complex_from_parts(a
.real
/ b
.real
, a
.imag
/ b
.real
);
12783 float denom
= b
.real
* b
.real
+ b
.imag
* b
.imag
;
12784 return __pyx_t_float_complex_from_parts(
12785 (a
.real
* b
.real
+ a
.imag
* b
.imag
) / denom
,
12786 (a
.imag
* b
.real
- a
.real
* b
.imag
) / denom
);
12790 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_neg_float(__pyx_t_float_complex a
) {
12791 __pyx_t_float_complex z
;
12796 static CYTHON_INLINE
int __Pyx_c_is_zero_float(__pyx_t_float_complex a
) {
12797 return (a
.real
== 0) && (a
.imag
== 0);
12799 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_conj_float(__pyx_t_float_complex a
) {
12800 __pyx_t_float_complex z
;
12806 static CYTHON_INLINE
float __Pyx_c_abs_float(__pyx_t_float_complex z
) {
12807 #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
12808 return sqrtf(z
.real
*z
.real
+ z
.imag
*z
.imag
);
12810 return hypotf(z
.real
, z
.imag
);
12813 static CYTHON_INLINE __pyx_t_float_complex
__Pyx_c_pow_float(__pyx_t_float_complex a
, __pyx_t_float_complex b
) {
12814 __pyx_t_float_complex z
;
12815 float r
, lnr
, theta
, z_r
, z_theta
;
12816 if (b
.imag
== 0 && b
.real
== (int)b
.real
) {
12818 float denom
= a
.real
* a
.real
+ a
.imag
* a
.imag
;
12819 a
.real
= a
.real
/ denom
;
12820 a
.imag
= -a
.imag
/ denom
;
12823 switch ((int)b
.real
) {
12831 return __Pyx_c_prod_float(a
, a
);
12833 z
= __Pyx_c_prod_float(a
, a
);
12834 return __Pyx_c_prod_float(z
, a
);
12836 z
= __Pyx_c_prod_float(a
, a
);
12837 return __Pyx_c_prod_float(z
, z
);
12843 } else if (b
.imag
== 0) {
12844 z
.real
= powf(a
.real
, b
.real
);
12847 } else if (a
.real
> 0) {
12852 theta
= atan2f(0.0, -1.0);
12855 r
= __Pyx_c_abs_float(a
);
12856 theta
= atan2f(a
.imag
, a
.real
);
12859 z_r
= expf(lnr
* b
.real
- theta
* b
.imag
);
12860 z_theta
= theta
* b
.real
+ lnr
* b
.imag
;
12861 z
.real
= z_r
* cosf(z_theta
);
12862 z
.imag
= z_r
* sinf(z_theta
);
12869 #if CYTHON_CCOMPLEX
12871 static CYTHON_INLINE __pyx_t_double_complex
__pyx_t_double_complex_from_parts(double x
, double y
) {
12872 return ::std::complex< double >(x
, y
);
12875 static CYTHON_INLINE __pyx_t_double_complex
__pyx_t_double_complex_from_parts(double x
, double y
) {
12876 return x
+ y
*(__pyx_t_double_complex
)_Complex_I
;
12880 static CYTHON_INLINE __pyx_t_double_complex
__pyx_t_double_complex_from_parts(double x
, double y
) {
12881 __pyx_t_double_complex z
;
12889 #if CYTHON_CCOMPLEX
12891 static CYTHON_INLINE
int __Pyx_c_eq_double(__pyx_t_double_complex a
, __pyx_t_double_complex b
) {
12892 return (a
.real
== b
.real
) && (a
.imag
== b
.imag
);
12894 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_sum_double(__pyx_t_double_complex a
, __pyx_t_double_complex b
) {
12895 __pyx_t_double_complex z
;
12896 z
.real
= a
.real
+ b
.real
;
12897 z
.imag
= a
.imag
+ b
.imag
;
12900 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_diff_double(__pyx_t_double_complex a
, __pyx_t_double_complex b
) {
12901 __pyx_t_double_complex z
;
12902 z
.real
= a
.real
- b
.real
;
12903 z
.imag
= a
.imag
- b
.imag
;
12906 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_prod_double(__pyx_t_double_complex a
, __pyx_t_double_complex b
) {
12907 __pyx_t_double_complex z
;
12908 z
.real
= a
.real
* b
.real
- a
.imag
* b
.imag
;
12909 z
.imag
= a
.real
* b
.imag
+ a
.imag
* b
.real
;
12913 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_quot_double(__pyx_t_double_complex a
, __pyx_t_double_complex b
) {
12915 return __pyx_t_double_complex_from_parts(a
.real
/ b
.real
, a
.imag
/ b
.real
);
12916 } else if (fabs(b
.real
) >= fabs(b
.imag
)) {
12917 if (b
.real
== 0 && b
.imag
== 0) {
12918 return __pyx_t_double_complex_from_parts(a
.real
/ b
.real
, a
.imag
/ b
.imag
);
12920 double r
= b
.imag
/ b
.real
;
12921 double s
= (double)(1.0) / (b
.real
+ b
.imag
* r
);
12922 return __pyx_t_double_complex_from_parts(
12923 (a
.real
+ a
.imag
* r
) * s
, (a
.imag
- a
.real
* r
) * s
);
12926 double r
= b
.real
/ b
.imag
;
12927 double s
= (double)(1.0) / (b
.imag
+ b
.real
* r
);
12928 return __pyx_t_double_complex_from_parts(
12929 (a
.real
* r
+ a
.imag
) * s
, (a
.imag
* r
- a
.real
) * s
);
12933 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_quot_double(__pyx_t_double_complex a
, __pyx_t_double_complex b
) {
12935 return __pyx_t_double_complex_from_parts(a
.real
/ b
.real
, a
.imag
/ b
.real
);
12937 double denom
= b
.real
* b
.real
+ b
.imag
* b
.imag
;
12938 return __pyx_t_double_complex_from_parts(
12939 (a
.real
* b
.real
+ a
.imag
* b
.imag
) / denom
,
12940 (a
.imag
* b
.real
- a
.real
* b
.imag
) / denom
);
12944 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_neg_double(__pyx_t_double_complex a
) {
12945 __pyx_t_double_complex z
;
12950 static CYTHON_INLINE
int __Pyx_c_is_zero_double(__pyx_t_double_complex a
) {
12951 return (a
.real
== 0) && (a
.imag
== 0);
12953 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_conj_double(__pyx_t_double_complex a
) {
12954 __pyx_t_double_complex z
;
12960 static CYTHON_INLINE
double __Pyx_c_abs_double(__pyx_t_double_complex z
) {
12961 #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
12962 return sqrt(z
.real
*z
.real
+ z
.imag
*z
.imag
);
12964 return hypot(z
.real
, z
.imag
);
12967 static CYTHON_INLINE __pyx_t_double_complex
__Pyx_c_pow_double(__pyx_t_double_complex a
, __pyx_t_double_complex b
) {
12968 __pyx_t_double_complex z
;
12969 double r
, lnr
, theta
, z_r
, z_theta
;
12970 if (b
.imag
== 0 && b
.real
== (int)b
.real
) {
12972 double denom
= a
.real
* a
.real
+ a
.imag
* a
.imag
;
12973 a
.real
= a
.real
/ denom
;
12974 a
.imag
= -a
.imag
/ denom
;
12977 switch ((int)b
.real
) {
12985 return __Pyx_c_prod_double(a
, a
);
12987 z
= __Pyx_c_prod_double(a
, a
);
12988 return __Pyx_c_prod_double(z
, a
);
12990 z
= __Pyx_c_prod_double(a
, a
);
12991 return __Pyx_c_prod_double(z
, z
);
12997 } else if (b
.imag
== 0) {
12998 z
.real
= pow(a
.real
, b
.real
);
13001 } else if (a
.real
> 0) {
13006 theta
= atan2(0.0, -1.0);
13009 r
= __Pyx_c_abs_double(a
);
13010 theta
= atan2(a
.imag
, a
.real
);
13013 z_r
= exp(lnr
* b
.real
- theta
* b
.imag
);
13014 z_theta
= theta
* b
.real
+ lnr
* b
.imag
;
13015 z
.real
= z_r
* cos(z_theta
);
13016 z
.imag
= z_r
* sin(z_theta
);
13023 static CYTHON_INLINE PyObject
* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value
) {
13024 const enum NPY_TYPES neg_one
= (enum NPY_TYPES
) ((enum NPY_TYPES
) 0 - (enum NPY_TYPES
) 1), const_zero
= (enum NPY_TYPES
) 0;
13025 const int is_unsigned
= neg_one
> const_zero
;
13027 if (sizeof(enum NPY_TYPES
) < sizeof(long)) {
13028 return PyInt_FromLong((long) value
);
13029 } else if (sizeof(enum NPY_TYPES
) <= sizeof(unsigned long)) {
13030 return PyLong_FromUnsignedLong((unsigned long) value
);
13031 #ifdef HAVE_LONG_LONG
13032 } else if (sizeof(enum NPY_TYPES
) <= sizeof(unsigned PY_LONG_LONG
)) {
13033 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG
) value
);
13037 if (sizeof(enum NPY_TYPES
) <= sizeof(long)) {
13038 return PyInt_FromLong((long) value
);
13039 #ifdef HAVE_LONG_LONG
13040 } else if (sizeof(enum NPY_TYPES
) <= sizeof(PY_LONG_LONG
)) {
13041 return PyLong_FromLongLong((PY_LONG_LONG
) value
);
13046 int one
= 1; int little
= (int)*(unsigned char *)&one
;
13047 unsigned char *bytes
= (unsigned char *)&value
;
13048 return _PyLong_FromByteArray(bytes
, sizeof(enum NPY_TYPES
),
13049 little
, !is_unsigned
);
13054 static CYTHON_INLINE
int __Pyx_PyInt_As_int(PyObject
*x
) {
13055 const int neg_one
= (int) ((int) 0 - (int) 1), const_zero
= (int) 0;
13056 const int is_unsigned
= neg_one
> const_zero
;
13057 #if PY_MAJOR_VERSION < 3
13058 if (likely(PyInt_Check(x
))) {
13059 if (sizeof(int) < sizeof(long)) {
13060 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x
))
13062 long val
= PyInt_AS_LONG(x
);
13063 if (is_unsigned
&& unlikely(val
< 0)) {
13064 goto raise_neg_overflow
;
13070 if (likely(PyLong_Check(x
))) {
13072 #if CYTHON_USE_PYLONG_INTERNALS
13073 const digit
* digits
= ((PyLongObject
*)x
)->ob_digit
;
13074 switch (Py_SIZE(x
)) {
13075 case 0: return (int) 0;
13076 case 1: __PYX_VERIFY_RETURN_INT(int, digit
, digits
[0])
13078 if (8 * sizeof(int) > 1 * PyLong_SHIFT
) {
13079 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13080 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13081 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT
) {
13082 return (int) (((((int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0]));
13087 if (8 * sizeof(int) > 2 * PyLong_SHIFT
) {
13088 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13089 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13090 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT
) {
13091 return (int) (((((((int)digits
[2]) << PyLong_SHIFT
) | (int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0]));
13096 if (8 * sizeof(int) > 3 * PyLong_SHIFT
) {
13097 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13098 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13099 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT
) {
13100 return (int) (((((((((int)digits
[3]) << PyLong_SHIFT
) | (int)digits
[2]) << PyLong_SHIFT
) | (int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0]));
13106 #if CYTHON_COMPILING_IN_CPYTHON
13107 if (unlikely(Py_SIZE(x
) < 0)) {
13108 goto raise_neg_overflow
;
13112 int result
= PyObject_RichCompareBool(x
, Py_False
, Py_LT
);
13113 if (unlikely(result
< 0))
13115 if (unlikely(result
== 1))
13116 goto raise_neg_overflow
;
13119 if (sizeof(int) <= sizeof(unsigned long)) {
13120 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x
))
13121 #ifdef HAVE_LONG_LONG
13122 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG
)) {
13123 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG
, PyLong_AsUnsignedLongLong(x
))
13127 #if CYTHON_USE_PYLONG_INTERNALS
13128 const digit
* digits
= ((PyLongObject
*)x
)->ob_digit
;
13129 switch (Py_SIZE(x
)) {
13130 case 0: return (int) 0;
13131 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit
, (sdigit
) (-(sdigit
)digits
[0]))
13132 case 1: __PYX_VERIFY_RETURN_INT(int, digit
, +digits
[0])
13134 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT
) {
13135 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13136 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13137 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT
) {
13138 return (int) (((int)-1)*(((((int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0])));
13143 if (8 * sizeof(int) > 1 * PyLong_SHIFT
) {
13144 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13145 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13146 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT
) {
13147 return (int) ((((((int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0])));
13152 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT
) {
13153 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13154 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13155 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT
) {
13156 return (int) (((int)-1)*(((((((int)digits
[2]) << PyLong_SHIFT
) | (int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0])));
13161 if (8 * sizeof(int) > 2 * PyLong_SHIFT
) {
13162 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13163 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13164 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT
) {
13165 return (int) ((((((((int)digits
[2]) << PyLong_SHIFT
) | (int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0])));
13170 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT
) {
13171 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13172 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13173 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT
) {
13174 return (int) (((int)-1)*(((((((((int)digits
[3]) << PyLong_SHIFT
) | (int)digits
[2]) << PyLong_SHIFT
) | (int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0])));
13179 if (8 * sizeof(int) > 3 * PyLong_SHIFT
) {
13180 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13181 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13182 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT
) {
13183 return (int) ((((((((((int)digits
[3]) << PyLong_SHIFT
) | (int)digits
[2]) << PyLong_SHIFT
) | (int)digits
[1]) << PyLong_SHIFT
) | (int)digits
[0])));
13189 if (sizeof(int) <= sizeof(long)) {
13190 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x
))
13191 #ifdef HAVE_LONG_LONG
13192 } else if (sizeof(int) <= sizeof(PY_LONG_LONG
)) {
13193 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG
, PyLong_AsLongLong(x
))
13198 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
13199 PyErr_SetString(PyExc_RuntimeError
,
13200 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
13203 PyObject
*v
= __Pyx_PyNumber_IntOrLong(x
);
13204 #if PY_MAJOR_VERSION < 3
13205 if (likely(v
) && !PyLong_Check(v
)) {
13207 v
= PyNumber_Long(tmp
);
13212 int one
= 1; int is_little
= (int)*(unsigned char *)&one
;
13213 unsigned char *bytes
= (unsigned char *)&val
;
13214 int ret
= _PyLong_AsByteArray((PyLongObject
*)v
,
13215 bytes
, sizeof(val
),
13216 is_little
, !is_unsigned
);
13226 PyObject
*tmp
= __Pyx_PyNumber_IntOrLong(x
);
13227 if (!tmp
) return (int) -1;
13228 val
= __Pyx_PyInt_As_int(tmp
);
13233 PyErr_SetString(PyExc_OverflowError
,
13234 "value too large to convert to int");
13236 raise_neg_overflow
:
13237 PyErr_SetString(PyExc_OverflowError
,
13238 "can't convert negative value to int");
13243 static CYTHON_INLINE npy_int32
__Pyx_PyInt_As_npy_int32(PyObject
*x
) {
13244 const npy_int32 neg_one
= (npy_int32
) ((npy_int32
) 0 - (npy_int32
) 1), const_zero
= (npy_int32
) 0;
13245 const int is_unsigned
= neg_one
> const_zero
;
13246 #if PY_MAJOR_VERSION < 3
13247 if (likely(PyInt_Check(x
))) {
13248 if (sizeof(npy_int32
) < sizeof(long)) {
13249 __PYX_VERIFY_RETURN_INT(npy_int32
, long, PyInt_AS_LONG(x
))
13251 long val
= PyInt_AS_LONG(x
);
13252 if (is_unsigned
&& unlikely(val
< 0)) {
13253 goto raise_neg_overflow
;
13255 return (npy_int32
) val
;
13259 if (likely(PyLong_Check(x
))) {
13261 #if CYTHON_USE_PYLONG_INTERNALS
13262 const digit
* digits
= ((PyLongObject
*)x
)->ob_digit
;
13263 switch (Py_SIZE(x
)) {
13264 case 0: return (npy_int32
) 0;
13265 case 1: __PYX_VERIFY_RETURN_INT(npy_int32
, digit
, digits
[0])
13267 if (8 * sizeof(npy_int32
) > 1 * PyLong_SHIFT
) {
13268 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13269 __PYX_VERIFY_RETURN_INT(npy_int32
, unsigned long, (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13270 } else if (8 * sizeof(npy_int32
) >= 2 * PyLong_SHIFT
) {
13271 return (npy_int32
) (((((npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0]));
13276 if (8 * sizeof(npy_int32
) > 2 * PyLong_SHIFT
) {
13277 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13278 __PYX_VERIFY_RETURN_INT(npy_int32
, unsigned long, (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13279 } else if (8 * sizeof(npy_int32
) >= 3 * PyLong_SHIFT
) {
13280 return (npy_int32
) (((((((npy_int32
)digits
[2]) << PyLong_SHIFT
) | (npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0]));
13285 if (8 * sizeof(npy_int32
) > 3 * PyLong_SHIFT
) {
13286 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13287 __PYX_VERIFY_RETURN_INT(npy_int32
, unsigned long, (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13288 } else if (8 * sizeof(npy_int32
) >= 4 * PyLong_SHIFT
) {
13289 return (npy_int32
) (((((((((npy_int32
)digits
[3]) << PyLong_SHIFT
) | (npy_int32
)digits
[2]) << PyLong_SHIFT
) | (npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0]));
13295 #if CYTHON_COMPILING_IN_CPYTHON
13296 if (unlikely(Py_SIZE(x
) < 0)) {
13297 goto raise_neg_overflow
;
13301 int result
= PyObject_RichCompareBool(x
, Py_False
, Py_LT
);
13302 if (unlikely(result
< 0))
13303 return (npy_int32
) -1;
13304 if (unlikely(result
== 1))
13305 goto raise_neg_overflow
;
13308 if (sizeof(npy_int32
) <= sizeof(unsigned long)) {
13309 __PYX_VERIFY_RETURN_INT_EXC(npy_int32
, unsigned long, PyLong_AsUnsignedLong(x
))
13310 #ifdef HAVE_LONG_LONG
13311 } else if (sizeof(npy_int32
) <= sizeof(unsigned PY_LONG_LONG
)) {
13312 __PYX_VERIFY_RETURN_INT_EXC(npy_int32
, unsigned PY_LONG_LONG
, PyLong_AsUnsignedLongLong(x
))
13316 #if CYTHON_USE_PYLONG_INTERNALS
13317 const digit
* digits
= ((PyLongObject
*)x
)->ob_digit
;
13318 switch (Py_SIZE(x
)) {
13319 case 0: return (npy_int32
) 0;
13320 case -1: __PYX_VERIFY_RETURN_INT(npy_int32
, sdigit
, (sdigit
) (-(sdigit
)digits
[0]))
13321 case 1: __PYX_VERIFY_RETURN_INT(npy_int32
, digit
, +digits
[0])
13323 if (8 * sizeof(npy_int32
) - 1 > 1 * PyLong_SHIFT
) {
13324 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13325 __PYX_VERIFY_RETURN_INT(npy_int32
, long, -(long) (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13326 } else if (8 * sizeof(npy_int32
) - 1 > 2 * PyLong_SHIFT
) {
13327 return (npy_int32
) (((npy_int32
)-1)*(((((npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0])));
13332 if (8 * sizeof(npy_int32
) > 1 * PyLong_SHIFT
) {
13333 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13334 __PYX_VERIFY_RETURN_INT(npy_int32
, unsigned long, (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13335 } else if (8 * sizeof(npy_int32
) - 1 > 2 * PyLong_SHIFT
) {
13336 return (npy_int32
) ((((((npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0])));
13341 if (8 * sizeof(npy_int32
) - 1 > 2 * PyLong_SHIFT
) {
13342 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13343 __PYX_VERIFY_RETURN_INT(npy_int32
, long, -(long) (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13344 } else if (8 * sizeof(npy_int32
) - 1 > 3 * PyLong_SHIFT
) {
13345 return (npy_int32
) (((npy_int32
)-1)*(((((((npy_int32
)digits
[2]) << PyLong_SHIFT
) | (npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0])));
13350 if (8 * sizeof(npy_int32
) > 2 * PyLong_SHIFT
) {
13351 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13352 __PYX_VERIFY_RETURN_INT(npy_int32
, unsigned long, (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13353 } else if (8 * sizeof(npy_int32
) - 1 > 3 * PyLong_SHIFT
) {
13354 return (npy_int32
) ((((((((npy_int32
)digits
[2]) << PyLong_SHIFT
) | (npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0])));
13359 if (8 * sizeof(npy_int32
) - 1 > 3 * PyLong_SHIFT
) {
13360 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13361 __PYX_VERIFY_RETURN_INT(npy_int32
, long, -(long) (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13362 } else if (8 * sizeof(npy_int32
) - 1 > 4 * PyLong_SHIFT
) {
13363 return (npy_int32
) (((npy_int32
)-1)*(((((((((npy_int32
)digits
[3]) << PyLong_SHIFT
) | (npy_int32
)digits
[2]) << PyLong_SHIFT
) | (npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0])));
13368 if (8 * sizeof(npy_int32
) > 3 * PyLong_SHIFT
) {
13369 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13370 __PYX_VERIFY_RETURN_INT(npy_int32
, unsigned long, (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13371 } else if (8 * sizeof(npy_int32
) - 1 > 4 * PyLong_SHIFT
) {
13372 return (npy_int32
) ((((((((((npy_int32
)digits
[3]) << PyLong_SHIFT
) | (npy_int32
)digits
[2]) << PyLong_SHIFT
) | (npy_int32
)digits
[1]) << PyLong_SHIFT
) | (npy_int32
)digits
[0])));
13378 if (sizeof(npy_int32
) <= sizeof(long)) {
13379 __PYX_VERIFY_RETURN_INT_EXC(npy_int32
, long, PyLong_AsLong(x
))
13380 #ifdef HAVE_LONG_LONG
13381 } else if (sizeof(npy_int32
) <= sizeof(PY_LONG_LONG
)) {
13382 __PYX_VERIFY_RETURN_INT_EXC(npy_int32
, PY_LONG_LONG
, PyLong_AsLongLong(x
))
13387 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
13388 PyErr_SetString(PyExc_RuntimeError
,
13389 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
13392 PyObject
*v
= __Pyx_PyNumber_IntOrLong(x
);
13393 #if PY_MAJOR_VERSION < 3
13394 if (likely(v
) && !PyLong_Check(v
)) {
13396 v
= PyNumber_Long(tmp
);
13401 int one
= 1; int is_little
= (int)*(unsigned char *)&one
;
13402 unsigned char *bytes
= (unsigned char *)&val
;
13403 int ret
= _PyLong_AsByteArray((PyLongObject
*)v
,
13404 bytes
, sizeof(val
),
13405 is_little
, !is_unsigned
);
13411 return (npy_int32
) -1;
13415 PyObject
*tmp
= __Pyx_PyNumber_IntOrLong(x
);
13416 if (!tmp
) return (npy_int32
) -1;
13417 val
= __Pyx_PyInt_As_npy_int32(tmp
);
13422 PyErr_SetString(PyExc_OverflowError
,
13423 "value too large to convert to npy_int32");
13424 return (npy_int32
) -1;
13425 raise_neg_overflow
:
13426 PyErr_SetString(PyExc_OverflowError
,
13427 "can't convert negative value to npy_int32");
13428 return (npy_int32
) -1;
13432 static CYTHON_INLINE
long __Pyx_PyInt_As_long(PyObject
*x
) {
13433 const long neg_one
= (long) ((long) 0 - (long) 1), const_zero
= (long) 0;
13434 const int is_unsigned
= neg_one
> const_zero
;
13435 #if PY_MAJOR_VERSION < 3
13436 if (likely(PyInt_Check(x
))) {
13437 if (sizeof(long) < sizeof(long)) {
13438 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x
))
13440 long val
= PyInt_AS_LONG(x
);
13441 if (is_unsigned
&& unlikely(val
< 0)) {
13442 goto raise_neg_overflow
;
13448 if (likely(PyLong_Check(x
))) {
13450 #if CYTHON_USE_PYLONG_INTERNALS
13451 const digit
* digits
= ((PyLongObject
*)x
)->ob_digit
;
13452 switch (Py_SIZE(x
)) {
13453 case 0: return (long) 0;
13454 case 1: __PYX_VERIFY_RETURN_INT(long, digit
, digits
[0])
13456 if (8 * sizeof(long) > 1 * PyLong_SHIFT
) {
13457 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13458 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13459 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT
) {
13460 return (long) (((((long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0]));
13465 if (8 * sizeof(long) > 2 * PyLong_SHIFT
) {
13466 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13467 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13468 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT
) {
13469 return (long) (((((((long)digits
[2]) << PyLong_SHIFT
) | (long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0]));
13474 if (8 * sizeof(long) > 3 * PyLong_SHIFT
) {
13475 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13476 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13477 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT
) {
13478 return (long) (((((((((long)digits
[3]) << PyLong_SHIFT
) | (long)digits
[2]) << PyLong_SHIFT
) | (long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0]));
13484 #if CYTHON_COMPILING_IN_CPYTHON
13485 if (unlikely(Py_SIZE(x
) < 0)) {
13486 goto raise_neg_overflow
;
13490 int result
= PyObject_RichCompareBool(x
, Py_False
, Py_LT
);
13491 if (unlikely(result
< 0))
13493 if (unlikely(result
== 1))
13494 goto raise_neg_overflow
;
13497 if (sizeof(long) <= sizeof(unsigned long)) {
13498 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x
))
13499 #ifdef HAVE_LONG_LONG
13500 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG
)) {
13501 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG
, PyLong_AsUnsignedLongLong(x
))
13505 #if CYTHON_USE_PYLONG_INTERNALS
13506 const digit
* digits
= ((PyLongObject
*)x
)->ob_digit
;
13507 switch (Py_SIZE(x
)) {
13508 case 0: return (long) 0;
13509 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit
, (sdigit
) (-(sdigit
)digits
[0]))
13510 case 1: __PYX_VERIFY_RETURN_INT(long, digit
, +digits
[0])
13512 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT
) {
13513 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13514 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13515 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT
) {
13516 return (long) (((long)-1)*(((((long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0])));
13521 if (8 * sizeof(long) > 1 * PyLong_SHIFT
) {
13522 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT
) {
13523 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13524 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT
) {
13525 return (long) ((((((long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0])));
13530 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT
) {
13531 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13532 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13533 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT
) {
13534 return (long) (((long)-1)*(((((((long)digits
[2]) << PyLong_SHIFT
) | (long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0])));
13539 if (8 * sizeof(long) > 2 * PyLong_SHIFT
) {
13540 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT
) {
13541 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13542 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT
) {
13543 return (long) ((((((((long)digits
[2]) << PyLong_SHIFT
) | (long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0])));
13548 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT
) {
13549 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13550 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13551 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT
) {
13552 return (long) (((long)-1)*(((((((((long)digits
[3]) << PyLong_SHIFT
) | (long)digits
[2]) << PyLong_SHIFT
) | (long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0])));
13557 if (8 * sizeof(long) > 3 * PyLong_SHIFT
) {
13558 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT
) {
13559 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits
[3]) << PyLong_SHIFT
) | (unsigned long)digits
[2]) << PyLong_SHIFT
) | (unsigned long)digits
[1]) << PyLong_SHIFT
) | (unsigned long)digits
[0])))
13560 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT
) {
13561 return (long) ((((((((((long)digits
[3]) << PyLong_SHIFT
) | (long)digits
[2]) << PyLong_SHIFT
) | (long)digits
[1]) << PyLong_SHIFT
) | (long)digits
[0])));
13567 if (sizeof(long) <= sizeof(long)) {
13568 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x
))
13569 #ifdef HAVE_LONG_LONG
13570 } else if (sizeof(long) <= sizeof(PY_LONG_LONG
)) {
13571 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG
, PyLong_AsLongLong(x
))
13576 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
13577 PyErr_SetString(PyExc_RuntimeError
,
13578 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
13581 PyObject
*v
= __Pyx_PyNumber_IntOrLong(x
);
13582 #if PY_MAJOR_VERSION < 3
13583 if (likely(v
) && !PyLong_Check(v
)) {
13585 v
= PyNumber_Long(tmp
);
13590 int one
= 1; int is_little
= (int)*(unsigned char *)&one
;
13591 unsigned char *bytes
= (unsigned char *)&val
;
13592 int ret
= _PyLong_AsByteArray((PyLongObject
*)v
,
13593 bytes
, sizeof(val
),
13594 is_little
, !is_unsigned
);
13604 PyObject
*tmp
= __Pyx_PyNumber_IntOrLong(x
);
13605 if (!tmp
) return (long) -1;
13606 val
= __Pyx_PyInt_As_long(tmp
);
13611 PyErr_SetString(PyExc_OverflowError
,
13612 "value too large to convert to long");
13614 raise_neg_overflow
:
13615 PyErr_SetString(PyExc_OverflowError
,
13616 "can't convert negative value to long");
13620 /* FastTypeChecks */
13621 #if CYTHON_COMPILING_IN_CPYTHON
13622 static int __Pyx_InBases(PyTypeObject
*a
, PyTypeObject
*b
) {
13628 return b
== &PyBaseObject_Type
;
13630 static CYTHON_INLINE
int __Pyx_IsSubtype(PyTypeObject
*a
, PyTypeObject
*b
) {
13632 if (a
== b
) return 1;
13636 n
= PyTuple_GET_SIZE(mro
);
13637 for (i
= 0; i
< n
; i
++) {
13638 if (PyTuple_GET_ITEM(mro
, i
) == (PyObject
*)b
)
13643 return __Pyx_InBases(a
, b
);
13645 #if PY_MAJOR_VERSION == 2
13646 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject
*err
, PyObject
* exc_type1
, PyObject
* exc_type2
) {
13647 PyObject
*exception
, *value
, *tb
;
13649 __Pyx_PyThreadState_declare
13650 __Pyx_PyThreadState_assign
13651 __Pyx_ErrFetch(&exception
, &value
, &tb
);
13652 res
= exc_type1
? PyObject_IsSubclass(err
, exc_type1
) : 0;
13653 if (unlikely(res
== -1)) {
13654 PyErr_WriteUnraisable(err
);
13658 res
= PyObject_IsSubclass(err
, exc_type2
);
13659 if (unlikely(res
== -1)) {
13660 PyErr_WriteUnraisable(err
);
13664 __Pyx_ErrRestore(exception
, value
, tb
);
13668 static CYTHON_INLINE
int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject
*err
, PyObject
* exc_type1
, PyObject
*exc_type2
) {
13669 int res
= exc_type1
? __Pyx_IsSubtype((PyTypeObject
*)err
, (PyTypeObject
*)exc_type1
) : 0;
13671 res
= __Pyx_IsSubtype((PyTypeObject
*)err
, (PyTypeObject
*)exc_type2
);
13676 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject
*exc_type
, PyObject
*tuple
) {
13678 assert(PyExceptionClass_Check(exc_type
));
13679 n
= PyTuple_GET_SIZE(tuple
);
13680 #if PY_MAJOR_VERSION >= 3
13681 for (i
=0; i
<n
; i
++) {
13682 if (exc_type
== PyTuple_GET_ITEM(tuple
, i
)) return 1;
13685 for (i
=0; i
<n
; i
++) {
13686 PyObject
*t
= PyTuple_GET_ITEM(tuple
, i
);
13687 #if PY_MAJOR_VERSION < 3
13688 if (likely(exc_type
== t
)) return 1;
13690 if (likely(PyExceptionClass_Check(t
))) {
13691 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type
, NULL
, t
)) return 1;
13697 static CYTHON_INLINE
int __Pyx_PyErr_GivenExceptionMatches(PyObject
*err
, PyObject
* exc_type
) {
13698 if (likely(err
== exc_type
)) return 1;
13699 if (likely(PyExceptionClass_Check(err
))) {
13700 if (likely(PyExceptionClass_Check(exc_type
))) {
13701 return __Pyx_inner_PyErr_GivenExceptionMatches2(err
, NULL
, exc_type
);
13702 } else if (likely(PyTuple_Check(exc_type
))) {
13703 return __Pyx_PyErr_GivenExceptionMatchesTuple(err
, exc_type
);
13707 return PyErr_GivenExceptionMatches(err
, exc_type
);
13709 static CYTHON_INLINE
int __Pyx_PyErr_GivenExceptionMatches2(PyObject
*err
, PyObject
*exc_type1
, PyObject
*exc_type2
) {
13710 assert(PyExceptionClass_Check(exc_type1
));
13711 assert(PyExceptionClass_Check(exc_type2
));
13712 if (likely(err
== exc_type1
|| err
== exc_type2
)) return 1;
13713 if (likely(PyExceptionClass_Check(err
))) {
13714 return __Pyx_inner_PyErr_GivenExceptionMatches2(err
, exc_type1
, exc_type2
);
13716 return (PyErr_GivenExceptionMatches(err
, exc_type1
) || PyErr_GivenExceptionMatches(err
, exc_type2
));
13720 /* CheckBinaryVersion */
13721 static int __Pyx_check_binary_version(void) {
13722 char ctversion
[4], rtversion
[4];
13723 PyOS_snprintf(ctversion
, 4, "%d.%d", PY_MAJOR_VERSION
, PY_MINOR_VERSION
);
13724 PyOS_snprintf(rtversion
, 4, "%s", Py_GetVersion());
13725 if (ctversion
[0] != rtversion
[0] || ctversion
[2] != rtversion
[2]) {
13727 PyOS_snprintf(message
, sizeof(message
),
13728 "compiletime version %s of module '%.100s' "
13729 "does not match runtime version %s",
13730 ctversion
, __Pyx_MODULE_NAME
, rtversion
);
13731 return PyErr_WarnEx(NULL
, message
, 1);
13737 static int __Pyx_InitStrings(__Pyx_StringTabEntry
*t
) {
13739 #if PY_MAJOR_VERSION < 3
13740 if (t
->is_unicode
) {
13741 *t
->p
= PyUnicode_DecodeUTF8(t
->s
, t
->n
- 1, NULL
);
13742 } else if (t
->intern
) {
13743 *t
->p
= PyString_InternFromString(t
->s
);
13745 *t
->p
= PyString_FromStringAndSize(t
->s
, t
->n
- 1);
13748 if (t
->is_unicode
| t
->is_str
) {
13750 *t
->p
= PyUnicode_InternFromString(t
->s
);
13751 } else if (t
->encoding
) {
13752 *t
->p
= PyUnicode_Decode(t
->s
, t
->n
- 1, t
->encoding
, NULL
);
13754 *t
->p
= PyUnicode_FromStringAndSize(t
->s
, t
->n
- 1);
13757 *t
->p
= PyBytes_FromStringAndSize(t
->s
, t
->n
- 1);
13762 if (PyObject_Hash(*t
->p
) == -1)
13769 static CYTHON_INLINE PyObject
* __Pyx_PyUnicode_FromString(const char* c_str
) {
13770 return __Pyx_PyUnicode_FromStringAndSize(c_str
, (Py_ssize_t
)strlen(c_str
));
13772 static CYTHON_INLINE
const char* __Pyx_PyObject_AsString(PyObject
* o
) {
13774 return __Pyx_PyObject_AsStringAndSize(o
, &ignore
);
13776 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
13777 #if !CYTHON_PEP393_ENABLED
13778 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject
* o
, Py_ssize_t
*length
) {
13780 PyObject
* defenc
= _PyUnicode_AsDefaultEncodedString(o
, NULL
);
13781 if (!defenc
) return NULL
;
13782 defenc_c
= PyBytes_AS_STRING(defenc
);
13783 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
13785 char* end
= defenc_c
+ PyBytes_GET_SIZE(defenc
);
13787 for (c
= defenc_c
; c
< end
; c
++) {
13788 if ((unsigned char) (*c
) >= 128) {
13789 PyUnicode_AsASCIIString(o
);
13795 *length
= PyBytes_GET_SIZE(defenc
);
13799 static CYTHON_INLINE
const char* __Pyx_PyUnicode_AsStringAndSize(PyObject
* o
, Py_ssize_t
*length
) {
13800 if (unlikely(__Pyx_PyUnicode_READY(o
) == -1)) return NULL
;
13801 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
13802 if (likely(PyUnicode_IS_ASCII(o
))) {
13803 *length
= PyUnicode_GET_LENGTH(o
);
13804 return PyUnicode_AsUTF8(o
);
13806 PyUnicode_AsASCIIString(o
);
13810 return PyUnicode_AsUTF8AndSize(o
, length
);
13815 static CYTHON_INLINE
const char* __Pyx_PyObject_AsStringAndSize(PyObject
* o
, Py_ssize_t
*length
) {
13816 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
13818 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
13819 __Pyx_sys_getdefaultencoding_not_ascii
&&
13821 PyUnicode_Check(o
)) {
13822 return __Pyx_PyUnicode_AsStringAndSize(o
, length
);
13825 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
13826 if (PyByteArray_Check(o
)) {
13827 *length
= PyByteArray_GET_SIZE(o
);
13828 return PyByteArray_AS_STRING(o
);
13833 int r
= PyBytes_AsStringAndSize(o
, &result
, length
);
13834 if (unlikely(r
< 0)) {
13841 static CYTHON_INLINE
int __Pyx_PyObject_IsTrue(PyObject
* x
) {
13842 int is_true
= x
== Py_True
;
13843 if (is_true
| (x
== Py_False
) | (x
== Py_None
)) return is_true
;
13844 else return PyObject_IsTrue(x
);
13846 static CYTHON_INLINE
int __Pyx_PyObject_IsTrueAndDecref(PyObject
* x
) {
13848 if (unlikely(!x
)) return -1;
13849 retval
= __Pyx_PyObject_IsTrue(x
);
13853 static PyObject
* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject
* result
, const char* type_name
) {
13854 #if PY_MAJOR_VERSION >= 3
13855 if (PyLong_Check(result
)) {
13856 if (PyErr_WarnFormat(PyExc_DeprecationWarning
, 1,
13857 "__int__ returned non-int (type %.200s). "
13858 "The ability to return an instance of a strict subclass of int "
13859 "is deprecated, and may be removed in a future version of Python.",
13860 Py_TYPE(result
)->tp_name
)) {
13867 PyErr_Format(PyExc_TypeError
,
13868 "__%.4s__ returned non-%.4s (type %.200s)",
13869 type_name
, type_name
, Py_TYPE(result
)->tp_name
);
13873 static CYTHON_INLINE PyObject
* __Pyx_PyNumber_IntOrLong(PyObject
* x
) {
13874 #if CYTHON_USE_TYPE_SLOTS
13875 PyNumberMethods
*m
;
13877 const char *name
= NULL
;
13878 PyObject
*res
= NULL
;
13879 #if PY_MAJOR_VERSION < 3
13880 if (likely(PyInt_Check(x
) || PyLong_Check(x
)))
13882 if (likely(PyLong_Check(x
)))
13884 return __Pyx_NewRef(x
);
13885 #if CYTHON_USE_TYPE_SLOTS
13886 m
= Py_TYPE(x
)->tp_as_number
;
13887 #if PY_MAJOR_VERSION < 3
13888 if (m
&& m
->nb_int
) {
13890 res
= m
->nb_int(x
);
13892 else if (m
&& m
->nb_long
) {
13894 res
= m
->nb_long(x
);
13897 if (likely(m
&& m
->nb_int
)) {
13899 res
= m
->nb_int(x
);
13903 if (!PyBytes_CheckExact(x
) && !PyUnicode_CheckExact(x
)) {
13904 res
= PyNumber_Int(x
);
13908 #if PY_MAJOR_VERSION < 3
13909 if (unlikely(!PyInt_Check(res
) && !PyLong_Check(res
))) {
13911 if (unlikely(!PyLong_CheckExact(res
))) {
13913 return __Pyx_PyNumber_IntOrLongWrongResultType(res
, name
);
13916 else if (!PyErr_Occurred()) {
13917 PyErr_SetString(PyExc_TypeError
,
13918 "an integer is required");
13922 static CYTHON_INLINE Py_ssize_t
__Pyx_PyIndex_AsSsize_t(PyObject
* b
) {
13925 #if PY_MAJOR_VERSION < 3
13926 if (likely(PyInt_CheckExact(b
))) {
13927 if (sizeof(Py_ssize_t
) >= sizeof(long))
13928 return PyInt_AS_LONG(b
);
13930 return PyInt_AsSsize_t(b
);
13933 if (likely(PyLong_CheckExact(b
))) {
13934 #if CYTHON_USE_PYLONG_INTERNALS
13935 const digit
* digits
= ((PyLongObject
*)b
)->ob_digit
;
13936 const Py_ssize_t size
= Py_SIZE(b
);
13937 if (likely(__Pyx_sst_abs(size
) <= 1)) {
13938 ival
= likely(size
) ? digits
[0] : 0;
13939 if (size
== -1) ival
= -ival
;
13944 if (8 * sizeof(Py_ssize_t
) > 2 * PyLong_SHIFT
) {
13945 return (Py_ssize_t
) (((((size_t)digits
[1]) << PyLong_SHIFT
) | (size_t)digits
[0]));
13949 if (8 * sizeof(Py_ssize_t
) > 2 * PyLong_SHIFT
) {
13950 return -(Py_ssize_t
) (((((size_t)digits
[1]) << PyLong_SHIFT
) | (size_t)digits
[0]));
13954 if (8 * sizeof(Py_ssize_t
) > 3 * PyLong_SHIFT
) {
13955 return (Py_ssize_t
) (((((((size_t)digits
[2]) << PyLong_SHIFT
) | (size_t)digits
[1]) << PyLong_SHIFT
) | (size_t)digits
[0]));
13959 if (8 * sizeof(Py_ssize_t
) > 3 * PyLong_SHIFT
) {
13960 return -(Py_ssize_t
) (((((((size_t)digits
[2]) << PyLong_SHIFT
) | (size_t)digits
[1]) << PyLong_SHIFT
) | (size_t)digits
[0]));
13964 if (8 * sizeof(Py_ssize_t
) > 4 * PyLong_SHIFT
) {
13965 return (Py_ssize_t
) (((((((((size_t)digits
[3]) << PyLong_SHIFT
) | (size_t)digits
[2]) << PyLong_SHIFT
) | (size_t)digits
[1]) << PyLong_SHIFT
) | (size_t)digits
[0]));
13969 if (8 * sizeof(Py_ssize_t
) > 4 * PyLong_SHIFT
) {
13970 return -(Py_ssize_t
) (((((((((size_t)digits
[3]) << PyLong_SHIFT
) | (size_t)digits
[2]) << PyLong_SHIFT
) | (size_t)digits
[1]) << PyLong_SHIFT
) | (size_t)digits
[0]));
13976 return PyLong_AsSsize_t(b
);
13978 x
= PyNumber_Index(b
);
13980 ival
= PyInt_AsSsize_t(x
);
13984 static CYTHON_INLINE PyObject
* __Pyx_PyBool_FromLong(long b
) {
13985 return b
? __Pyx_NewRef(Py_True
) : __Pyx_NewRef(Py_False
);
13987 static CYTHON_INLINE PyObject
* __Pyx_PyInt_FromSize_t(size_t ival
) {
13988 return PyInt_FromSize_t(ival
);
13992 #endif /* Py_PYTHON_H */