1 /* Generated by Cython 0.29.14 */
2 
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
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+.
9 #else
10 #define CYTHON_ABI "0_29_14"
11 #define CYTHON_HEX_VERSION 0x001D0EF0
12 #define CYTHON_FUTURE_DIVISION 1
13 #include <stddef.h>
14 #ifndef offsetof
15   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
16 #endif
17 #if !defined(WIN32) && !defined(MS_WINDOWS)
18   #ifndef __stdcall
19     #define __stdcall
20   #endif
21   #ifndef __cdecl
22     #define __cdecl
23   #endif
24   #ifndef __fastcall
25     #define __fastcall
26   #endif
27 #endif
28 #ifndef DL_IMPORT
29   #define DL_IMPORT(t) t
30 #endif
31 #ifndef DL_EXPORT
32   #define DL_EXPORT(t) t
33 #endif
34 #define __PYX_COMMA ,
35 #ifndef HAVE_LONG_LONG
36   #if PY_VERSION_HEX >= 0x02070000
37     #define HAVE_LONG_LONG
38   #endif
39 #endif
40 #ifndef PY_LONG_LONG
41   #define PY_LONG_LONG LONG_LONG
42 #endif
43 #ifndef Py_HUGE_VAL
44   #define Py_HUGE_VAL HUGE_VAL
45 #endif
46 #ifdef PYPY_VERSION
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
59   #endif
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
92   #endif
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
101   #endif
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
108   #endif
109   #ifndef CYTHON_ASSUME_SAFE_MACROS
110     #define CYTHON_ASSUME_SAFE_MACROS 1
111   #endif
112   #ifndef CYTHON_UNPACK_METHODS
113     #define CYTHON_UNPACK_METHODS 1
114   #endif
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
127 #else
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
133   #endif
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
139   #endif
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
145   #endif
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
151   #endif
152   #ifndef CYTHON_USE_PYLIST_INTERNALS
153     #define CYTHON_USE_PYLIST_INTERNALS 1
154   #endif
155   #ifndef CYTHON_USE_UNICODE_INTERNALS
156     #define CYTHON_USE_UNICODE_INTERNALS 1
157   #endif
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
163   #endif
164   #ifndef CYTHON_AVOID_BORROWED_REFS
165     #define CYTHON_AVOID_BORROWED_REFS 0
166   #endif
167   #ifndef CYTHON_ASSUME_SAFE_MACROS
168     #define CYTHON_ASSUME_SAFE_MACROS 1
169   #endif
170   #ifndef CYTHON_UNPACK_METHODS
171     #define CYTHON_UNPACK_METHODS 1
172   #endif
173   #ifndef CYTHON_FAST_THREAD_STATE
174     #define CYTHON_FAST_THREAD_STATE 1
175   #endif
176   #ifndef CYTHON_FAST_PYCALL
177     #define CYTHON_FAST_PYCALL 1
178   #endif
179   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
180     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
181   #endif
182   #ifndef CYTHON_USE_TP_FINALIZE
183     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
184   #endif
185   #ifndef CYTHON_USE_DICT_VERSIONS
186     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
187   #endif
188   #ifndef CYTHON_USE_EXC_INFO_STACK
189     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
190   #endif
191 #endif
192 #if !defined(CYTHON_FAST_PYCCALL)
193 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
194 #endif
195 #if CYTHON_USE_PYLONG_INTERNALS
196   #include "longintrepr.h"
197   #undef SHIFT
198   #undef BASE
199   #undef MASK
200   #ifdef SIZEOF_VOID_P
201     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
202   #endif
203 #endif
204 #ifndef __has_attribute
205   #define __has_attribute(x) 0
206 #endif
207 #ifndef __has_cpp_attribute
208   #define __has_cpp_attribute(x) 0
209 #endif
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
217   #else
218     #define CYTHON_RESTRICT
219   #endif
220 #endif
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__))
225 #   else
226 #     define CYTHON_UNUSED
227 #   endif
228 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
229 #   define CYTHON_UNUSED __attribute__ ((__unused__))
230 # else
231 #   define CYTHON_UNUSED
232 # endif
233 #endif
234 #ifndef CYTHON_MAYBE_UNUSED_VAR
235 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)236      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
237 #  else
238 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
239 #  endif
240 #endif
241 #ifndef CYTHON_NCP_UNUSED
242 # if CYTHON_COMPILING_IN_CPYTHON
243 #  define CYTHON_NCP_UNUSED
244 # else
245 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
246 # endif
247 #endif
248 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
249 #ifdef _MSC_VER
250     #ifndef _MSC_STDINT_H_
251         #if _MSC_VER < 1300
252            typedef unsigned char     uint8_t;
253            typedef unsigned int      uint32_t;
254         #else
255            typedef unsigned __int8   uint8_t;
256            typedef unsigned __int32  uint32_t;
257         #endif
258     #endif
259 #else
260    #include <stdint.h>
261 #endif
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]]
270     #endif
271   #endif
272   #ifndef CYTHON_FALLTHROUGH
273     #if __has_attribute(fallthrough)
274       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
275     #else
276       #define CYTHON_FALLTHROUGH
277     #endif
278   #endif
279   #if defined(__clang__ ) && defined(__apple_build_version__)
280     #if __apple_build_version__ < 7000000
281       #undef  CYTHON_FALLTHROUGH
282       #define CYTHON_FALLTHROUGH
283     #endif
284   #endif
285 #endif
286 
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
296   #else
297     #define CYTHON_INLINE
298   #endif
299 #endif
300 
301 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
302   #define Py_OptimizeFlag 0
303 #endif
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
311 #else
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)
316 #else
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)
319 #endif
320   #define __Pyx_DefaultClassType PyType_Type
321 #endif
322 #ifndef Py_TPFLAGS_CHECKTYPES
323   #define Py_TPFLAGS_CHECKTYPES 0
324 #endif
325 #ifndef Py_TPFLAGS_HAVE_INDEX
326   #define Py_TPFLAGS_HAVE_INDEX 0
327 #endif
328 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
329   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
330 #endif
331 #ifndef Py_TPFLAGS_HAVE_FINALIZE
332   #define Py_TPFLAGS_HAVE_FINALIZE 0
333 #endif
334 #ifndef METH_STACKLESS
335   #define METH_STACKLESS 0
336 #endif
337 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
338   #ifndef METH_FASTCALL
339      #define METH_FASTCALL 0x80
340   #endif
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);
344 #else
345   #define __Pyx_PyCFunctionFast _PyCFunctionFast
346   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
347 #endif
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)))))
351 #else
352 #define __Pyx_PyFastCFunction_Check(func) 0
353 #endif
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)
358 #endif
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)
363 #endif
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)
367 #else
368   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
369   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
370 #endif
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()
377 #else
378   #define __Pyx_PyThreadState_Current _PyThreadState_Current
379 #endif
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;
PyThread_tss_create(Py_tss_t * key)384 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
385   *key = PyThread_create_key();
386   return 0;
387 }
PyThread_tss_alloc(void)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;
391   return key;
392 }
PyThread_tss_free(Py_tss_t * key)393 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
394   PyObject_Free(key);
395 }
PyThread_tss_is_created(Py_tss_t * key)396 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
397   return *key != Py_tss_NEEDS_INIT;
398 }
PyThread_tss_delete(Py_tss_t * key)399 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
400   PyThread_delete_key(*key);
401   *key = Py_tss_NEEDS_INIT;
402 }
PyThread_tss_set(Py_tss_t * key,void * value)403 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
404   return PyThread_set_key_value(*key, value);
405 }
PyThread_tss_get(Py_tss_t * key)406 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
407   return PyThread_get_key_value(*key);
408 }
409 #endif
410 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
411 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
412 #else
413 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
414 #endif
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)
418 #else
419   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
420   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
421 #endif
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)
424 #else
425 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
426 #endif
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)))
439 #else
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))
453 #endif
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)
457 #else
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))
461 #endif
462 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
463   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
464 #endif
465 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
466   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
467 #endif
468 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
469   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
470 #endif
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)
475 #else
476   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
477 #endif
478 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
479   #define PyObject_ASCII(o)            PyObject_Repr(o)
480 #endif
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
488 #endif
489 #if PY_MAJOR_VERSION >= 3
490   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
491   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
492 #else
493   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
494   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
495 #endif
496 #ifndef PySet_CheckExact
497   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
498 #endif
499 #if CYTHON_ASSUME_SAFE_MACROS
500   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
501 #else
502   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
503 #endif
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
520 #endif
521 #if PY_MAJOR_VERSION >= 3
522   #define PyBoolObject                 PyLongObject
523 #endif
524 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
525   #ifndef PyUnicode_InternFromString
526     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
527   #endif
528 #endif
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
533 #else
534   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
535   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
536 #endif
537 #if PY_MAJOR_VERSION >= 3
538   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
539 #else
540   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
541 #endif
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)
546   #else
547     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
548   #endif
549 #else
550   #define __Pyx_PyType_AsAsync(obj) NULL
551 #endif
552 #ifndef __Pyx_PyAsyncMethodsStruct
553     typedef struct {
554         unaryfunc am_await;
555         unaryfunc am_aiter;
556         unaryfunc am_anext;
557     } __Pyx_PyAsyncMethodsStruct;
558 #endif
559 
560 #if defined(WIN32) || defined(MS_WINDOWS)
561   #define _USE_MATH_DEFINES
562 #endif
563 #include <math.h>
564 #ifdef NAN
565 #define __PYX_NAN() ((float) NAN)
566 #else
__PYX_NAN()567 static CYTHON_INLINE float __PYX_NAN() {
568   float value;
569   memset(&value, 0xFF, sizeof(value));
570   return value;
571 }
572 #endif
573 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
574 #define __Pyx_truncl trunc
575 #else
576 #define __Pyx_truncl truncl
577 #endif
578 
579 
580 #define __PYX_ERR(f_index, lineno, Ln_error) \
581 { \
582   __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
583 }
584 
585 #ifndef __PYX_EXTERN_C
586   #ifdef __cplusplus
587     #define __PYX_EXTERN_C extern "C"
588   #else
589     #define __PYX_EXTERN_C extern
590   #endif
591 #endif
592 
593 #define __PYX_HAVE__MACS2__Signal
594 #define __PYX_HAVE_API__MACS2__Signal
595 /* Early includes */
596 #include <string.h>
597 #include <stdio.h>
598 #include "numpy/arrayobject.h"
599 #include "numpy/ufuncobject.h"
600 #include "pythread.h"
601 #ifdef _OPENMP
602 #include <omp.h>
603 #endif /* _OPENMP */
604 
605 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
606 #define CYTHON_WITHOUT_ASSERTIONS
607 #endif
608 
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;
611 
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)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)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;
632 }
633 #if defined (__cplusplus) && __cplusplus >= 201103L
634     #include <cstdlib>
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)
646 #else
647     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
648 #endif
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
659 #else
660     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
661     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
662 #endif
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)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)679 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
680     const Py_UNICODE *u_end = u;
681     while (*u_end++) ;
682     return (size_t)(u_end - u - 1);
683 }
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))
699 #else
700 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
701 #endif
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))
705 #else
706 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
707 #endif
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;
__Pyx_init_sys_getdefaultencoding_params(void)711 static int __Pyx_init_sys_getdefaultencoding_params(void) {
712     PyObject* sys;
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");
718     if (!sys) goto bad;
719     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
720     Py_DECREF(sys);
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;
726     } else {
727         char ascii_chars[128];
728         int c;
729         for (c = 0; c < 128; c++) {
730             ascii_chars[c] = c;
731         }
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) {
737             PyErr_Format(
738                 PyExc_ValueError,
739                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
740                 default_encoding_c);
741             goto bad;
742         }
743         Py_DECREF(ascii_chars_u);
744         Py_DECREF(ascii_chars_b);
745     }
746     Py_DECREF(default_encoding);
747     return 0;
748 bad:
749     Py_XDECREF(default_encoding);
750     Py_XDECREF(ascii_chars_u);
751     Py_XDECREF(ascii_chars_b);
752     return -1;
753 }
754 #endif
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)
757 #else
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;
__Pyx_init_sys_getdefaultencoding_params(void)761 static int __Pyx_init_sys_getdefaultencoding_params(void) {
762     PyObject* sys;
763     PyObject* default_encoding = NULL;
764     char* default_encoding_c;
765     sys = PyImport_ImportModule("sys");
766     if (!sys) goto bad;
767     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
768     Py_DECREF(sys);
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);
776     return 0;
777 bad:
778     Py_XDECREF(default_encoding);
779     return -1;
780 }
781 #endif
782 #endif
783 
784 
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__ */
__Pyx_pretend_to_initialize(void * ptr)793 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
794 
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;
806 
807 /* Header.proto */
808 #if !defined(CYTHON_CCOMPLEX)
809   #if defined(__cplusplus)
810     #define CYTHON_CCOMPLEX 1
811   #elif defined(_Complex_I)
812     #define CYTHON_CCOMPLEX 1
813   #else
814     #define CYTHON_CCOMPLEX 0
815   #endif
816 #endif
817 #if CYTHON_CCOMPLEX
818   #ifdef __cplusplus
819     #include <complex>
820   #else
821     #include <complex.h>
822   #endif
823 #endif
824 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
825   #undef _Complex_I
826   #define _Complex_I 1.0fj
827 #endif
828 
829 
830 static const char *__pyx_f[] = {
831   "MACS2/Signal.pyx",
832   "__init__.pxd",
833   "type.pxd",
834   "bool.pxd",
835   "complex.pxd",
836 };
837 /* BufferFormatStructs.proto */
838 #define IS_UNSIGNED(type) (((type) -1) > 0)
839 struct __Pyx_StructField_;
840 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
841 typedef struct {
842   const char* name;
843   struct __Pyx_StructField_* fields;
844   size_t size;
845   size_t arraysize[8];
846   int ndim;
847   char typegroup;
848   char is_unsigned;
849   int flags;
850 } __Pyx_TypeInfo;
851 typedef struct __Pyx_StructField_ {
852   __Pyx_TypeInfo* type;
853   const char* name;
854   size_t offset;
855 } __Pyx_StructField;
856 typedef struct {
857   __Pyx_StructField* field;
858   size_t parent_offset;
859 } __Pyx_BufFmt_StackElem;
860 typedef struct {
861   __Pyx_StructField root;
862   __Pyx_BufFmt_StackElem* head;
863   size_t fmt_offset;
864   size_t new_count, enc_count;
865   size_t struct_alignment;
866   int is_complex;
867   char enc_type;
868   char new_packmode;
869   char enc_packmode;
870   char is_valid_array;
871 } __Pyx_BufFmt_Context;
872 
873 
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.
876  *
877  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
878  * ctypedef npy_int16      int16_t
879  * ctypedef npy_int32      int32_t
880  */
881 typedef npy_int8 __pyx_t_5numpy_int8_t;
882 
883 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":777
884  *
885  * ctypedef npy_int8       int8_t
886  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
887  * ctypedef npy_int32      int32_t
888  * ctypedef npy_int64      int64_t
889  */
890 typedef npy_int16 __pyx_t_5numpy_int16_t;
891 
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
898  */
899 typedef npy_int32 __pyx_t_5numpy_int32_t;
900 
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
907  */
908 typedef npy_int64 __pyx_t_5numpy_int64_t;
909 
910 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":783
911  * #ctypedef npy_int128     int128_t
912  *
913  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
914  * ctypedef npy_uint16     uint16_t
915  * ctypedef npy_uint32     uint32_t
916  */
917 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
918 
919 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":784
920  *
921  * ctypedef npy_uint8      uint8_t
922  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
923  * ctypedef npy_uint32     uint32_t
924  * ctypedef npy_uint64     uint64_t
925  */
926 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
927 
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
934  */
935 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
936 
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
943  */
944 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
945 
946 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":790
947  * #ctypedef npy_uint128    uint128_t
948  *
949  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
950  * ctypedef npy_float64    float64_t
951  * #ctypedef npy_float80    float80_t
952  */
953 typedef npy_float32 __pyx_t_5numpy_float32_t;
954 
955 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":791
956  *
957  * ctypedef npy_float32    float32_t
958  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
959  * #ctypedef npy_float80    float80_t
960  * #ctypedef npy_float128   float128_t
961  */
962 typedef npy_float64 __pyx_t_5numpy_float64_t;
963 
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
970  */
971 typedef npy_long __pyx_t_5numpy_int_t;
972 
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
978  *
979  */
980 typedef npy_longlong __pyx_t_5numpy_long_t;
981 
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             # <<<<<<<<<<<<<<
986  *
987  * ctypedef npy_ulong      uint_t
988  */
989 typedef npy_longlong __pyx_t_5numpy_longlong_t;
990 
991 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":804
992  * ctypedef npy_longlong   longlong_t
993  *
994  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
995  * ctypedef npy_ulonglong  ulong_t
996  * ctypedef npy_ulonglong  ulonglong_t
997  */
998 typedef npy_ulong __pyx_t_5numpy_uint_t;
999 
1000 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":805
1001  *
1002  * ctypedef npy_ulong      uint_t
1003  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1004  * ctypedef npy_ulonglong  ulonglong_t
1005  *
1006  */
1007 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1008 
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             # <<<<<<<<<<<<<<
1013  *
1014  * ctypedef npy_intp       intp_t
1015  */
1016 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1017 
1018 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":808
1019  * ctypedef npy_ulonglong  ulonglong_t
1020  *
1021  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1022  * ctypedef npy_uintp      uintp_t
1023  *
1024  */
1025 typedef npy_intp __pyx_t_5numpy_intp_t;
1026 
1027 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":809
1028  *
1029  * ctypedef npy_intp       intp_t
1030  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1031  *
1032  * ctypedef npy_double     float_t
1033  */
1034 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1035 
1036 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":811
1037  * ctypedef npy_uintp      uintp_t
1038  *
1039  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1040  * ctypedef npy_double     double_t
1041  * ctypedef npy_longdouble longdouble_t
1042  */
1043 typedef npy_double __pyx_t_5numpy_float_t;
1044 
1045 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":812
1046  *
1047  * ctypedef npy_double     float_t
1048  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1049  * ctypedef npy_longdouble longdouble_t
1050  *
1051  */
1052 typedef npy_double __pyx_t_5numpy_double_t;
1053 
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             # <<<<<<<<<<<<<<
1058  *
1059  * ctypedef npy_cfloat      cfloat_t
1060  */
1061 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1062 /* Declarations.proto */
1063 #if CYTHON_CCOMPLEX
1064   #ifdef __cplusplus
1065     typedef ::std::complex< float > __pyx_t_float_complex;
1066   #else
1067     typedef float _Complex __pyx_t_float_complex;
1068   #endif
1069 #else
1070     typedef struct { float real, imag; } __pyx_t_float_complex;
1071 #endif
1072 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1073 
1074 /* Declarations.proto */
1075 #if CYTHON_CCOMPLEX
1076   #ifdef __cplusplus
1077     typedef ::std::complex< double > __pyx_t_double_complex;
1078   #else
1079     typedef double _Complex __pyx_t_double_complex;
1080   #endif
1081 #else
1082     typedef struct { double real, imag; } __pyx_t_double_complex;
1083 #endif
1084 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1085 
1086 
1087 /*--- Type declarations ---*/
1088 
1089 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":815
1090  * ctypedef npy_longdouble longdouble_t
1091  *
1092  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1093  * ctypedef npy_cdouble     cdouble_t
1094  * ctypedef npy_clongdouble clongdouble_t
1095  */
1096 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1097 
1098 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":816
1099  *
1100  * ctypedef npy_cfloat      cfloat_t
1101  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1102  * ctypedef npy_clongdouble clongdouble_t
1103  *
1104  */
1105 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1106 
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             # <<<<<<<<<<<<<<
1111  *
1112  * ctypedef npy_cdouble     complex_t
1113  */
1114 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1115 
1116 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":819
1117  * ctypedef npy_clongdouble clongdouble_t
1118  *
1119  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1120  *
1121  * cdef inline object PyArray_MultiIterNew1(a):
1122  */
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;
1127 
1128 /* "MACS2/Signal.pyx":20
1129  * from math import factorial as mathfactorial
1130  *
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
1134  */
1135 struct __pyx_opt_args_5MACS2_6Signal_maxima {
1136   int __pyx_n;
1137   int window_size;
1138 };
1139 
1140 /* "MACS2/Signal.pyx":171
1141  * #        return n
1142  *
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):
1146  */
1147 struct __pyx_opt_args_5MACS2_6Signal_enforce_valleys {
1148   int __pyx_n;
1149   float min_valley;
1150 };
1151 
1152 /* "MACS2/Signal.pyx":267
1153  *
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.
1158  */
1159 struct __pyx_opt_args_5MACS2_6Signal_savitzky_golay {
1160   int __pyx_n;
1161   int deriv;
1162   int rate;
1163 };
1164 
1165 /* --- Runtime support code (head) --- */
1166 /* Refnanny.proto */
1167 #ifndef CYTHON_REFNANNY
1168   #define CYTHON_REFNANNY 0
1169 #endif
1170 #if CYTHON_REFNANNY
1171   typedef struct {
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;
1182 #ifdef WITH_THREAD
1183   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1184           if (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);\
1188           } else {\
1189               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1190           }
1191 #else
1192   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1193           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1194 #endif
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)
1205 #else
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)
1217 #endif
1218 #define __Pyx_XDECREF_SET(r, v) do {\
1219         PyObject *tmp = (PyObject *) r;\
1220         r = v; __Pyx_XDECREF(tmp);\
1221     } while (0)
1222 #define __Pyx_DECREF_SET(r, v) do {\
1223         PyObject *tmp = (PyObject *) r;\
1224         r = v; __Pyx_DECREF(tmp);\
1225     } while (0)
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)
1228 
1229 /* PyObjectGetAttrStr.proto */
1230 #if CYTHON_USE_TYPE_SLOTS
1231 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1232 #else
1233 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1234 #endif
1235 
1236 /* GetBuiltinName.proto */
1237 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1238 
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
1244 #else
1245 #define __Pyx_PyThreadState_declare
1246 #define __Pyx_PyThreadState_assign
1247 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1248 #endif
1249 
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))
1261 #else
1262 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1263 #endif
1264 #else
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)
1273 #endif
1274 
1275 /* Profile.proto */
1276 #ifndef CYTHON_PROFILE
1277 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
1278   #define CYTHON_PROFILE 0
1279 #else
1280   #define CYTHON_PROFILE 1
1281 #endif
1282 #endif
1283 #ifndef CYTHON_TRACE_NOGIL
1284   #define CYTHON_TRACE_NOGIL 0
1285 #else
1286   #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
1287     #define CYTHON_TRACE 1
1288   #endif
1289 #endif
1290 #ifndef CYTHON_TRACE
1291   #define CYTHON_TRACE 0
1292 #endif
1293 #if CYTHON_TRACE
1294   #undef CYTHON_PROFILE_REUSE_FRAME
1295 #endif
1296 #ifndef CYTHON_PROFILE_REUSE_FRAME
1297   #define CYTHON_PROFILE_REUSE_FRAME 0
1298 #endif
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)
1306   #else
1307     #define CYTHON_FRAME_MODIFIER
1308     #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
1309   #endif
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;
1316   #ifdef WITH_THREAD
1317   #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
1318   if (nogil) {\
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);\
1326           }\
1327           PyGILState_Release(state);\
1328           if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
1329       }\
1330   } else {\
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;\
1336       }\
1337   }
1338   #else
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;\
1345       }\
1346   }
1347   #endif
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))) {\
1353           tstate->tracing++;\
1354           tstate->use_tracing = 0;\
1355           PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
1356           if (exc_info) {\
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);\
1363           }\
1364           tstate->use_tracing = 1;\
1365           tstate->tracing--;\
1366       }\
1367   }
__Pyx_call_return_trace_func(PyThreadState * tstate,PyFrameObject * frame,PyObject * result)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);
1371       tstate->tracing++;
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;
1379       tstate->tracing--;
1380       __Pyx_ErrRestoreInState(tstate, type, value, traceback);
1381   }
1382   #ifdef WITH_THREAD
1383   #define __Pyx_TraceReturn(result, nogil)\
1384   if (likely(!__Pyx_use_tracing)); else {\
1385       if (nogil) {\
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);\
1392               }\
1393               PyGILState_Release(state);\
1394           }\
1395       } else {\
1396           PyThreadState* tstate = __Pyx_PyThreadState_Current;\
1397           if (tstate->use_tracing) {\
1398               __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
1399           }\
1400       }\
1401   }
1402   #else
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);\
1408       }\
1409   }
1410   #endif
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);
1413 #else
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)
1419 #endif
1420 #if CYTHON_TRACE
__Pyx_call_line_trace_func(PyThreadState * tstate,PyFrameObject * frame,int lineno)1421   static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) {
1422       int ret;
1423       PyObject *type, *value, *traceback;
1424       __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
1425       __Pyx_PyFrame_SetLineNumber(frame, lineno);
1426       tstate->tracing++;
1427       tstate->use_tracing = 0;
1428       ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL);
1429       tstate->use_tracing = 1;
1430       tstate->tracing--;
1431       if (likely(!ret)) {
1432           __Pyx_ErrRestoreInState(tstate, type, value, traceback);
1433       } else {
1434           Py_XDECREF(type);
1435           Py_XDECREF(value);
1436           Py_XDECREF(traceback);
1437       }
1438       return ret;
1439   }
1440   #ifdef WITH_THREAD
1441   #define __Pyx_TraceLine(lineno, nogil, goto_error)\
1442   if (likely(!__Pyx_use_tracing)); else {\
1443       if (nogil) {\
1444           if (CYTHON_TRACE_NOGIL) {\
1445               int ret = 0;\
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);\
1451               }\
1452               PyGILState_Release(state);\
1453               if (unlikely(ret)) goto_error;\
1454           }\
1455       } else {\
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;\
1460           }\
1461       }\
1462   }
1463   #else
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;\
1470       }\
1471   }
1472   #endif
1473 #else
1474   #define __Pyx_TraceLine(lineno, nogil, goto_error)   if ((1)); else goto_error;
1475 #endif
1476 
1477 /* IsLittleEndian.proto */
1478 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
1479 
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);
1485 
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 };
1497 
1498 /* None.proto */
1499 static CYTHON_INLINE long __Pyx_div_long(long, long);
1500 
1501 /* PyCFunctionFastCall.proto */
1502 #if CYTHON_FAST_PYCCALL
1503 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1504 #else
1505 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1506 #endif
1507 
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);
1514 #else
1515 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1516 #endif
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)
1521 #endif
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))
1529 #endif
1530 
1531 /* PyObjectCall.proto */
1532 #if CYTHON_COMPILING_IN_CPYTHON
1533 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1534 #else
1535 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1536 #endif
1537 
1538 /* PyObjectCall2Args.proto */
1539 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1540 
1541 /* PyObjectCallMethO.proto */
1542 #if CYTHON_COMPILING_IN_CPYTHON
1543 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1544 #endif
1545 
1546 /* PyObjectCallOneArg.proto */
1547 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1548 
1549 /* ExtTypeTest.proto */
1550 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1551 
1552 /* BufferFallbackError.proto */
1553 static void __Pyx_RaiseBufferFallbackError(void);
1554 
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;\
1567     } else {\
1568         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1569         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1570     }\
1571 }
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);
1575 #else
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);
1579 #endif
1580 
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);\
1589 }
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);\
1594 }
1595 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1596 #else
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);
1600 #endif
1601 
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);
1623 
1624 /* RaiseDoubleKeywords.proto */
1625 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1626 
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);
1631 
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);
1635 
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);
1641 
1642 /* BufferIndexError.proto */
1643 static void __Pyx_RaiseBufferIndexError(int axis);
1644 
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);
1649 #else
1650 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
1651 #endif
1652 
1653 /* PyObjectCallNoArg.proto */
1654 #if CYTHON_COMPILING_IN_CPYTHON
1655 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1656 #else
1657 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1658 #endif
1659 
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);
1664 
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);
1668 #else
1669 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1670     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1671 #endif
1672 
1673 /* None.proto */
1674 static CYTHON_INLINE long __Pyx_mod_long(long, long);
1675 
1676 /* ListCompAppend.proto */
1677 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_ListComp_Append(PyObject * list,PyObject * x)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)) {
1682         Py_INCREF(x);
1683         PyList_SET_ITEM(list, len, x);
1684         Py_SIZE(list) = len+1;
1685         return 0;
1686     }
1687     return PyList_Append(list, x);
1688 }
1689 #else
1690 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1691 #endif
1692 
1693 /* GetTopmostException.proto */
1694 #if CYTHON_USE_EXC_INFO_STACK
1695 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1696 #endif
1697 
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);
1704 #else
1705 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1706 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1707 #endif
1708 
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);
1713 #else
1714 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1715 #endif
1716 
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);
1721 #else
1722 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1723 #endif
1724 
1725 /* RaiseException.proto */
1726 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1727 
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))
1734 #else
1735 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1736 #define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
1737 #endif
1738 
1739 /* RaiseTooManyValuesToUnpack.proto */
1740 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1741 
1742 /* RaiseNeedMoreValuesToUnpack.proto */
1743 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1744 
1745 /* RaiseNoneIterError.proto */
1746 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1747 
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
1755 };
1756 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1757 #endif
1758 
1759 /* Import.proto */
1760 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1761 
1762 /* ImportFrom.proto */
1763 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1764 
1765 /* CLineInTraceback.proto */
1766 #ifdef CYTHON_CLINE_IN_TRACEBACK
1767 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1768 #else
1769 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1770 #endif
1771 
1772 /* CodeObjectCache.proto */
1773 typedef struct {
1774     PyCodeObject* code_object;
1775     int code_line;
1776 } __Pyx_CodeObjectCacheEntry;
1777 struct __Pyx_CodeObjectCache {
1778     int count;
1779     int max_count;
1780     __Pyx_CodeObjectCacheEntry* entries;
1781 };
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);
1786 
1787 /* AddTraceback.proto */
1788 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1789                                int py_line, const char *filename);
1790 
1791 /* BufferStructDeclare.proto */
1792 typedef struct {
1793   Py_ssize_t shape, strides, suboffsets;
1794 } __Pyx_Buf_DimInfo;
1795 typedef struct {
1796   size_t refcount;
1797   Py_buffer pybuffer;
1798 } __Pyx_Buffer;
1799 typedef struct {
1800   __Pyx_Buffer *rcbuffer;
1801   char *data;
1802   __Pyx_Buf_DimInfo diminfo[8];
1803 } __Pyx_LocalBuf_ND;
1804 
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);
1808 #else
1809     #define __Pyx_GetBuffer PyObject_GetBuffer
1810     #define __Pyx_ReleaseBuffer PyBuffer_Release
1811 #endif
1812 
1813 
1814 /* CIntToPy.proto */
1815 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1816 
1817 /* CIntToPy.proto */
1818 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int32(npy_int32 value);
1819 
1820 /* CIntToPy.proto */
1821 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1822 
1823 /* None.proto */
1824 static CYTHON_INLINE long __Pyx_pow_long(long, long);
1825 
1826 /* None.proto */
1827 static CYTHON_INLINE int __Pyx_pow_int(int, int);
1828 
1829 /* RealImag.proto */
1830 #if CYTHON_CCOMPLEX
1831   #ifdef __cplusplus
1832     #define __Pyx_CREAL(z) ((z).real())
1833     #define __Pyx_CIMAG(z) ((z).imag())
1834   #else
1835     #define __Pyx_CREAL(z) (__real__(z))
1836     #define __Pyx_CIMAG(z) (__imag__(z))
1837   #endif
1838 #else
1839     #define __Pyx_CREAL(z) ((z).real)
1840     #define __Pyx_CIMAG(z) ((z).imag)
1841 #endif
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))
1846 #else
1847     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
1848     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
1849 #endif
1850 
1851 /* Arithmetic.proto */
1852 #if CYTHON_CCOMPLEX
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))
1859   #ifdef __cplusplus
1860     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
1861     #define __Pyx_c_conj_float(z)    (::std::conj(z))
1862     #if 1
1863         #define __Pyx_c_abs_float(z)     (::std::abs(z))
1864         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
1865     #endif
1866   #else
1867     #define __Pyx_c_is_zero_float(z) ((z)==0)
1868     #define __Pyx_c_conj_float(z)    (conjf(z))
1869     #if 1
1870         #define __Pyx_c_abs_float(z)     (cabsf(z))
1871         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
1872     #endif
1873  #endif
1874 #else
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);
1883     #if 1
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);
1886     #endif
1887 #endif
1888 
1889 /* Arithmetic.proto */
1890 #if CYTHON_CCOMPLEX
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))
1897   #ifdef __cplusplus
1898     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
1899     #define __Pyx_c_conj_double(z)    (::std::conj(z))
1900     #if 1
1901         #define __Pyx_c_abs_double(z)     (::std::abs(z))
1902         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
1903     #endif
1904   #else
1905     #define __Pyx_c_is_zero_double(z) ((z)==0)
1906     #define __Pyx_c_conj_double(z)    (conj(z))
1907     #if 1
1908         #define __Pyx_c_abs_double(z)     (cabs(z))
1909         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
1910     #endif
1911  #endif
1912 #else
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);
1921     #if 1
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);
1924     #endif
1925 #endif
1926 
1927 /* CIntToPy.proto */
1928 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);
1929 
1930 /* CIntFromPy.proto */
1931 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1932 
1933 /* CIntFromPy.proto */
1934 static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *);
1935 
1936 /* CIntFromPy.proto */
1937 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1938 
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);
1945 #else
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))
1949 #endif
1950 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1951 
1952 /* CheckBinaryVersion.proto */
1953 static int __Pyx_check_binary_version(void);
1954 
1955 /* InitStrings.proto */
1956 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1957 
1958 
1959 /* Module declarations from 'cpython.buffer' */
1960 
1961 /* Module declarations from 'libc.string' */
1962 
1963 /* Module declarations from 'libc.stdio' */
1964 
1965 /* Module declarations from '__builtin__' */
1966 
1967 /* Module declarations from 'cpython.type' */
1968 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1969 
1970 /* Module declarations from 'cpython.version' */
1971 
1972 /* Module declarations from 'cpython.exc' */
1973 
1974 /* Module declarations from 'cpython.module' */
1975 
1976 /* Module declarations from 'cpython.mem' */
1977 
1978 /* Module declarations from 'cpython.tuple' */
1979 
1980 /* Module declarations from 'cpython.list' */
1981 
1982 /* Module declarations from 'cpython.sequence' */
1983 
1984 /* Module declarations from 'cpython.mapping' */
1985 
1986 /* Module declarations from 'cpython.iterator' */
1987 
1988 /* Module declarations from 'cpython.number' */
1989 
1990 /* Module declarations from 'cpython.int' */
1991 
1992 /* Module declarations from '__builtin__' */
1993 
1994 /* Module declarations from 'cpython.bool' */
1995 static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
1996 
1997 /* Module declarations from 'cpython.long' */
1998 
1999 /* Module declarations from 'cpython.float' */
2000 
2001 /* Module declarations from '__builtin__' */
2002 
2003 /* Module declarations from 'cpython.complex' */
2004 static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
2005 
2006 /* Module declarations from 'cpython.string' */
2007 
2008 /* Module declarations from 'cpython.unicode' */
2009 
2010 /* Module declarations from 'cpython.dict' */
2011 
2012 /* Module declarations from 'cpython.instance' */
2013 
2014 /* Module declarations from 'cpython.function' */
2015 
2016 /* Module declarations from 'cpython.method' */
2017 
2018 /* Module declarations from 'cpython.weakref' */
2019 
2020 /* Module declarations from 'cpython.getargs' */
2021 
2022 /* Module declarations from 'cpython.pythread' */
2023 
2024 /* Module declarations from 'cpython.pystate' */
2025 
2026 /* Module declarations from 'cpython.cobject' */
2027 
2028 /* Module declarations from 'cpython.oldbuffer' */
2029 
2030 /* Module declarations from 'cpython.set' */
2031 
2032 /* Module declarations from 'cpython.bytes' */
2033 
2034 /* Module declarations from 'cpython.pycapsule' */
2035 
2036 /* Module declarations from 'cpython' */
2037 
2038 /* Module declarations from 'cpython.object' */
2039 
2040 /* Module declarations from 'cpython.ref' */
2041 
2042 /* Module declarations from 'numpy' */
2043 
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*/
2051 
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;
2070 
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;
2230 /* Late includes */
2231 
2232 /* "MACS2/Signal.pyx":20
2233  * from math import factorial as mathfactorial
2234  *
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
2238  */
2239 
2240 static PyObject *__pyx_pw_5MACS2_6Signal_1maxima(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__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)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;
2264   int __pyx_t_5;
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;
2277     }
2278   }
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;
2299   {
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)
2302   }
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];
2304 
2305   /* "MACS2/Signal.pyx":30
2306  *         np.ndarray[np.float32_t, ndim=1] sign, diff
2307  *
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") )
2311  */
2312   __pyx_v_window_size = ((__Pyx_div_long(__pyx_v_window_size, 2) * 2) + 1);
2313 
2314   /* "MACS2/Signal.pyx":31
2315  *
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 )
2320  */
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;
2326   __pyx_t_2 = NULL;
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);
2334     }
2335   }
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);
2343   {
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();
2352       } else {
2353         PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
2354       }
2355       __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
2356     }
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)
2359   }
2360   __pyx_t_4 = 0;
2361   __pyx_v_smoothed = ((PyArrayObject *)__pyx_t_1);
2362   __pyx_t_1 = 0;
2363 
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')
2370  */
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);
2378   __pyx_t_10 = NULL;
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);
2386     }
2387   }
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;
2393   __pyx_t_9 = NULL;
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);
2401     }
2402   }
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);
2411   {
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();
2420       } else {
2421         PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
2422       }
2423       __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
2424     }
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)
2427   }
2428   __pyx_t_11 = 0;
2429   __pyx_v_sign = ((PyArrayObject *)__pyx_t_1);
2430   __pyx_t_1 = 0;
2431 
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')
2437  *     return m
2438  */
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;
2444   __pyx_t_2 = NULL;
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);
2452     }
2453   }
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);
2461   {
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();
2470       } else {
2471         PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
2472       }
2473       __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
2474     }
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)
2477   }
2478   __pyx_t_11 = 0;
2479   __pyx_v_diff = ((PyArrayObject *)__pyx_t_1);
2480   __pyx_t_1 = 0;
2481 
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')             # <<<<<<<<<<<<<<
2486  *     return m
2487  *
2488  */
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)
2495   __pyx_t_10 = NULL;
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);
2503     }
2504   }
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;
2517   __pyx_t_9 = NULL;
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);
2525     }
2526   }
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);
2534   {
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();
2543       } else {
2544         PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
2545       }
2546       __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
2547     }
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)
2550   }
2551   __pyx_t_12 = 0;
2552   __pyx_v_m = ((PyArrayObject *)__pyx_t_1);
2553   __pyx_t_1 = 0;
2554 
2555   /* "MACS2/Signal.pyx":35
2556  *     diff = np.diff( sign )
2557  *     m = np.where( diff <= -1)[0].astype('int32')
2558  *     return m             # <<<<<<<<<<<<<<
2559  *
2560  * cdef np.ndarray[np.int32_t, ndim=1] internal_minima( np.ndarray[np.float32_t, ndim=1] signal,
2561  */
2562   __Pyx_XDECREF(((PyObject *)__pyx_r));
2563   __Pyx_INCREF(((PyObject *)__pyx_v_m));
2564   __pyx_r = ((PyArrayObject *)__pyx_v_m);
2565   goto __pyx_L0;
2566 
2567   /* "MACS2/Signal.pyx":20
2568  * from math import factorial as mathfactorial
2569  *
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
2573  */
2574 
2575   /* function exit code */
2576   __pyx_L1_error:;
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);
2593   __pyx_r = 0;
2594   goto __pyx_L2;
2595   __pyx_L0:;
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);
2601   __pyx_L2:;
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();
2609   return __pyx_r;
2610 }
2611 
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    ";
__pyx_pw_5MACS2_6Signal_1maxima(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)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);
2621   {
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)) {
2625       Py_ssize_t kw_args;
2626       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2627       switch (pos_args) {
2628         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2629         CYTHON_FALLTHROUGH;
2630         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2631         CYTHON_FALLTHROUGH;
2632         case  0: break;
2633         default: goto __pyx_L5_argtuple_error;
2634       }
2635       kw_args = PyDict_Size(__pyx_kwds);
2636       switch (pos_args) {
2637         case  0:
2638         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signal)) != 0)) kw_args--;
2639         else goto __pyx_L5_argtuple_error;
2640         CYTHON_FALLTHROUGH;
2641         case  1:
2642         if (kw_args > 0) {
2643           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_window_size);
2644           if (value) { values[1] = value; kw_args--; }
2645         }
2646       }
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)
2649       }
2650     } else {
2651       switch (PyTuple_GET_SIZE(__pyx_args)) {
2652         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2653         CYTHON_FALLTHROUGH;
2654         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2655         break;
2656         default: goto __pyx_L5_argtuple_error;
2657       }
2658     }
2659     __pyx_v_signal = ((PyArrayObject *)values[0]);
2660     if (values[1]) {
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)
2662     } else {
2663       __pyx_v_window_size = ((int)51);
2664     }
2665   }
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)
2669   __pyx_L3_error:;
2670   __Pyx_AddTraceback("MACS2.Signal.maxima", __pyx_clineno, __pyx_lineno, __pyx_filename);
2671   __Pyx_RefNannyFinishContext();
2672   return NULL;
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);
2676 
2677   /* function exit code */
2678   goto __pyx_L0;
2679   __pyx_L1_error:;
2680   __pyx_r = NULL;
2681   __pyx_L0:;
2682   __Pyx_RefNannyFinishContext();
2683   return __pyx_r;
2684 }
2685 
__pyx_pf_5MACS2_6Signal_maxima(CYTHON_UNUSED PyObject * __pyx_self,PyArrayObject * __pyx_v_signal,int __pyx_v_window_size)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;
2700   {
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)
2703   }
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;
2711   __pyx_t_1 = 0;
2712   goto __pyx_L0;
2713 
2714   /* function exit code */
2715   __pyx_L1_error:;
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);
2724   __pyx_r = NULL;
2725   goto __pyx_L2;
2726   __pyx_L0:;
2727   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
2728   __pyx_L2:;
2729   __Pyx_XGIVEREF(__pyx_r);
2730   __Pyx_TraceReturn(__pyx_r, 0);
2731   __Pyx_RefNannyFinishContext();
2732   return __pyx_r;
2733 }
2734 
2735 /* "MACS2/Signal.pyx":37
2736  *     return m
2737  *
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 ):
2740  *     cdef:
2741  */
2742 
__pyx_f_5MACS2_6Signal_internal_minima(PyArrayObject * __pyx_v_signal,PyArrayObject * __pyx_v_maxima)2743 static PyArrayObject *__pyx_f_5MACS2_6Signal_internal_minima(PyArrayObject *__pyx_v_signal, PyArrayObject *__pyx_v_maxima) {
2744   PyArrayObject *__pyx_v_ret = 0;
2745   int __pyx_v_n;
2746   int __pyx_v_i;
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;
2759   int __pyx_t_2;
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;
2769   long __pyx_t_12;
2770   long __pyx_t_13;
2771   Py_ssize_t __pyx_t_14;
2772   int __pyx_t_15;
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;
2790   {
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)
2793   }
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];
2795   {
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)
2798   }
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];
2800 
2801   /* "MACS2/Signal.pyx":41
2802  *     cdef:
2803  *         np.ndarray[np.int32_t, ndim=1] ret
2804  *         int n = maxima.shape[0]             # <<<<<<<<<<<<<<
2805  *         int i, v, v2
2806  *     if n == 0 or n == 1:
2807  */
2808   __pyx_v_n = (__pyx_v_maxima->dimensions[0]);
2809 
2810   /* "MACS2/Signal.pyx":43
2811  *         int n = maxima.shape[0]
2812  *         int i, v, v2
2813  *     if n == 0 or n == 1:             # <<<<<<<<<<<<<<
2814  *         ret = np.ndarray(0, 'int32')
2815  *         return ret
2816  */
2817   switch (__pyx_v_n) {
2818     case 0:
2819     case 1:
2820 
2821     /* "MACS2/Signal.pyx":44
2822  *         int i, v, v2
2823  *     if n == 0 or n == 1:
2824  *         ret = np.ndarray(0, 'int32')             # <<<<<<<<<<<<<<
2825  *         return ret
2826  *     else:
2827  */
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);
2830     {
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();
2839         } else {
2840           PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5);
2841         }
2842         __pyx_t_3 = __pyx_t_4 = __pyx_t_5 = 0;
2843       }
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)
2846     }
2847     __pyx_v_ret = ((PyArrayObject *)__pyx_t_1);
2848     __pyx_t_1 = 0;
2849 
2850     /* "MACS2/Signal.pyx":45
2851  *     if n == 0 or n == 1:
2852  *         ret = np.ndarray(0, 'int32')
2853  *         return ret             # <<<<<<<<<<<<<<
2854  *     else:
2855  *         ret = np.zeros(n - 1, 'int32')
2856  */
2857     __Pyx_XDECREF(((PyObject *)__pyx_r));
2858     __Pyx_INCREF(((PyObject *)__pyx_v_ret));
2859     __pyx_r = ((PyArrayObject *)__pyx_v_ret);
2860     goto __pyx_L0;
2861 
2862     /* "MACS2/Signal.pyx":43
2863  *         int n = maxima.shape[0]
2864  *         int i, v, v2
2865  *     if n == 0 or n == 1:             # <<<<<<<<<<<<<<
2866  *         ret = np.ndarray(0, 'int32')
2867  *         return ret
2868  */
2869     break;
2870     default:
2871 
2872     /* "MACS2/Signal.pyx":47
2873  *         return ret
2874  *     else:
2875  *         ret = np.zeros(n - 1, 'int32')             # <<<<<<<<<<<<<<
2876  *         pos1 = maxima[0]
2877  *         for i in range(n - 1):
2878  */
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);
2886     __pyx_t_8 = NULL;
2887     __pyx_t_2 = 0;
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);
2895         __pyx_t_2 = 1;
2896       }
2897     }
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;
2905     } else
2906     #endif
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;
2914     } else
2915     #endif
2916     {
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);
2919       if (__pyx_t_8) {
2920         __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
2921       }
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);
2927       __pyx_t_6 = 0;
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;
2931     }
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);
2935     {
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();
2944         } else {
2945           PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_3);
2946         }
2947         __pyx_t_5 = __pyx_t_4 = __pyx_t_3 = 0;
2948       }
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)
2951     }
2952     __pyx_t_10 = 0;
2953     __pyx_v_ret = ((PyArrayObject *)__pyx_t_1);
2954     __pyx_t_1 = 0;
2955 
2956     /* "MACS2/Signal.pyx":48
2957  *     else:
2958  *         ret = np.zeros(n - 1, 'int32')
2959  *         pos1 = maxima[0]             # <<<<<<<<<<<<<<
2960  *         for i in range(n - 1):
2961  *             pos2 = maxima[i + 1]
2962  */
2963     __pyx_t_11 = 0;
2964     __pyx_t_2 = -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)
2972     }
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;
2976     __pyx_t_1 = 0;
2977 
2978     /* "MACS2/Signal.pyx":49
2979  *         ret = np.zeros(n - 1, 'int32')
2980  *         pos1 = maxima[0]
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
2984  */
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;
2989 
2990       /* "MACS2/Signal.pyx":50
2991  *         pos1 = maxima[0]
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
2995  *             pos1 = pos2
2996  */
2997       __pyx_t_14 = (__pyx_v_i + 1);
2998       __pyx_t_15 = -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)
3006       }
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);
3010       __pyx_t_1 = 0;
3011 
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             # <<<<<<<<<<<<<<
3016  *             pos1 = pos2
3017  *         return ret
3018  */
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;
3037       __pyx_t_16 = NULL;
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);
3045         }
3046       }
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;
3055       __pyx_t_7 = NULL;
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);
3063         }
3064       }
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;
3083       __pyx_t_15 = -1;
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)
3091       }
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;
3093 
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             # <<<<<<<<<<<<<<
3098  *         return ret
3099  *
3100  */
3101       __Pyx_INCREF(__pyx_v_pos2);
3102       __Pyx_DECREF_SET(__pyx_v_pos1, __pyx_v_pos2);
3103     }
3104 
3105     /* "MACS2/Signal.pyx":53
3106  *             ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
3107  *             pos1 = pos2
3108  *         return ret             # <<<<<<<<<<<<<<
3109  *
3110  * cdef inline float sqrt(float threshold):
3111  */
3112     __Pyx_XDECREF(((PyObject *)__pyx_r));
3113     __Pyx_INCREF(((PyObject *)__pyx_v_ret));
3114     __pyx_r = ((PyArrayObject *)__pyx_v_ret);
3115     goto __pyx_L0;
3116     break;
3117   }
3118 
3119   /* "MACS2/Signal.pyx":37
3120  *     return m
3121  *
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 ):
3124  *     cdef:
3125  */
3126 
3127   /* function exit code */
3128   __pyx_L1_error:;
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);
3144   __pyx_r = 0;
3145   goto __pyx_L2;
3146   __pyx_L0:;
3147   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
3148   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret.rcbuffer->pybuffer);
3149   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
3150   __pyx_L2:;
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();
3157   return __pyx_r;
3158 }
3159 
3160 /* "MACS2/Signal.pyx":55
3161  *         return ret
3162  *
3163  * cdef inline float sqrt(float threshold):             # <<<<<<<<<<<<<<
3164  *     return mathsqrt(threshold)
3165  *
3166  */
3167 
__pyx_f_5MACS2_6Signal_sqrt(float __pyx_v_threshold)3168 static CYTHON_INLINE float __pyx_f_5MACS2_6Signal_sqrt(float __pyx_v_threshold) {
3169   float __pyx_r;
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;
3176   float __pyx_t_5;
3177   __Pyx_RefNannySetupContext("sqrt", 0);
3178   __Pyx_TraceCall("sqrt", __pyx_f[0], 55, 0, __PYX_ERR(0, 55, __pyx_L1_error));
3179 
3180   /* "MACS2/Signal.pyx":56
3181  *
3182  * cdef inline float sqrt(float threshold):
3183  *     return mathsqrt(threshold)             # <<<<<<<<<<<<<<
3184  *
3185  * cpdef enforce_peakyness(np.ndarray[np.float32_t, ndim=1] signal,
3186  */
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);
3191   __pyx_t_4 = NULL;
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);
3199     }
3200   }
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;
3210   goto __pyx_L0;
3211 
3212   /* "MACS2/Signal.pyx":55
3213  *         return ret
3214  *
3215  * cdef inline float sqrt(float threshold):             # <<<<<<<<<<<<<<
3216  *     return mathsqrt(threshold)
3217  *
3218  */
3219 
3220   /* function exit code */
3221   __pyx_L1_error:;
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);
3227   __pyx_r = 0;
3228   __pyx_L0:;
3229   __Pyx_TraceReturn(Py_None, 0);
3230   __Pyx_RefNannyFinishContext();
3231   return __pyx_r;
3232 }
3233 
3234 /* "MACS2/Signal.pyx":58
3235  *     return mathsqrt(threshold)
3236  *
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
3240  */
3241 
3242 static PyObject *__pyx_pw_5MACS2_6Signal_3enforce_peakyness(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5MACS2_6Signal_enforce_peakyness(PyArrayObject * __pyx_v_signal,PyArrayObject * __pyx_v_maxima,CYTHON_UNUSED int __pyx_skip_dispatch)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;
3246   int __pyx_v_n;
3247   float __pyx_v_threshold;
3248   PyArrayObject *__pyx_v_peaky_maxima = 0;
3249   int __pyx_v_j;
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;
3269   int __pyx_t_5;
3270   Py_ssize_t __pyx_t_6;
3271   int __pyx_t_7;
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;
3285   float __pyx_t_21;
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;
3317   {
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)
3320   }
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];
3322   {
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)
3325   }
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];
3327 
3328   /* "MACS2/Signal.pyx":75
3329  *     """
3330  *     cdef:
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]
3334  */
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);
3337   {
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];
3343     }
3344   }
3345   __pyx_v_minima = ((PyArrayObject *)__pyx_t_1);
3346   __pyx_t_1 = 0;
3347 
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]             # <<<<<<<<<<<<<<
3352  *         float threshold
3353  *         np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
3354  */
3355   __pyx_v_n = (__pyx_v_minima->dimensions[0]);
3356 
3357   /* "MACS2/Signal.pyx":79
3358  *         int n = minima.shape[0]
3359  *         float threshold
3360  *         np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()             # <<<<<<<<<<<<<<
3361  *         int j = 0
3362  *     if n == 0: return maxima
3363  */
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);
3366   __pyx_t_3 = NULL;
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);
3374     }
3375   }
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);
3383   {
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];
3389     }
3390   }
3391   __pyx_t_4 = 0;
3392   __pyx_v_peaky_maxima = ((PyArrayObject *)__pyx_t_1);
3393   __pyx_t_1 = 0;
3394 
3395   /* "MACS2/Signal.pyx":80
3396  *         float threshold
3397  *         np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
3398  *         int j = 0             # <<<<<<<<<<<<<<
3399  *     if n == 0: return maxima
3400  * #    else:
3401  */
3402   __pyx_v_j = 0;
3403 
3404   /* "MACS2/Signal.pyx":81
3405  *         np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
3406  *         int j = 0
3407  *     if n == 0: return maxima             # <<<<<<<<<<<<<<
3408  * #    else:
3409  *     threshold = signal[minima[0]]
3410  */
3411   __pyx_t_5 = ((__pyx_v_n == 0) != 0);
3412   if (__pyx_t_5) {
3413     __Pyx_XDECREF(__pyx_r);
3414     __Pyx_INCREF(((PyObject *)__pyx_v_maxima));
3415     __pyx_r = ((PyObject *)__pyx_v_maxima);
3416     goto __pyx_L0;
3417   }
3418 
3419   /* "MACS2/Signal.pyx":83
3420  *     if n == 0: return maxima
3421  * #    else:
3422  *     threshold = signal[minima[0]]             # <<<<<<<<<<<<<<
3423  *     threshold += sqrt(threshold)
3424  *     new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
3425  */
3426   __pyx_t_6 = 0;
3427   __pyx_t_7 = -1;
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)
3435   }
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));
3437   __pyx_t_7 = -1;
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)
3445   }
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));
3447 
3448   /* "MACS2/Signal.pyx":84
3449  * #    else:
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] )
3454  */
3455   __pyx_v_threshold = (__pyx_v_threshold + __pyx_f_5MACS2_6Signal_sqrt(__pyx_v_threshold));
3456 
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]):
3463  */
3464   __pyx_t_9 = 0;
3465   __pyx_t_7 = -1;
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)
3473   }
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);
3496   {
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();
3505       } else {
3506         PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
3507       }
3508       __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
3509     }
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)
3512   }
3513   __pyx_t_10 = 0;
3514   __pyx_v_new_signal = ((PyArrayObject *)__pyx_t_1);
3515   __pyx_t_1 = 0;
3516 
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]
3522  *         j += 1
3523  */
3524   __pyx_t_14 = 0;
3525   __pyx_t_7 = -1;
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)
3533   }
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;
3538   if (__pyx_t_5) {
3539 
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]             # <<<<<<<<<<<<<<
3544  *         j += 1
3545  *     for i in range(n - 1):
3546  */
3547     __pyx_t_15 = 0;
3548     __pyx_t_7 = -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)
3556     }
3557     __pyx_t_16 = 0;
3558     __pyx_t_7 = -1;
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)
3566     }
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));
3568 
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]])
3575  */
3576     __pyx_v_j = (__pyx_v_j + 1);
3577 
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]
3583  *         j += 1
3584  */
3585   }
3586 
3587   /* "MACS2/Signal.pyx":90
3588  *         peaky_maxima[0] = maxima[0]
3589  *         j += 1
3590  *     for i in range(n - 1):             # <<<<<<<<<<<<<<
3591  *         threshold = max(signal[minima[i]], signal[minima[i + 1]])
3592  *         threshold += sqrt(threshold)
3593  */
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;
3601     __pyx_t_18 = NULL;
3602   } else {
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)
3606   }
3607   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3608   for (;;) {
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)
3614         #else
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);
3617         #endif
3618       } else {
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)
3622         #else
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);
3625         #endif
3626       }
3627     } else {
3628       __pyx_t_2 = __pyx_t_18(__pyx_t_1);
3629       if (unlikely(!__pyx_t_2)) {
3630         PyObject* exc_type = PyErr_Occurred();
3631         if (exc_type) {
3632           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3633           else __PYX_ERR(0, 90, __pyx_L1_error)
3634         }
3635         break;
3636       }
3637       __Pyx_GOTREF(__pyx_t_2);
3638     }
3639     __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
3640     __pyx_t_2 = 0;
3641 
3642     /* "MACS2/Signal.pyx":91
3643  *         j += 1
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
3648  */
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;
3665     if (__pyx_t_5) {
3666       __Pyx_INCREF(__pyx_t_2);
3667       __pyx_t_3 = __pyx_t_2;
3668     } else {
3669       __Pyx_INCREF(__pyx_t_19);
3670       __pyx_t_3 = __pyx_t_19;
3671     }
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;
3677 
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]
3684  */
3685     __pyx_v_threshold = (__pyx_v_threshold + __pyx_f_5MACS2_6Signal_sqrt(__pyx_v_threshold));
3686 
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):
3693  */
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);
3716     {
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();
3725         } else {
3726           PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
3727         }
3728         __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
3729       }
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)
3732     }
3733     __pyx_t_10 = 0;
3734     __Pyx_DECREF_SET(__pyx_v_new_signal, ((PyArrayObject *)__pyx_t_3));
3735     __pyx_t_3 = 0;
3736 
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]
3743  */
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);
3756     __pyx_t_19 = 0;
3757 
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]
3763  *             j += 1
3764  */
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;
3770     if (__pyx_t_5) {
3771 
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]             # <<<<<<<<<<<<<<
3776  *             j += 1
3777  *     threshold =  signal[minima[-1]]
3778  */
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;
3787       __pyx_t_7 = -1;
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)
3795       }
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;
3797 
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)
3804  */
3805       __pyx_v_j = (__pyx_v_j + 1);
3806 
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]
3812  *             j += 1
3813  */
3814     }
3815 
3816     /* "MACS2/Signal.pyx":90
3817  *         peaky_maxima[0] = maxima[0]
3818  *         j += 1
3819  *     for i in range(n - 1):             # <<<<<<<<<<<<<<
3820  *         threshold = max(signal[minima[i]], signal[minima[i + 1]])
3821  *         threshold += sqrt(threshold)
3822  */
3823   }
3824   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3825 
3826   /* "MACS2/Signal.pyx":98
3827  *             peaky_maxima[j] = maxima[i + 1]
3828  *             j += 1
3829  *     threshold =  signal[minima[-1]]             # <<<<<<<<<<<<<<
3830  *     threshold += sqrt(threshold)
3831  *     new_signal = signal[minima[-1]:] - threshold
3832  */
3833   __pyx_t_24 = -1L;
3834   __pyx_t_7 = -1;
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)
3842   }
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));
3844   __pyx_t_7 = -1;
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)
3852   }
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));
3854 
3855   /* "MACS2/Signal.pyx":99
3856  *             j += 1
3857  *     threshold =  signal[minima[-1]]
3858  *     threshold += sqrt(threshold)             # <<<<<<<<<<<<<<
3859  *     new_signal = signal[minima[-1]:] - threshold
3860  *     new_maximum = maxima[-1] - minima[-1]
3861  */
3862   __pyx_v_threshold = (__pyx_v_threshold + __pyx_f_5MACS2_6Signal_sqrt(__pyx_v_threshold));
3863 
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):
3870  */
3871   __pyx_t_26 = -1L;
3872   __pyx_t_7 = -1;
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)
3880   }
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);
3897   {
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();
3906       } else {
3907         PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
3908       }
3909       __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
3910     }
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)
3913   }
3914   __pyx_t_10 = 0;
3915   __Pyx_DECREF_SET(__pyx_v_new_signal, ((PyArrayObject *)__pyx_t_19));
3916   __pyx_t_19 = 0;
3917 
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]
3924  */
3925   __pyx_t_27 = -1L;
3926   __pyx_t_7 = -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)
3934   }
3935   __pyx_t_28 = -1L;
3936   __pyx_t_7 = -1;
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)
3944   }
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);
3948   __pyx_t_19 = 0;
3949 
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]
3955  *         j += 1
3956  */
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;
3962   if (__pyx_t_5) {
3963 
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]             # <<<<<<<<<<<<<<
3968  *         j += 1
3969  *     peaky_maxima.resize(j, refcheck=False)
3970  */
3971     __pyx_t_29 = -1L;
3972     __pyx_t_7 = -1;
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)
3980     }
3981     __pyx_t_30 = __pyx_v_j;
3982     __pyx_t_7 = -1;
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)
3990     }
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));
3992 
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
3999  */
4000     __pyx_v_j = (__pyx_v_j + 1);
4001 
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]
4007  *         j += 1
4008  */
4009   }
4010 
4011   /* "MACS2/Signal.pyx":105
4012  *         peaky_maxima[j] = maxima[-1]
4013  *         j += 1
4014  *     peaky_maxima.resize(j, refcheck=False)             # <<<<<<<<<<<<<<
4015  *     return peaky_maxima
4016  *
4017  */
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);
4026   __pyx_t_3 = 0;
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;
4036 
4037   /* "MACS2/Signal.pyx":106
4038  *         j += 1
4039  *     peaky_maxima.resize(j, refcheck=False)
4040  *     return peaky_maxima             # <<<<<<<<<<<<<<
4041  *
4042  * # hardcoded minimum peak width = 50
4043  */
4044   __Pyx_XDECREF(__pyx_r);
4045   __Pyx_INCREF(((PyObject *)__pyx_v_peaky_maxima));
4046   __pyx_r = ((PyObject *)__pyx_v_peaky_maxima);
4047   goto __pyx_L0;
4048 
4049   /* "MACS2/Signal.pyx":58
4050  *     return mathsqrt(threshold)
4051  *
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
4055  */
4056 
4057   /* function exit code */
4058   __pyx_L1_error:;
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);
4075   __pyx_r = 0;
4076   goto __pyx_L2;
4077   __pyx_L0:;
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);
4083   __pyx_L2:;
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();
4092   return __pyx_r;
4093 }
4094 
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    ";
__pyx_pw_5MACS2_6Signal_3enforce_peakyness(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)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);
4104   {
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)) {
4108       Py_ssize_t kw_args;
4109       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4110       switch (pos_args) {
4111         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4112         CYTHON_FALLTHROUGH;
4113         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4114         CYTHON_FALLTHROUGH;
4115         case  0: break;
4116         default: goto __pyx_L5_argtuple_error;
4117       }
4118       kw_args = PyDict_Size(__pyx_kwds);
4119       switch (pos_args) {
4120         case  0:
4121         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signal)) != 0)) kw_args--;
4122         else goto __pyx_L5_argtuple_error;
4123         CYTHON_FALLTHROUGH;
4124         case  1:
4125         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxima)) != 0)) kw_args--;
4126         else {
4127           __Pyx_RaiseArgtupleInvalid("enforce_peakyness", 1, 2, 2, 1); __PYX_ERR(0, 58, __pyx_L3_error)
4128         }
4129       }
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)
4132       }
4133     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4134       goto __pyx_L5_argtuple_error;
4135     } else {
4136       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4137       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4138     }
4139     __pyx_v_signal = ((PyArrayObject *)values[0]);
4140     __pyx_v_maxima = ((PyArrayObject *)values[1]);
4141   }
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)
4145   __pyx_L3_error:;
4146   __Pyx_AddTraceback("MACS2.Signal.enforce_peakyness", __pyx_clineno, __pyx_lineno, __pyx_filename);
4147   __Pyx_RefNannyFinishContext();
4148   return NULL;
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);
4153 
4154   /* function exit code */
4155   goto __pyx_L0;
4156   __pyx_L1_error:;
4157   __pyx_r = NULL;
4158   __pyx_L0:;
4159   __Pyx_RefNannyFinishContext();
4160   return __pyx_r;
4161 }
4162 
__pyx_pf_5MACS2_6Signal_2enforce_peakyness(CYTHON_UNUSED PyObject * __pyx_self,PyArrayObject * __pyx_v_signal,PyArrayObject * __pyx_v_maxima)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;
4182   {
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)
4185   }
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];
4187   {
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)
4190   }
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;
4196   __pyx_t_1 = 0;
4197   goto __pyx_L0;
4198 
4199   /* function exit code */
4200   __pyx_L1_error:;
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);
4210   __pyx_r = NULL;
4211   goto __pyx_L2;
4212   __pyx_L0:;
4213   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
4214   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
4215   __pyx_L2:;
4216   __Pyx_XGIVEREF(__pyx_r);
4217   __Pyx_TraceReturn(__pyx_r, 0);
4218   __Pyx_RefNannyFinishContext();
4219   return __pyx_r;
4220 }
4221 
4222 /* "MACS2/Signal.pyx":109
4223  *
4224  * # hardcoded minimum peak width = 50
4225  * cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum):             # <<<<<<<<<<<<<<
4226  *     cdef:
4227  *         s = hard_clip(signal, maximum)
4228  */
4229 
__pyx_f_5MACS2_6Signal_is_valid_peak(PyArrayObject * __pyx_v_signal,int __pyx_v_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;
4232   int __pyx_v_length;
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;
4240   int __pyx_t_3;
4241   int __pyx_t_4;
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;
4248   {
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)
4251   }
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];
4253 
4254   /* "MACS2/Signal.pyx":111
4255  * cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum):
4256  *     cdef:
4257  *         s = hard_clip(signal, maximum)             # <<<<<<<<<<<<<<
4258  *         int length = s.shape[0]
4259  *     if length < 50: return False
4260  */
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;
4264   __pyx_t_1 = 0;
4265 
4266   /* "MACS2/Signal.pyx":112
4267  *     cdef:
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
4272  */
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;
4281 
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
4287  *     return True
4288  */
4289   __pyx_t_4 = ((__pyx_v_length < 50) != 0);
4290   if (__pyx_t_4) {
4291     __Pyx_XDECREF(((PyObject *)__pyx_r));
4292     __Pyx_INCREF(Py_False);
4293     __pyx_r = ((PyBoolObject *)Py_False);
4294     goto __pyx_L0;
4295   }
4296 
4297   /* "MACS2/Signal.pyx":114
4298  *         int length = s.shape[0]
4299  *     if length < 50: return False
4300  *     elif too_flat(s): return False             # <<<<<<<<<<<<<<
4301  *     return True
4302  *
4303  */
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;
4309   if (__pyx_t_4) {
4310     __Pyx_XDECREF(((PyObject *)__pyx_r));
4311     __Pyx_INCREF(Py_False);
4312     __pyx_r = ((PyBoolObject *)Py_False);
4313     goto __pyx_L0;
4314   }
4315 
4316   /* "MACS2/Signal.pyx":115
4317  *     if length < 50: return False
4318  *     elif too_flat(s): return False
4319  *     return True             # <<<<<<<<<<<<<<
4320  *
4321  * # require at least 6 different float values -- prevents broad flat peaks
4322  */
4323   __Pyx_XDECREF(((PyObject *)__pyx_r));
4324   __Pyx_INCREF(Py_True);
4325   __pyx_r = ((PyBoolObject *)Py_True);
4326   goto __pyx_L0;
4327 
4328   /* "MACS2/Signal.pyx":109
4329  *
4330  * # hardcoded minimum peak width = 50
4331  * cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum):             # <<<<<<<<<<<<<<
4332  *     cdef:
4333  *         s = hard_clip(signal, maximum)
4334  */
4335 
4336   /* function exit code */
4337   __pyx_L1_error:;
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);
4347   __pyx_r = 0;
4348   goto __pyx_L2;
4349   __pyx_L0:;
4350   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
4351   __pyx_L2:;
4352   __Pyx_XDECREF(__pyx_v_s);
4353   __Pyx_XGIVEREF((PyObject *)__pyx_r);
4354   __Pyx_TraceReturn(__pyx_r, 0);
4355   __Pyx_RefNannyFinishContext();
4356   return __pyx_r;
4357 }
4358 
4359 /* "MACS2/Signal.pyx":118
4360  *
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
4364  * #    """
4365  */
4366 
__pyx_f_5MACS2_6Signal_too_flat(PyArrayObject * __pyx_v_signal)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;
4382   {
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)
4385   }
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];
4387 
4388   /* "MACS2/Signal.pyx":121
4389  * #    """return whether signal has at least 6 unique values
4390  * #    """
4391  *     return np.unique(signal).shape[0] < 6             # <<<<<<<<<<<<<<
4392  *
4393  * # hard clip a region with negative values
4394  */
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;
4401   __pyx_t_2 = NULL;
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);
4409     }
4410   }
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);
4426   __pyx_t_3 = 0;
4427   goto __pyx_L0;
4428 
4429   /* "MACS2/Signal.pyx":118
4430  *
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
4434  * #    """
4435  */
4436 
4437   /* function exit code */
4438   __pyx_L1_error:;
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);
4449   __pyx_r = 0;
4450   goto __pyx_L2;
4451   __pyx_L0:;
4452   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
4453   __pyx_L2:;
4454   __Pyx_XGIVEREF((PyObject *)__pyx_r);
4455   __Pyx_TraceReturn(__pyx_r, 0);
4456   __Pyx_RefNannyFinishContext();
4457   return __pyx_r;
4458 }
4459 
4460 /* "MACS2/Signal.pyx":124
4461  *
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
4466  */
4467 
__pyx_f_5MACS2_6Signal_hard_clip(PyArrayObject * __pyx_v_signal,int __pyx_v_maximum)4468 static PyArrayObject *__pyx_f_5MACS2_6Signal_hard_clip(PyArrayObject *__pyx_v_signal, int __pyx_v_maximum) {
4469   int __pyx_v_i;
4470   int __pyx_v_left;
4471   int __pyx_v_right;
4472   __Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
4473   __Pyx_Buffer __pyx_pybuffer_signal;
4474   PyArrayObject *__pyx_r = NULL;
4475   __Pyx_TraceDeclarations
4476   __Pyx_RefNannyDeclarations
4477   int __pyx_t_1;
4478   Py_ssize_t __pyx_t_2;
4479   int __pyx_t_3;
4480   int __pyx_t_4;
4481   int __pyx_t_5;
4482   Py_ssize_t __pyx_t_6;
4483   int __pyx_t_7;
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;
4493   {
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)
4496   }
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];
4498 
4499   /* "MACS2/Signal.pyx":130
4500  *     cdef:
4501  *         int i
4502  *         int left = 0             # <<<<<<<<<<<<<<
4503  *         int right = signal.shape[0]
4504  *     # clip left
4505  */
4506   __pyx_v_left = 0;
4507 
4508   /* "MACS2/Signal.pyx":131
4509  *         int i
4510  *         int left = 0
4511  *         int right = signal.shape[0]             # <<<<<<<<<<<<<<
4512  *     # clip left
4513  *     for i in range(right - maximum, 0):
4514  */
4515   __pyx_v_right = (__pyx_v_signal->dimensions[0]);
4516 
4517   /* "MACS2/Signal.pyx":133
4518  *         int right = signal.shape[0]
4519  *     # clip left
4520  *     for i in range(right - maximum, 0):             # <<<<<<<<<<<<<<
4521  *         if signal[-i] < 0:
4522  *             left = i
4523  */
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;
4526 
4527     /* "MACS2/Signal.pyx":134
4528  *     # clip left
4529  *     for i in range(right - maximum, 0):
4530  *         if signal[-i] < 0:             # <<<<<<<<<<<<<<
4531  *             left = i
4532  *             break
4533  */
4534     __pyx_t_2 = (-__pyx_v_i);
4535     __pyx_t_3 = -1;
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)
4543     }
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);
4545     if (__pyx_t_4) {
4546 
4547       /* "MACS2/Signal.pyx":135
4548  *     for i in range(right - maximum, 0):
4549  *         if signal[-i] < 0:
4550  *             left = i             # <<<<<<<<<<<<<<
4551  *             break
4552  *     for i in range(maximum, right):
4553  */
4554       __pyx_v_left = __pyx_v_i;
4555 
4556       /* "MACS2/Signal.pyx":136
4557  *         if signal[-i] < 0:
4558  *             left = i
4559  *             break             # <<<<<<<<<<<<<<
4560  *     for i in range(maximum, right):
4561  *         if signal[i] < 0:
4562  */
4563       goto __pyx_L4_break;
4564 
4565       /* "MACS2/Signal.pyx":134
4566  *     # clip left
4567  *     for i in range(right - maximum, 0):
4568  *         if signal[-i] < 0:             # <<<<<<<<<<<<<<
4569  *             left = i
4570  *             break
4571  */
4572     }
4573   }
4574   __pyx_L4_break:;
4575 
4576   /* "MACS2/Signal.pyx":137
4577  *             left = i
4578  *             break
4579  *     for i in range(maximum, right):             # <<<<<<<<<<<<<<
4580  *         if signal[i] < 0:
4581  *             right = i
4582  */
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;
4587 
4588     /* "MACS2/Signal.pyx":138
4589  *             break
4590  *     for i in range(maximum, right):
4591  *         if signal[i] < 0:             # <<<<<<<<<<<<<<
4592  *             right = i
4593  *             break
4594  */
4595     __pyx_t_6 = __pyx_v_i;
4596     __pyx_t_7 = -1;
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)
4604     }
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);
4606     if (__pyx_t_4) {
4607 
4608       /* "MACS2/Signal.pyx":139
4609  *     for i in range(maximum, right):
4610  *         if signal[i] < 0:
4611  *             right = i             # <<<<<<<<<<<<<<
4612  *             break
4613  *     return signal[left:right]
4614  */
4615       __pyx_v_right = __pyx_v_i;
4616 
4617       /* "MACS2/Signal.pyx":140
4618  *         if signal[i] < 0:
4619  *             right = i
4620  *             break             # <<<<<<<<<<<<<<
4621  *     return signal[left:right]
4622  *
4623  */
4624       goto __pyx_L7_break;
4625 
4626       /* "MACS2/Signal.pyx":138
4627  *             break
4628  *     for i in range(maximum, right):
4629  *         if signal[i] < 0:             # <<<<<<<<<<<<<<
4630  *             right = i
4631  *             break
4632  */
4633     }
4634   }
4635   __pyx_L7_break:;
4636 
4637   /* "MACS2/Signal.pyx":141
4638  *             right = i
4639  *             break
4640  *     return signal[left:right]             # <<<<<<<<<<<<<<
4641  *
4642  * # for all maxima, set min_subpeak_width = 0
4643  */
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);
4658   __pyx_t_9 = 0;
4659   goto __pyx_L0;
4660 
4661   /* "MACS2/Signal.pyx":124
4662  *
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
4667  */
4668 
4669   /* function exit code */
4670   __pyx_L1_error:;
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);
4681   __pyx_r = 0;
4682   goto __pyx_L2;
4683   __pyx_L0:;
4684   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
4685   __pyx_L2:;
4686   __Pyx_XGIVEREF((PyObject *)__pyx_r);
4687   __Pyx_TraceReturn(__pyx_r, 0);
4688   __Pyx_RefNannyFinishContext();
4689   return __pyx_r;
4690 }
4691 
4692 /* "MACS2/Signal.pyx":171
4693  * #        return n
4694  *
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):
4698  */
4699 
4700 static PyObject *__pyx_pw_5MACS2_6Signal_5enforce_valleys(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__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)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;
4704   float __pyx_v_v;
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;
4711   long __pyx_v_i;
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;
4725   int __pyx_t_5;
4726   int __pyx_t_6;
4727   int __pyx_t_7;
4728   long __pyx_t_8;
4729   Py_ssize_t __pyx_t_9;
4730   int __pyx_t_10;
4731   Py_ssize_t __pyx_t_11;
4732   Py_ssize_t __pyx_t_12;
4733   Py_ssize_t __pyx_t_13;
4734   float __pyx_t_14;
4735   float __pyx_t_15;
4736   float __pyx_t_16;
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;
4745     }
4746   }
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;
4759   {
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)
4762   }
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];
4764   {
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)
4767   }
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];
4769 
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()
4776  */
4777   __pyx_v_n_summits = (__pyx_v_summits->dimensions[0]);
4778 
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
4785  */
4786   __pyx_v_n_valid_summits = 1;
4787 
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
4794  */
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);
4797   __pyx_t_3 = NULL;
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);
4805     }
4806   }
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);
4814   {
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];
4820     }
4821   }
4822   __pyx_t_4 = 0;
4823   __pyx_v_valid_summits = ((PyArrayObject *)__pyx_t_1);
4824   __pyx_t_1 = 0;
4825 
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]
4832  */
4833   __pyx_t_5 = ((__pyx_v_n_summits == 1) != 0);
4834   if (__pyx_t_5) {
4835     __Pyx_XDECREF(__pyx_r);
4836     __Pyx_INCREF(((PyObject *)__pyx_v_summits));
4837     __pyx_r = ((PyObject *)__pyx_v_summits);
4838     goto __pyx_L0;
4839   }
4840 
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]
4847  */
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;
4852 
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]
4859  */
4860     __pyx_t_9 = (__pyx_v_n_valid_summits - 1);
4861     __pyx_t_10 = -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)
4869     }
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));
4871 
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]
4878  */
4879     __pyx_t_11 = __pyx_v_i;
4880     __pyx_t_10 = -1;
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)
4888     }
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));
4890 
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)
4897  */
4898     __pyx_t_12 = __pyx_v_prev_summit_pos;
4899     __pyx_t_10 = -1;
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)
4907     }
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));
4909 
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():
4916  */
4917     __pyx_t_13 = __pyx_v_summit_pos;
4918     __pyx_t_10 = -1;
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)
4926     }
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));
4928 
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
4935  */
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;
4940     } else {
4941       __pyx_t_16 = __pyx_t_15;
4942     }
4943     __pyx_v_req_min = (__pyx_v_min_valley * __pyx_t_16);
4944 
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
4951  */
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;
4971     __pyx_t_2 = NULL;
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);
4979       }
4980     }
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;
4988     if (__pyx_t_5) {
4989 
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
4995  *         elif v > prev_v:
4996  */
4997       __pyx_t_18 = __pyx_v_n_valid_summits;
4998       __pyx_t_10 = -1;
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)
5006       }
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;
5008 
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             # <<<<<<<<<<<<<<
5013  *         elif v > prev_v:
5014  *             valid_summits[n_valid_summits-1] = summit_pos
5015  */
5016       __pyx_v_n_valid_summits = (__pyx_v_n_valid_summits + 1);
5017 
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
5024  */
5025       goto __pyx_L6;
5026     }
5027 
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)
5034  */
5035     __pyx_t_5 = ((__pyx_v_v > __pyx_v_prev_v) != 0);
5036     if (__pyx_t_5) {
5037 
5038       /* "MACS2/Signal.pyx":195
5039  *             n_valid_summits += 1
5040  *         elif v > prev_v:
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
5044  */
5045       __pyx_t_19 = (__pyx_v_n_valid_summits - 1);
5046       __pyx_t_10 = -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)
5054       }
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;
5056 
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)
5063  */
5064     }
5065     __pyx_L6:;
5066   }
5067 
5068   /* "MACS2/Signal.pyx":196
5069  *         elif v > prev_v:
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
5073  *     #
5074  */
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);
5083   __pyx_t_17 = 0;
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;
5093 
5094   /* "MACS2/Signal.pyx":199
5095  *     # Step 2: Re-find peaks from subtracted signal
5096  *     #
5097  *     return valid_summits             # <<<<<<<<<<<<<<
5098  *
5099  * # Modified from http://www.scipy.org/Cookbook/SavitzkyGolay
5100  */
5101   __Pyx_XDECREF(__pyx_r);
5102   __Pyx_INCREF(((PyObject *)__pyx_v_valid_summits));
5103   __pyx_r = ((PyObject *)__pyx_v_valid_summits);
5104   goto __pyx_L0;
5105 
5106   /* "MACS2/Signal.pyx":171
5107  * #        return n
5108  *
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):
5112  */
5113 
5114   /* function exit code */
5115   __pyx_L1_error:;
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);
5129   __pyx_r = 0;
5130   goto __pyx_L2;
5131   __pyx_L0:;
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);
5135   __pyx_L2:;
5136   __Pyx_XDECREF((PyObject *)__pyx_v_valid_summits);
5137   __Pyx_XGIVEREF(__pyx_r);
5138   __Pyx_TraceReturn(__pyx_r, 0);
5139   __Pyx_RefNannyFinishContext();
5140   return __pyx_r;
5141 }
5142 
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    ";
__pyx_pw_5MACS2_6Signal_5enforce_valleys(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)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);
5153   {
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)) {
5157       Py_ssize_t kw_args;
5158       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5159       switch (pos_args) {
5160         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5161         CYTHON_FALLTHROUGH;
5162         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5163         CYTHON_FALLTHROUGH;
5164         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5165         CYTHON_FALLTHROUGH;
5166         case  0: break;
5167         default: goto __pyx_L5_argtuple_error;
5168       }
5169       kw_args = PyDict_Size(__pyx_kwds);
5170       switch (pos_args) {
5171         case  0:
5172         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signal)) != 0)) kw_args--;
5173         else goto __pyx_L5_argtuple_error;
5174         CYTHON_FALLTHROUGH;
5175         case  1:
5176         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_summits)) != 0)) kw_args--;
5177         else {
5178           __Pyx_RaiseArgtupleInvalid("enforce_valleys", 0, 2, 3, 1); __PYX_ERR(0, 171, __pyx_L3_error)
5179         }
5180         CYTHON_FALLTHROUGH;
5181         case  2:
5182         if (kw_args > 0) {
5183           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_valley);
5184           if (value) { values[2] = value; kw_args--; }
5185         }
5186       }
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)
5189       }
5190     } else {
5191       switch (PyTuple_GET_SIZE(__pyx_args)) {
5192         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5193         CYTHON_FALLTHROUGH;
5194         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5195         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5196         break;
5197         default: goto __pyx_L5_argtuple_error;
5198       }
5199     }
5200     __pyx_v_signal = ((PyArrayObject *)values[0]);
5201     __pyx_v_summits = ((PyArrayObject *)values[1]);
5202     if (values[2]) {
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)
5204     } else {
5205       __pyx_v_min_valley = ((float)0.8);
5206     }
5207   }
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)
5211   __pyx_L3_error:;
5212   __Pyx_AddTraceback("MACS2.Signal.enforce_valleys", __pyx_clineno, __pyx_lineno, __pyx_filename);
5213   __Pyx_RefNannyFinishContext();
5214   return NULL;
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);
5219 
5220   /* function exit code */
5221   goto __pyx_L0;
5222   __pyx_L1_error:;
5223   __pyx_r = NULL;
5224   __pyx_L0:;
5225   __Pyx_RefNannyFinishContext();
5226   return __pyx_r;
5227 }
5228 
__pyx_pf_5MACS2_6Signal_4enforce_valleys(CYTHON_UNUSED PyObject * __pyx_self,PyArrayObject * __pyx_v_signal,PyArrayObject * __pyx_v_summits,float __pyx_v_min_valley)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;
5249   {
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)
5252   }
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];
5254   {
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)
5257   }
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;
5265   __pyx_t_1 = 0;
5266   goto __pyx_L0;
5267 
5268   /* function exit code */
5269   __pyx_L1_error:;
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);
5279   __pyx_r = NULL;
5280   goto __pyx_L2;
5281   __pyx_L0:;
5282   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
5283   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_summits.rcbuffer->pybuffer);
5284   __pyx_L2:;
5285   __Pyx_XGIVEREF(__pyx_r);
5286   __Pyx_TraceReturn(__pyx_r, 0);
5287   __Pyx_RefNannyFinishContext();
5288   return __pyx_r;
5289 }
5290 
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,             # <<<<<<<<<<<<<<
5295  *                      int window_size):
5296  *     """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
5297  */
5298 
5299 static PyObject *__pyx_pw_5MACS2_6Signal_7savitzky_golay_order2_deriv1(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5MACS2_6Signal_savitzky_golay_order2_deriv1(PyArrayObject * __pyx_v_signal,int __pyx_v_window_size,CYTHON_UNUSED int __pyx_skip_dispatch)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
5323   int __pyx_t_1;
5324   PyObject *__pyx_t_2 = NULL;
5325   PyObject *__pyx_t_3 = NULL;
5326   long __pyx_t_4;
5327   long __pyx_t_5;
5328   int __pyx_t_6;
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;
5371   {
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)
5374   }
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];
5376 
5377   /* "MACS2/Signal.pyx":249
5378  *         np.ndarray[np.float64_t, ndim=1] m, ret
5379  *
5380  *     if window_size % 2 != 1: window_size += 1             # <<<<<<<<<<<<<<
5381  *     half_window = (window_size - 1) // 2
5382  *     # precompute coefficients
5383  */
5384   __pyx_t_1 = ((__Pyx_mod_long(__pyx_v_window_size, 2) != 1) != 0);
5385   if (__pyx_t_1) {
5386     __pyx_v_window_size = (__pyx_v_window_size + 1);
5387   }
5388 
5389   /* "MACS2/Signal.pyx":250
5390  *
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)],
5395  */
5396   __pyx_v_half_window = __Pyx_div_long((__pyx_v_window_size - 1), 2);
5397 
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)],             # <<<<<<<<<<<<<<
5402  *                  dtype='int64')
5403  *     m = np.linalg.pinv(b)[1]
5404  */
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);
5430       __pyx_t_7 = 0;
5431       __pyx_t_8 = 0;
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;
5434     }
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);
5440   __pyx_t_2 = 0;
5441 
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
5448  */
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)
5452 
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)],             # <<<<<<<<<<<<<<
5457  *                  dtype='int64')
5458  *     m = np.linalg.pinv(b)[1]
5459  */
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);
5467   {
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();
5476       } else {
5477         PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
5478       }
5479       __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
5480     }
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)
5483   }
5484   __pyx_t_10 = 0;
5485   __pyx_v_b = ((PyArrayObject *)__pyx_t_8);
5486   __pyx_t_8 = 0;
5487 
5488   /* "MACS2/Signal.pyx":254
5489  *     b = np.array([[1, k, k**2] for k in range(-half_window, half_window+1)],
5490  *                  dtype='int64')
5491  *     m = np.linalg.pinv(b)[1]             # <<<<<<<<<<<<<<
5492  *     # pad the signal at the extremes with
5493  *     # values taken from the signal itself
5494  */
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;
5503   __pyx_t_9 = NULL;
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);
5511     }
5512   }
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);
5523   {
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();
5532       } else {
5533         PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
5534       }
5535       __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
5536     }
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)
5539   }
5540   __pyx_t_14 = 0;
5541   __pyx_v_m = ((PyArrayObject *)__pyx_t_2);
5542   __pyx_t_2 = 0;
5543 
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))
5550  */
5551   __pyx_t_15 = 0;
5552   __pyx_t_6 = -1;
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)
5560   }
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;
5579   __pyx_t_16 = 0;
5580   __pyx_t_6 = -1;
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)
5588   }
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;
5595   __pyx_t_9 = NULL;
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);
5603     }
5604   }
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);
5617   {
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();
5626       } else {
5627         PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
5628       }
5629       __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
5630     }
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)
5633   }
5634   __pyx_t_18 = 0;
5635   __pyx_v_firstvals = ((PyArrayObject *)__pyx_t_3);
5636   __pyx_t_3 = 0;
5637 
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))
5643  *     #print (repr(m))
5644  */
5645   __pyx_t_19 = -1L;
5646   __pyx_t_6 = -1;
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)
5654   }
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;
5673   __pyx_t_20 = -1L;
5674   __pyx_t_6 = -1;
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)
5682   }
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;
5689   __pyx_t_2 = NULL;
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);
5697     }
5698   }
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);
5711   {
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();
5720       } else {
5721         PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
5722       }
5723       __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
5724     }
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)
5727   }
5728   __pyx_t_18 = 0;
5729   __pyx_v_lastvals = ((PyArrayObject *)__pyx_t_17);
5730   __pyx_t_17 = 0;
5731 
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))             # <<<<<<<<<<<<<<
5736  *     #print (repr(m))
5737  *     ret = np.convolve( m[::-1], signal.astype("float64"), mode='valid') #.astype("float32").round(8) # round to 8 decimals to avoid signing issue
5738  */
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));
5755   __pyx_t_7 = NULL;
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);
5763     }
5764   }
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);
5773   {
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();
5782       } else {
5783         PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
5784       }
5785       __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
5786     }
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)
5789   }
5790   __pyx_t_21 = 0;
5791   __Pyx_DECREF_SET(__pyx_v_signal, ((PyArrayObject *)__pyx_t_17));
5792   __pyx_t_17 = 0;
5793 
5794   /* "MACS2/Signal.pyx":261
5795  *     signal = np.concatenate((firstvals, signal, lastvals))
5796  *     #print (repr(m))
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])
5799  *     return ret
5800  */
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);
5810   __pyx_t_2 = NULL;
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);
5818     }
5819   }
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);
5831   __pyx_t_17 = 0;
5832   __pyx_t_8 = 0;
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);
5843   {
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();
5852       } else {
5853         PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
5854       }
5855       __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
5856     }
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)
5859   }
5860   __pyx_t_14 = 0;
5861   __pyx_v_ret = ((PyArrayObject *)__pyx_t_17);
5862   __pyx_t_17 = 0;
5863 
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             # <<<<<<<<<<<<<<
5868  *
5869  *
5870  */
5871   __Pyx_XDECREF(((PyObject *)__pyx_r));
5872   __Pyx_INCREF(((PyObject *)__pyx_v_ret));
5873   __pyx_r = ((PyArrayObject *)__pyx_v_ret);
5874   goto __pyx_L0;
5875 
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,             # <<<<<<<<<<<<<<
5880  *                      int window_size):
5881  *     """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
5882  */
5883 
5884   /* function exit code */
5885   __pyx_L1_error:;
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);
5904   __pyx_r = 0;
5905   goto __pyx_L2;
5906   __pyx_L0:;
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);
5913   __pyx_L2:;
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();
5923   return __pyx_r;
5924 }
5925 
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    ";
__pyx_pw_5MACS2_6Signal_7savitzky_golay_order2_deriv1(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)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);
5935   {
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)) {
5939       Py_ssize_t kw_args;
5940       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5941       switch (pos_args) {
5942         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5943         CYTHON_FALLTHROUGH;
5944         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5945         CYTHON_FALLTHROUGH;
5946         case  0: break;
5947         default: goto __pyx_L5_argtuple_error;
5948       }
5949       kw_args = PyDict_Size(__pyx_kwds);
5950       switch (pos_args) {
5951         case  0:
5952         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signal)) != 0)) kw_args--;
5953         else goto __pyx_L5_argtuple_error;
5954         CYTHON_FALLTHROUGH;
5955         case  1:
5956         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_window_size)) != 0)) kw_args--;
5957         else {
5958           __Pyx_RaiseArgtupleInvalid("savitzky_golay_order2_deriv1", 1, 2, 2, 1); __PYX_ERR(0, 205, __pyx_L3_error)
5959         }
5960       }
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)
5963       }
5964     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5965       goto __pyx_L5_argtuple_error;
5966     } else {
5967       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5968       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5969     }
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)
5972   }
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)
5976   __pyx_L3_error:;
5977   __Pyx_AddTraceback("MACS2.Signal.savitzky_golay_order2_deriv1", __pyx_clineno, __pyx_lineno, __pyx_filename);
5978   __Pyx_RefNannyFinishContext();
5979   return NULL;
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);
5983 
5984   /* function exit code */
5985   goto __pyx_L0;
5986   __pyx_L1_error:;
5987   __pyx_r = NULL;
5988   __pyx_L0:;
5989   __Pyx_RefNannyFinishContext();
5990   return __pyx_r;
5991 }
5992 
__pyx_pf_5MACS2_6Signal_6savitzky_golay_order2_deriv1(CYTHON_UNUSED PyObject * __pyx_self,PyArrayObject * __pyx_v_signal,int __pyx_v_window_size)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;
6006   {
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)
6009   }
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;
6015   __pyx_t_1 = 0;
6016   goto __pyx_L0;
6017 
6018   /* function exit code */
6019   __pyx_L1_error:;
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);
6028   __pyx_r = NULL;
6029   goto __pyx_L2;
6030   __pyx_L0:;
6031   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
6032   __pyx_L2:;
6033   __Pyx_XGIVEREF(__pyx_r);
6034   __Pyx_TraceReturn(__pyx_r, 0);
6035   __Pyx_RefNannyFinishContext();
6036   return __pyx_r;
6037 }
6038 
6039 /* "MACS2/Signal.pyx":267
6040  *
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.
6045  */
6046 
6047 static PyObject *__pyx_pw_5MACS2_6Signal_9savitzky_golay(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__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)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;
6084   int __pyx_t_10;
6085   int __pyx_t_11;
6086   int __pyx_t_12;
6087   long __pyx_t_13;
6088   long __pyx_t_14;
6089   long __pyx_t_15;
6090   long __pyx_t_16;
6091   long __pyx_t_17;
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;
6107       }
6108     }
6109   }
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;
6135   {
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)
6138   }
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];
6140 
6141   /* "MACS2/Signal.pyx":324
6142  *         np.ndarray[np.float64_t, ndim=1] m
6143  *
6144  *     try:             # <<<<<<<<<<<<<<
6145  *         window_size = np.abs( np.int( window_size ) )
6146  *         order = np.abs( np.int( order ) )
6147  */
6148   {
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);
6155     /*try:*/ {
6156 
6157       /* "MACS2/Signal.pyx":325
6158  *
6159  *     try:
6160  *         window_size = np.abs( np.int( window_size ) )             # <<<<<<<<<<<<<<
6161  *         order = np.abs( np.int( order ) )
6162  *     except ValueError, msg:
6163  */
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);
6176       __pyx_t_9 = NULL;
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);
6184         }
6185       }
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;
6192       __pyx_t_8 = NULL;
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);
6200         }
6201       }
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;
6211 
6212       /* "MACS2/Signal.pyx":326
6213  *     try:
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")
6218  */
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);
6231       __pyx_t_9 = NULL;
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);
6239         }
6240       }
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;
6247       __pyx_t_7 = NULL;
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);
6255         }
6256       }
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;
6266 
6267       /* "MACS2/Signal.pyx":324
6268  *         np.ndarray[np.float64_t, ndim=1] m
6269  *
6270  *     try:             # <<<<<<<<<<<<<<
6271  *         window_size = np.abs( np.int( window_size ) )
6272  *         order = np.abs( np.int( order ) )
6273  */
6274     }
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;
6279     __pyx_L3_error:;
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;
6286 
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:
6293  */
6294     __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
6295     if (__pyx_t_10) {
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;
6303 
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")
6310  */
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)
6316     }
6317     goto __pyx_L5_except_error;
6318     __pyx_L5_except_error:;
6319 
6320     /* "MACS2/Signal.pyx":324
6321  *         np.ndarray[np.float64_t, ndim=1] m
6322  *
6323  *     try:             # <<<<<<<<<<<<<<
6324  *         window_size = np.abs( np.int( window_size ) )
6325  *         order = np.abs( np.int( order ) )
6326  */
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;
6332     __pyx_L8_try_end:;
6333   }
6334 
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:
6341  */
6342   __pyx_t_12 = ((__Pyx_mod_long(__pyx_v_window_size, 2) != 1) != 0);
6343   if (!__pyx_t_12) {
6344   } else {
6345     __pyx_t_11 = __pyx_t_12;
6346     goto __pyx_L12_bool_binop_done;
6347   }
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)) {
6352 
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")
6359  */
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)
6365 
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:
6372  */
6373   }
6374 
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
6381  */
6382   __pyx_t_11 = ((__pyx_v_window_size < (__pyx_v_order + 2)) != 0);
6383   if (unlikely(__pyx_t_11)) {
6384 
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
6391  */
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)
6397 
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
6404  */
6405   }
6406 
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 ) ] )
6413  */
6414   __pyx_v_half_window = __Pyx_div_long((__pyx_v_window_size - 1), 2);
6415 
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
6422  */
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;
6446         }
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;
6450     }
6451   } /* exit inner scope */
6452   __pyx_t_7 = NULL;
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);
6460     }
6461   }
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);
6470   {
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();
6479       } else {
6480         PyErr_Restore(__pyx_t_3, __pyx_t_2, __pyx_t_1);
6481       }
6482       __pyx_t_3 = __pyx_t_2 = __pyx_t_1 = 0;
6483     }
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)
6486   }
6487   __pyx_t_18 = 0;
6488   __pyx_v_b = ((PyArrayObject *)__pyx_t_6);
6489   __pyx_t_6 = 0;
6490 
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
6497  */
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;
6506   __pyx_t_5 = NULL;
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);
6514     }
6515   }
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);
6534   __pyx_t_8 = NULL;
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);
6542     }
6543   }
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);
6556   {
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();
6565       } else {
6566         PyErr_Restore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
6567       }
6568       __pyx_t_1 = __pyx_t_2 = __pyx_t_3 = 0;
6569     }
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)
6572   }
6573   __pyx_t_19 = 0;
6574   __pyx_v_m = ((PyArrayObject *)__pyx_t_4);
6575   __pyx_t_4 = 0;
6576 
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 ) )
6583  */
6584   __pyx_t_20 = 0;
6585   __pyx_t_10 = -1;
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)
6593   }
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;
6612   __pyx_t_21 = 0;
6613   __pyx_t_10 = -1;
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)
6621   }
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;
6628   __pyx_t_5 = NULL;
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);
6636     }
6637   }
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);
6650   {
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();
6659       } else {
6660         PyErr_Restore(__pyx_t_3, __pyx_t_2, __pyx_t_1);
6661       }
6662       __pyx_t_3 = __pyx_t_2 = __pyx_t_1 = 0;
6663     }
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)
6666   }
6667   __pyx_t_22 = 0;
6668   __pyx_v_firstvals = ((PyArrayObject *)__pyx_t_7);
6669   __pyx_t_7 = 0;
6670 
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")
6677  */
6678   __pyx_t_23 = -1L;
6679   __pyx_t_10 = -1;
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)
6687   }
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;
6706   __pyx_t_24 = -1L;
6707   __pyx_t_10 = -1;
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)
6715   }
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;
6722   __pyx_t_4 = NULL;
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);
6730     }
6731   }
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);
6744   {
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();
6753       } else {
6754         PyErr_Restore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
6755       }
6756       __pyx_t_1 = __pyx_t_2 = __pyx_t_3 = 0;
6757     }
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)
6760   }
6761   __pyx_t_22 = 0;
6762   __pyx_v_lastvals = ((PyArrayObject *)__pyx_t_9);
6763   __pyx_t_9 = 0;
6764 
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")
6770  *     return ret
6771  */
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));
6788   __pyx_t_8 = NULL;
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);
6796     }
6797   }
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);
6806   {
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();
6815       } else {
6816         PyErr_Restore(__pyx_t_3, __pyx_t_2, __pyx_t_1);
6817       }
6818       __pyx_t_3 = __pyx_t_2 = __pyx_t_1 = 0;
6819     }
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)
6822   }
6823   __pyx_t_25 = 0;
6824   __Pyx_DECREF_SET(__pyx_v_y, ((PyArrayObject *)__pyx_t_9));
6825   __pyx_t_9 = 0;
6826 
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")             # <<<<<<<<<<<<<<
6831  *     return ret
6832  */
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));
6847   __pyx_t_7 = 0;
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;
6859   __pyx_t_4 = NULL;
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);
6867     }
6868   }
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);
6876   {
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();
6885       } else {
6886         PyErr_Restore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
6887       }
6888       __pyx_t_1 = __pyx_t_2 = __pyx_t_3 = 0;
6889     }
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)
6892   }
6893   __pyx_t_22 = 0;
6894   __pyx_v_ret = ((PyArrayObject *)__pyx_t_9);
6895   __pyx_t_9 = 0;
6896 
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             # <<<<<<<<<<<<<<
6901  */
6902   __Pyx_XDECREF(((PyObject *)__pyx_r));
6903   __Pyx_INCREF(((PyObject *)__pyx_v_ret));
6904   __pyx_r = ((PyArrayObject *)__pyx_v_ret);
6905   goto __pyx_L0;
6906 
6907   /* "MACS2/Signal.pyx":267
6908  *
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.
6913  */
6914 
6915   /* function exit code */
6916   __pyx_L1_error:;
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);
6935   __pyx_r = 0;
6936   goto __pyx_L2;
6937   __pyx_L0:;
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);
6944   __pyx_L2:;
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();
6955   return __pyx_r;
6956 }
6957 
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   "" ";
__pyx_pw_5MACS2_6Signal_9savitzky_golay(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)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;
6964   int __pyx_v_order;
6965   int __pyx_v_deriv;
6966   int __pyx_v_rate;
6967   PyObject *__pyx_r = 0;
6968   __Pyx_RefNannyDeclarations
6969   __Pyx_RefNannySetupContext("savitzky_golay (wrapper)", 0);
6970   {
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)) {
6974       Py_ssize_t kw_args;
6975       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6976       switch (pos_args) {
6977         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6978         CYTHON_FALLTHROUGH;
6979         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6980         CYTHON_FALLTHROUGH;
6981         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6982         CYTHON_FALLTHROUGH;
6983         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6984         CYTHON_FALLTHROUGH;
6985         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6986         CYTHON_FALLTHROUGH;
6987         case  0: break;
6988         default: goto __pyx_L5_argtuple_error;
6989       }
6990       kw_args = PyDict_Size(__pyx_kwds);
6991       switch (pos_args) {
6992         case  0:
6993         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
6994         else goto __pyx_L5_argtuple_error;
6995         CYTHON_FALLTHROUGH;
6996         case  1:
6997         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_window_size)) != 0)) kw_args--;
6998         else {
6999           __Pyx_RaiseArgtupleInvalid("savitzky_golay", 0, 3, 5, 1); __PYX_ERR(0, 267, __pyx_L3_error)
7000         }
7001         CYTHON_FALLTHROUGH;
7002         case  2:
7003         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_order)) != 0)) kw_args--;
7004         else {
7005           __Pyx_RaiseArgtupleInvalid("savitzky_golay", 0, 3, 5, 2); __PYX_ERR(0, 267, __pyx_L3_error)
7006         }
7007         CYTHON_FALLTHROUGH;
7008         case  3:
7009         if (kw_args > 0) {
7010           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deriv);
7011           if (value) { values[3] = value; kw_args--; }
7012         }
7013         CYTHON_FALLTHROUGH;
7014         case  4:
7015         if (kw_args > 0) {
7016           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rate);
7017           if (value) { values[4] = value; kw_args--; }
7018         }
7019       }
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)
7022       }
7023     } else {
7024       switch (PyTuple_GET_SIZE(__pyx_args)) {
7025         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
7026         CYTHON_FALLTHROUGH;
7027         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7028         CYTHON_FALLTHROUGH;
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);
7032         break;
7033         default: goto __pyx_L5_argtuple_error;
7034       }
7035     }
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)
7039     if (values[3]) {
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)
7041     } else {
7042       __pyx_v_deriv = ((int)0);
7043     }
7044     if (values[4]) {
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)
7046     } else {
7047       __pyx_v_rate = ((int)1);
7048     }
7049   }
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)
7053   __pyx_L3_error:;
7054   __Pyx_AddTraceback("MACS2.Signal.savitzky_golay", __pyx_clineno, __pyx_lineno, __pyx_filename);
7055   __Pyx_RefNannyFinishContext();
7056   return NULL;
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);
7060 
7061   /* function exit code */
7062   goto __pyx_L0;
7063   __pyx_L1_error:;
7064   __pyx_r = NULL;
7065   __pyx_L0:;
7066   __Pyx_RefNannyFinishContext();
7067   return __pyx_r;
7068 }
7069 
__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)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;
7084   {
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)
7087   }
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;
7096   __pyx_t_1 = 0;
7097   goto __pyx_L0;
7098 
7099   /* function exit code */
7100   __pyx_L1_error:;
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);
7109   __pyx_r = NULL;
7110   goto __pyx_L2;
7111   __pyx_L0:;
7112   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer);
7113   __pyx_L2:;
7114   __Pyx_XGIVEREF(__pyx_r);
7115   __Pyx_TraceReturn(__pyx_r, 0);
7116   __Pyx_RefNannyFinishContext();
7117   return __pyx_r;
7118 }
7119 
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.
7126  */
7127 
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*/
__pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject * __pyx_v_self,Py_buffer * __pyx_v_info,int __pyx_v_flags)7130 static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
7131   int __pyx_r;
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));
7135 
7136   /* function exit code */
7137   __Pyx_RefNannyFinishContext();
7138   return __pyx_r;
7139 }
7140 
__pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject * __pyx_v_self,Py_buffer * __pyx_v_info,int __pyx_v_flags)7141 static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
7142   int __pyx_v_i;
7143   int __pyx_v_ndim;
7144   int __pyx_v_endian_detector;
7145   int __pyx_v_little_endian;
7146   int __pyx_v_t;
7147   char *__pyx_v_f;
7148   PyArray_Descr *__pyx_v_descr = 0;
7149   int __pyx_v_offset;
7150   int __pyx_r;
7151   __Pyx_TraceDeclarations
7152   __Pyx_RefNannyDeclarations
7153   int __pyx_t_1;
7154   int __pyx_t_2;
7155   PyObject *__pyx_t_3 = NULL;
7156   int __pyx_t_4;
7157   int __pyx_t_5;
7158   int __pyx_t_6;
7159   PyArray_Descr *__pyx_t_7;
7160   PyObject *__pyx_t_8 = NULL;
7161   char *__pyx_t_9;
7162   if (__pyx_v_info == NULL) {
7163     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
7164     return -1;
7165   }
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));
7170 
7171   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":265
7172  *
7173  *             cdef int i, ndim
7174  *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
7175  *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
7176  *
7177  */
7178   __pyx_v_endian_detector = 1;
7179 
7180   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":266
7181  *             cdef int i, ndim
7182  *             cdef int endian_detector = 1
7183  *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
7184  *
7185  *             ndim = PyArray_NDIM(self)
7186  */
7187   __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
7188 
7189   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":268
7190  *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
7191  *
7192  *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
7193  *
7194  *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
7195  */
7196   __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);
7197 
7198   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":270
7199  *             ndim = PyArray_NDIM(self)
7200  *
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")
7204  */
7205   __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
7206   if (__pyx_t_2) {
7207   } else {
7208     __pyx_t_1 = __pyx_t_2;
7209     goto __pyx_L4_bool_binop_done;
7210   }
7211 
7212   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":271
7213  *
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")
7217  *
7218  */
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:;
7222 
7223   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":270
7224  *             ndim = PyArray_NDIM(self)
7225  *
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")
7229  */
7230   if (unlikely(__pyx_t_1)) {
7231 
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")             # <<<<<<<<<<<<<<
7236  *
7237  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
7238  */
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)
7244 
7245     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":270
7246  *             ndim = PyArray_NDIM(self)
7247  *
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")
7251  */
7252   }
7253 
7254   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":274
7255  *                 raise ValueError(u"ndarray is not C contiguous")
7256  *
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")
7260  */
7261   __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
7262   if (__pyx_t_2) {
7263   } else {
7264     __pyx_t_1 = __pyx_t_2;
7265     goto __pyx_L7_bool_binop_done;
7266   }
7267 
7268   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":275
7269  *
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")
7273  *
7274  */
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:;
7278 
7279   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":274
7280  *                 raise ValueError(u"ndarray is not C contiguous")
7281  *
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")
7285  */
7286   if (unlikely(__pyx_t_1)) {
7287 
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")             # <<<<<<<<<<<<<<
7292  *
7293  *             info.buf = PyArray_DATA(self)
7294  */
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)
7300 
7301     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":274
7302  *                 raise ValueError(u"ndarray is not C contiguous")
7303  *
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")
7307  */
7308   }
7309 
7310   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":278
7311  *                 raise ValueError(u"ndarray is not Fortran contiguous")
7312  *
7313  *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
7314  *             info.ndim = ndim
7315  *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
7316  */
7317   __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);
7318 
7319   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":279
7320  *
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.
7325  */
7326   __pyx_v_info->ndim = __pyx_v_ndim;
7327 
7328   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":280
7329  *             info.buf = PyArray_DATA(self)
7330  *             info.ndim = ndim
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.
7334  */
7335   __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
7336   if (__pyx_t_1) {
7337 
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):
7344  */
7345     __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim))));
7346 
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]
7353  */
7354     __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);
7355 
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]
7362  */
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;
7367 
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]
7373  *             else:
7374  */
7375       (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);
7376 
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]             # <<<<<<<<<<<<<<
7381  *             else:
7382  *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
7383  */
7384       (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
7385     }
7386 
7387     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":280
7388  *             info.buf = PyArray_DATA(self)
7389  *             info.ndim = ndim
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.
7393  */
7394     goto __pyx_L9;
7395   }
7396 
7397   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":289
7398  *                     info.shape[i] = PyArray_DIMS(self)[i]
7399  *             else:
7400  *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
7401  *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
7402  *             info.suboffsets = NULL
7403  */
7404   /*else*/ {
7405     __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));
7406 
7407     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":290
7408  *             else:
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)
7413  */
7414     __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
7415   }
7416   __pyx_L9:;
7417 
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)
7424  */
7425   __pyx_v_info->suboffsets = NULL;
7426 
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)
7432  *
7433  */
7434   __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);
7435 
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)             # <<<<<<<<<<<<<<
7440  *
7441  *             cdef int t
7442  */
7443   __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));
7444 
7445   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":296
7446  *
7447  *             cdef int t
7448  *             cdef char* f = NULL             # <<<<<<<<<<<<<<
7449  *             cdef dtype descr = <dtype>PyArray_DESCR(self)
7450  *             cdef int offset
7451  */
7452   __pyx_v_f = NULL;
7453 
7454   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":297
7455  *             cdef int t
7456  *             cdef char* f = NULL
7457  *             cdef dtype descr = <dtype>PyArray_DESCR(self)             # <<<<<<<<<<<<<<
7458  *             cdef int offset
7459  *
7460  */
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);
7465   __pyx_t_3 = 0;
7466 
7467   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":300
7468  *             cdef int offset
7469  *
7470  *             info.obj = self             # <<<<<<<<<<<<<<
7471  *
7472  *             if not PyDataType_HASFIELDS(descr):
7473  */
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);
7479 
7480   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":302
7481  *             info.obj = self
7482  *
7483  *             if not PyDataType_HASFIELDS(descr):             # <<<<<<<<<<<<<<
7484  *                 t = descr.type_num
7485  *                 if ((descr.byteorder == c'>' and little_endian) or
7486  */
7487   __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0);
7488   if (__pyx_t_1) {
7489 
7490     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":303
7491  *
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)):
7496  */
7497     __pyx_t_4 = __pyx_v_descr->type_num;
7498     __pyx_v_t = __pyx_t_4;
7499 
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")
7506  */
7507     __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
7508     if (!__pyx_t_2) {
7509       goto __pyx_L15_next_or;
7510     } else {
7511     }
7512     __pyx_t_2 = (__pyx_v_little_endian != 0);
7513     if (!__pyx_t_2) {
7514     } else {
7515       __pyx_t_1 = __pyx_t_2;
7516       goto __pyx_L14_bool_binop_done;
7517     }
7518     __pyx_L15_next_or:;
7519 
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"
7526  */
7527     __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
7528     if (__pyx_t_2) {
7529     } else {
7530       __pyx_t_1 = __pyx_t_2;
7531       goto __pyx_L14_bool_binop_done;
7532     }
7533     __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
7534     __pyx_t_1 = __pyx_t_2;
7535     __pyx_L14_bool_binop_done:;
7536 
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")
7543  */
7544     if (unlikely(__pyx_t_1)) {
7545 
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"
7552  */
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)
7558 
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")
7565  */
7566     }
7567 
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"
7574  */
7575     switch (__pyx_v_t) {
7576       case NPY_BYTE:
7577       __pyx_v_f = ((char *)"b");
7578       break;
7579       case NPY_UBYTE:
7580 
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"
7587  */
7588       __pyx_v_f = ((char *)"B");
7589       break;
7590       case NPY_SHORT:
7591 
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"
7598  */
7599       __pyx_v_f = ((char *)"h");
7600       break;
7601       case NPY_USHORT:
7602 
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"
7609  */
7610       __pyx_v_f = ((char *)"H");
7611       break;
7612       case NPY_INT:
7613 
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"
7620  */
7621       __pyx_v_f = ((char *)"i");
7622       break;
7623       case NPY_UINT:
7624 
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"
7631  */
7632       __pyx_v_f = ((char *)"I");
7633       break;
7634       case NPY_LONG:
7635 
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"
7642  */
7643       __pyx_v_f = ((char *)"l");
7644       break;
7645       case NPY_ULONG:
7646 
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"
7653  */
7654       __pyx_v_f = ((char *)"L");
7655       break;
7656       case NPY_LONGLONG:
7657 
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"
7664  */
7665       __pyx_v_f = ((char *)"q");
7666       break;
7667       case NPY_ULONGLONG:
7668 
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"
7675  */
7676       __pyx_v_f = ((char *)"Q");
7677       break;
7678       case NPY_FLOAT:
7679 
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"
7686  */
7687       __pyx_v_f = ((char *)"f");
7688       break;
7689       case NPY_DOUBLE:
7690 
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"
7697  */
7698       __pyx_v_f = ((char *)"d");
7699       break;
7700       case NPY_LONGDOUBLE:
7701 
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"
7708  */
7709       __pyx_v_f = ((char *)"g");
7710       break;
7711       case NPY_CFLOAT:
7712 
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"
7719  */
7720       __pyx_v_f = ((char *)"Zf");
7721       break;
7722       case NPY_CDOUBLE:
7723 
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"
7730  */
7731       __pyx_v_f = ((char *)"Zd");
7732       break;
7733       case NPY_CLONGDOUBLE:
7734 
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"
7740  *                 else:
7741  */
7742       __pyx_v_f = ((char *)"Zg");
7743       break;
7744       case NPY_OBJECT:
7745 
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"             # <<<<<<<<<<<<<<
7750  *                 else:
7751  *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
7752  */
7753       __pyx_v_f = ((char *)"O");
7754       break;
7755       default:
7756 
7757       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":325
7758  *                 elif t == NPY_OBJECT:      f = "O"
7759  *                 else:
7760  *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
7761  *                 info.format = f
7762  *                 return
7763  */
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)
7775       break;
7776     }
7777 
7778     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":326
7779  *                 else:
7780  *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
7781  *                 info.format = f             # <<<<<<<<<<<<<<
7782  *                 return
7783  *             else:
7784  */
7785     __pyx_v_info->format = __pyx_v_f;
7786 
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)
7789  *                 info.format = f
7790  *                 return             # <<<<<<<<<<<<<<
7791  *             else:
7792  *                 info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
7793  */
7794     __pyx_r = 0;
7795     goto __pyx_L0;
7796 
7797     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":302
7798  *             info.obj = self
7799  *
7800  *             if not PyDataType_HASFIELDS(descr):             # <<<<<<<<<<<<<<
7801  *                 t = descr.type_num
7802  *                 if ((descr.byteorder == c'>' and little_endian) or
7803  */
7804   }
7805 
7806   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":329
7807  *                 return
7808  *             else:
7809  *                 info.format = <char*>PyObject_Malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
7810  *                 info.format[0] = c'^' # Native data types, manual alignment
7811  *                 offset = 0
7812  */
7813   /*else*/ {
7814     __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF));
7815 
7816     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":330
7817  *             else:
7818  *                 info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
7819  *                 info.format[0] = c'^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
7820  *                 offset = 0
7821  *                 f = _util_dtypestring(descr, info.format + 1,
7822  */
7823     (__pyx_v_info->format[0]) = '^';
7824 
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,
7831  */
7832     __pyx_v_offset = 0;
7833 
7834     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":332
7835  *                 info.format[0] = c'^' # Native data types, manual alignment
7836  *                 offset = 0
7837  *                 f = _util_dtypestring(descr, info.format + 1,             # <<<<<<<<<<<<<<
7838  *                                       info.format + _buffer_format_string_len,
7839  *                                       &offset)
7840  */
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;
7843 
7844     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":335
7845  *                                       info.format + _buffer_format_string_len,
7846  *                                       &offset)
7847  *                 f[0] = c'\0' # Terminate format string             # <<<<<<<<<<<<<<
7848  *
7849  *         def __releasebuffer__(ndarray self, Py_buffer* info):
7850  */
7851     (__pyx_v_f[0]) = '\x00';
7852   }
7853 
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.
7860  */
7861 
7862   /* function exit code */
7863   __pyx_r = 0;
7864   goto __pyx_L0;
7865   __pyx_L1_error:;
7866   __Pyx_XDECREF(__pyx_t_3);
7867   __Pyx_XDECREF(__pyx_t_8);
7868   __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
7869   __pyx_r = -1;
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;
7873   }
7874   goto __pyx_L2;
7875   __pyx_L0:;
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;
7879   }
7880   __pyx_L2:;
7881   __Pyx_XDECREF((PyObject *)__pyx_v_descr);
7882   __Pyx_TraceReturn(Py_None, 0);
7883   __Pyx_RefNannyFinishContext();
7884   return __pyx_r;
7885 }
7886 
7887 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":337
7888  *                 f[0] = c'\0' # Terminate format string
7889  *
7890  *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
7891  *             if PyArray_HASFIELDS(self):
7892  *                 PyObject_Free(info.format)
7893  */
7894 
7895 /* Python wrapper */
7896 static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
__pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject * __pyx_v_self,Py_buffer * __pyx_v_info)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));
7901 
7902   /* function exit code */
7903   __Pyx_RefNannyFinishContext();
7904 }
7905 
__pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject * __pyx_v_self,Py_buffer * __pyx_v_info)7906 static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
7907   __Pyx_TraceDeclarations
7908   __Pyx_RefNannyDeclarations
7909   int __pyx_t_1;
7910   __Pyx_RefNannySetupContext("__releasebuffer__", 0);
7911   __Pyx_TraceCall("__releasebuffer__", __pyx_f[1], 337, 0, __PYX_ERR(1, 337, __pyx_L1_error));
7912 
7913   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":338
7914  *
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):
7919  */
7920   __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
7921   if (__pyx_t_1) {
7922 
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)
7929  */
7930     PyObject_Free(__pyx_v_info->format);
7931 
7932     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":338
7933  *
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):
7938  */
7939   }
7940 
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
7947  */
7948   __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
7949   if (__pyx_t_1) {
7950 
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
7956  *
7957  */
7958     PyObject_Free(__pyx_v_info->strides);
7959 
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
7966  */
7967   }
7968 
7969   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":337
7970  *                 f[0] = c'\0' # Terminate format string
7971  *
7972  *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
7973  *             if PyArray_HASFIELDS(self):
7974  *                 PyObject_Free(info.format)
7975  */
7976 
7977   /* function exit code */
7978   goto __pyx_L0;
7979   __pyx_L1_error:;
7980   __Pyx_WriteUnraisable("numpy.ndarray.__releasebuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7981   __pyx_L0:;
7982   __Pyx_TraceReturn(Py_None, 0);
7983   __Pyx_RefNannyFinishContext();
7984 }
7985 
7986 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":821
7987  * ctypedef npy_cdouble     complex_t
7988  *
7989  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
7990  *     return PyArray_MultiIterNew(1, <void*>a)
7991  *
7992  */
7993 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_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));
8001 
8002   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":822
8003  *
8004  * cdef inline object PyArray_MultiIterNew1(a):
8005  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
8006  *
8007  * cdef inline object PyArray_MultiIterNew2(a, b):
8008  */
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;
8013   __pyx_t_1 = 0;
8014   goto __pyx_L0;
8015 
8016   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":821
8017  * ctypedef npy_cdouble     complex_t
8018  *
8019  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
8020  *     return PyArray_MultiIterNew(1, <void*>a)
8021  *
8022  */
8023 
8024   /* function exit code */
8025   __pyx_L1_error:;
8026   __Pyx_XDECREF(__pyx_t_1);
8027   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
8028   __pyx_r = 0;
8029   __pyx_L0:;
8030   __Pyx_XGIVEREF(__pyx_r);
8031   __Pyx_TraceReturn(__pyx_r, 0);
8032   __Pyx_RefNannyFinishContext();
8033   return __pyx_r;
8034 }
8035 
8036 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":824
8037  *     return PyArray_MultiIterNew(1, <void*>a)
8038  *
8039  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
8040  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8041  *
8042  */
8043 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_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));
8051 
8052   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":825
8053  *
8054  * cdef inline object PyArray_MultiIterNew2(a, b):
8055  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
8056  *
8057  * cdef inline object PyArray_MultiIterNew3(a, b, c):
8058  */
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;
8063   __pyx_t_1 = 0;
8064   goto __pyx_L0;
8065 
8066   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":824
8067  *     return PyArray_MultiIterNew(1, <void*>a)
8068  *
8069  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
8070  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8071  *
8072  */
8073 
8074   /* function exit code */
8075   __pyx_L1_error:;
8076   __Pyx_XDECREF(__pyx_t_1);
8077   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
8078   __pyx_r = 0;
8079   __pyx_L0:;
8080   __Pyx_XGIVEREF(__pyx_r);
8081   __Pyx_TraceReturn(__pyx_r, 0);
8082   __Pyx_RefNannyFinishContext();
8083   return __pyx_r;
8084 }
8085 
8086 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":827
8087  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8088  *
8089  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
8090  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
8091  *
8092  */
8093 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_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));
8101 
8102   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":828
8103  *
8104  * cdef inline object PyArray_MultiIterNew3(a, b, c):
8105  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
8106  *
8107  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
8108  */
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;
8113   __pyx_t_1 = 0;
8114   goto __pyx_L0;
8115 
8116   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":827
8117  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
8118  *
8119  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
8120  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
8121  *
8122  */
8123 
8124   /* function exit code */
8125   __pyx_L1_error:;
8126   __Pyx_XDECREF(__pyx_t_1);
8127   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
8128   __pyx_r = 0;
8129   __pyx_L0:;
8130   __Pyx_XGIVEREF(__pyx_r);
8131   __Pyx_TraceReturn(__pyx_r, 0);
8132   __Pyx_RefNannyFinishContext();
8133   return __pyx_r;
8134 }
8135 
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)
8138  *
8139  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
8140  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
8141  *
8142  */
8143 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_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));
8151 
8152   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":831
8153  *
8154  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
8155  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
8156  *
8157  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
8158  */
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;
8163   __pyx_t_1 = 0;
8164   goto __pyx_L0;
8165 
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)
8168  *
8169  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
8170  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
8171  *
8172  */
8173 
8174   /* function exit code */
8175   __pyx_L1_error:;
8176   __Pyx_XDECREF(__pyx_t_1);
8177   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
8178   __pyx_r = 0;
8179   __pyx_L0:;
8180   __Pyx_XGIVEREF(__pyx_r);
8181   __Pyx_TraceReturn(__pyx_r, 0);
8182   __Pyx_RefNannyFinishContext();
8183   return __pyx_r;
8184 }
8185 
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)
8188  *
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)
8191  *
8192  */
8193 
__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)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));
8201 
8202   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":834
8203  *
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)             # <<<<<<<<<<<<<<
8206  *
8207  * cdef inline tuple PyDataType_SHAPE(dtype d):
8208  */
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;
8213   __pyx_t_1 = 0;
8214   goto __pyx_L0;
8215 
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)
8218  *
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)
8221  *
8222  */
8223 
8224   /* function exit code */
8225   __pyx_L1_error:;
8226   __Pyx_XDECREF(__pyx_t_1);
8227   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
8228   __pyx_r = 0;
8229   __pyx_L0:;
8230   __Pyx_XGIVEREF(__pyx_r);
8231   __Pyx_TraceReturn(__pyx_r, 0);
8232   __Pyx_RefNannyFinishContext();
8233   return __pyx_r;
8234 }
8235 
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)
8238  *
8239  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
8240  *     if PyDataType_HASSUBARRAY(d):
8241  *         return <tuple>d.subarray.shape
8242  */
8243 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)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
8248   int __pyx_t_1;
8249   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
8250   __Pyx_TraceCall("PyDataType_SHAPE", __pyx_f[1], 836, 0, __PYX_ERR(1, 836, __pyx_L1_error));
8251 
8252   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":837
8253  *
8254  * cdef inline tuple PyDataType_SHAPE(dtype d):
8255  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
8256  *         return <tuple>d.subarray.shape
8257  *     else:
8258  */
8259   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
8260   if (__pyx_t_1) {
8261 
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             # <<<<<<<<<<<<<<
8266  *     else:
8267  *         return ()
8268  */
8269     __Pyx_XDECREF(__pyx_r);
8270     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
8271     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
8272     goto __pyx_L0;
8273 
8274     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":837
8275  *
8276  * cdef inline tuple PyDataType_SHAPE(dtype d):
8277  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
8278  *         return <tuple>d.subarray.shape
8279  *     else:
8280  */
8281   }
8282 
8283   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":840
8284  *         return <tuple>d.subarray.shape
8285  *     else:
8286  *         return ()             # <<<<<<<<<<<<<<
8287  *
8288  * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
8289  */
8290   /*else*/ {
8291     __Pyx_XDECREF(__pyx_r);
8292     __Pyx_INCREF(__pyx_empty_tuple);
8293     __pyx_r = __pyx_empty_tuple;
8294     goto __pyx_L0;
8295   }
8296 
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)
8299  *
8300  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
8301  *     if PyDataType_HASSUBARRAY(d):
8302  *         return <tuple>d.subarray.shape
8303  */
8304 
8305   /* function exit code */
8306   __pyx_L1_error:;
8307   __Pyx_AddTraceback("numpy.PyDataType_SHAPE", __pyx_clineno, __pyx_lineno, __pyx_filename);
8308   __pyx_r = 0;
8309   __pyx_L0:;
8310   __Pyx_XGIVEREF(__pyx_r);
8311   __Pyx_TraceReturn(__pyx_r, 0);
8312   __Pyx_RefNannyFinishContext();
8313   return __pyx_r;
8314 }
8315 
8316 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":842
8317  *         return ()
8318  *
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.
8322  */
8323 
__pyx_f_5numpy__util_dtypestring(PyArray_Descr * __pyx_v_descr,char * __pyx_v_f,char * __pyx_v_end,int * __pyx_v_offset)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;
8332   char *__pyx_r;
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;
8339   int __pyx_t_5;
8340   int __pyx_t_6;
8341   int __pyx_t_7;
8342   long __pyx_t_8;
8343   char *__pyx_t_9;
8344   __Pyx_RefNannySetupContext("_util_dtypestring", 0);
8345   __Pyx_TraceCall("_util_dtypestring", __pyx_f[1], 842, 0, __PYX_ERR(1, 842, __pyx_L1_error));
8346 
8347   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":847
8348  *
8349  *     cdef dtype child
8350  *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
8351  *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
8352  *     cdef tuple fields
8353  */
8354   __pyx_v_endian_detector = 1;
8355 
8356   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":848
8357  *     cdef dtype child
8358  *     cdef int endian_detector = 1
8359  *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
8360  *     cdef tuple fields
8361  *
8362  */
8363   __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
8364 
8365   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":851
8366  *     cdef tuple fields
8367  *
8368  *     for childname in descr.names:             # <<<<<<<<<<<<<<
8369  *         fields = descr.fields[childname]
8370  *         child, new_offset = fields
8371  */
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)
8375   }
8376   __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
8377   for (;;) {
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)
8381     #else
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);
8384     #endif
8385     __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
8386     __pyx_t_3 = 0;
8387 
8388     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":852
8389  *
8390  *     for childname in descr.names:
8391  *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
8392  *         child, new_offset = fields
8393  *
8394  */
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)
8398     }
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));
8403     __pyx_t_3 = 0;
8404 
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             # <<<<<<<<<<<<<<
8409  *
8410  *         if (end - f) - <int>(new_offset - offset[0]) < 15:
8411  */
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)
8419       }
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);
8425       #else
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);
8430       #endif
8431     } else {
8432       __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 853, __pyx_L1_error)
8433     }
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));
8436     __pyx_t_3 = 0;
8437     __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
8438     __pyx_t_4 = 0;
8439 
8440     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":855
8441  *         child, new_offset = fields
8442  *
8443  *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
8444  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
8445  *
8446  */
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)) {
8456 
8457       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":856
8458  *
8459  *         if (end - f) - <int>(new_offset - offset[0]) < 15:
8460  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
8461  *
8462  *         if ((child.byteorder == c'>' and little_endian) or
8463  */
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)
8469 
8470       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":855
8471  *         child, new_offset = fields
8472  *
8473  *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
8474  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
8475  *
8476  */
8477     }
8478 
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")
8481  *
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")
8485  */
8486     __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
8487     if (!__pyx_t_7) {
8488       goto __pyx_L8_next_or;
8489     } else {
8490     }
8491     __pyx_t_7 = (__pyx_v_little_endian != 0);
8492     if (!__pyx_t_7) {
8493     } else {
8494       __pyx_t_6 = __pyx_t_7;
8495       goto __pyx_L7_bool_binop_done;
8496     }
8497     __pyx_L8_next_or:;
8498 
8499     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":859
8500  *
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
8505  */
8506     __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
8507     if (__pyx_t_7) {
8508     } else {
8509       __pyx_t_6 = __pyx_t_7;
8510       goto __pyx_L7_bool_binop_done;
8511     }
8512     __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
8513     __pyx_t_6 = __pyx_t_7;
8514     __pyx_L7_bool_binop_done:;
8515 
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")
8518  *
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")
8522  */
8523     if (unlikely(__pyx_t_6)) {
8524 
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
8531  */
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)
8537 
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")
8540  *
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")
8544  */
8545     }
8546 
8547     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":870
8548  *
8549  *         # Output padding bytes
8550  *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
8551  *             f[0] = 120 # "x"; pad byte
8552  *             f += 1
8553  */
8554     while (1) {
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;
8562 
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             # <<<<<<<<<<<<<<
8567  *             f += 1
8568  *             offset[0] += 1
8569  */
8570       (__pyx_v_f[0]) = 0x78;
8571 
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             # <<<<<<<<<<<<<<
8576  *             offset[0] += 1
8577  *
8578  */
8579       __pyx_v_f = (__pyx_v_f + 1);
8580 
8581       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":873
8582  *             f[0] = 120 # "x"; pad byte
8583  *             f += 1
8584  *             offset[0] += 1             # <<<<<<<<<<<<<<
8585  *
8586  *         offset[0] += child.itemsize
8587  */
8588       __pyx_t_8 = 0;
8589       (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
8590     }
8591 
8592     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":875
8593  *             offset[0] += 1
8594  *
8595  *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
8596  *
8597  *         if not PyDataType_HASFIELDS(child):
8598  */
8599     __pyx_t_8 = 0;
8600     (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);
8601 
8602     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":877
8603  *         offset[0] += child.itemsize
8604  *
8605  *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
8606  *             t = child.type_num
8607  *             if end - f < 5:
8608  */
8609     __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
8610     if (__pyx_t_6) {
8611 
8612       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":878
8613  *
8614  *         if not PyDataType_HASFIELDS(child):
8615  *             t = child.type_num             # <<<<<<<<<<<<<<
8616  *             if end - f < 5:
8617  *                 raise RuntimeError(u"Format string allocated too short.")
8618  */
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);
8622       __pyx_t_4 = 0;
8623 
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.")
8629  *
8630  */
8631       __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
8632       if (unlikely(__pyx_t_6)) {
8633 
8634         /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":880
8635  *             t = child.type_num
8636  *             if end - f < 5:
8637  *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
8638  *
8639  *             # Until ticket #99 is fixed, use integers to avoid warnings
8640  */
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)
8646 
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.")
8652  *
8653  */
8654       }
8655 
8656       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":883
8657  *
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"
8662  */
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;
8669       if (__pyx_t_6) {
8670         (__pyx_v_f[0]) = 98;
8671         goto __pyx_L15;
8672       }
8673 
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"
8680  */
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;
8687       if (__pyx_t_6) {
8688         (__pyx_v_f[0]) = 66;
8689         goto __pyx_L15;
8690       }
8691 
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"
8698  */
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;
8705       if (__pyx_t_6) {
8706         (__pyx_v_f[0]) = 0x68;
8707         goto __pyx_L15;
8708       }
8709 
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"
8716  */
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;
8723       if (__pyx_t_6) {
8724         (__pyx_v_f[0]) = 72;
8725         goto __pyx_L15;
8726       }
8727 
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"
8734  */
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;
8741       if (__pyx_t_6) {
8742         (__pyx_v_f[0]) = 0x69;
8743         goto __pyx_L15;
8744       }
8745 
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"
8752  */
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;
8759       if (__pyx_t_6) {
8760         (__pyx_v_f[0]) = 73;
8761         goto __pyx_L15;
8762       }
8763 
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"
8770  */
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;
8777       if (__pyx_t_6) {
8778         (__pyx_v_f[0]) = 0x6C;
8779         goto __pyx_L15;
8780       }
8781 
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"
8788  */
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;
8795       if (__pyx_t_6) {
8796         (__pyx_v_f[0]) = 76;
8797         goto __pyx_L15;
8798       }
8799 
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"
8806  */
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;
8813       if (__pyx_t_6) {
8814         (__pyx_v_f[0]) = 0x71;
8815         goto __pyx_L15;
8816       }
8817 
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"
8824  */
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;
8831       if (__pyx_t_6) {
8832         (__pyx_v_f[0]) = 81;
8833         goto __pyx_L15;
8834       }
8835 
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"
8842  */
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;
8849       if (__pyx_t_6) {
8850         (__pyx_v_f[0]) = 0x66;
8851         goto __pyx_L15;
8852       }
8853 
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
8860  */
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;
8867       if (__pyx_t_6) {
8868         (__pyx_v_f[0]) = 0x64;
8869         goto __pyx_L15;
8870       }
8871 
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
8878  */
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;
8885       if (__pyx_t_6) {
8886         (__pyx_v_f[0]) = 0x67;
8887         goto __pyx_L15;
8888       }
8889 
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
8896  */
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;
8903       if (__pyx_t_6) {
8904         (__pyx_v_f[0]) = 90;
8905         (__pyx_v_f[1]) = 0x66;
8906         __pyx_v_f = (__pyx_v_f + 1);
8907         goto __pyx_L15;
8908       }
8909 
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"
8916  */
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;
8923       if (__pyx_t_6) {
8924         (__pyx_v_f[0]) = 90;
8925         (__pyx_v_f[1]) = 0x64;
8926         __pyx_v_f = (__pyx_v_f + 1);
8927         goto __pyx_L15;
8928       }
8929 
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"
8935  *             else:
8936  */
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;
8943       if (__pyx_t_6) {
8944         (__pyx_v_f[0]) = 90;
8945         (__pyx_v_f[1]) = 0x67;
8946         __pyx_v_f = (__pyx_v_f + 1);
8947         goto __pyx_L15;
8948       }
8949 
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"             # <<<<<<<<<<<<<<
8954  *             else:
8955  *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
8956  */
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;
8965         goto __pyx_L15;
8966       }
8967 
8968       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":901
8969  *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
8970  *             else:
8971  *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
8972  *             f += 1
8973  *         else:
8974  */
8975       /*else*/ {
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)
8984       }
8985       __pyx_L15:;
8986 
8987       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":902
8988  *             else:
8989  *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
8990  *             f += 1             # <<<<<<<<<<<<<<
8991  *         else:
8992  *             # Cython ignores struct boundary information ("T{...}"),
8993  */
8994       __pyx_v_f = (__pyx_v_f + 1);
8995 
8996       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":877
8997  *         offset[0] += child.itemsize
8998  *
8999  *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
9000  *             t = child.type_num
9001  *             if end - f < 5:
9002  */
9003       goto __pyx_L13;
9004     }
9005 
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)             # <<<<<<<<<<<<<<
9010  *     return f
9011  *
9012  */
9013     /*else*/ {
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;
9016     }
9017     __pyx_L13:;
9018 
9019     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":851
9020  *     cdef tuple fields
9021  *
9022  *     for childname in descr.names:             # <<<<<<<<<<<<<<
9023  *         fields = descr.fields[childname]
9024  *         child, new_offset = fields
9025  */
9026   }
9027   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9028 
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             # <<<<<<<<<<<<<<
9033  *
9034  *
9035  */
9036   __pyx_r = __pyx_v_f;
9037   goto __pyx_L0;
9038 
9039   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":842
9040  *         return ()
9041  *
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.
9045  */
9046 
9047   /* function exit code */
9048   __pyx_L1_error:;
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);
9053   __pyx_r = NULL;
9054   __pyx_L0:;
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();
9062   return __pyx_r;
9063 }
9064 
9065 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1022
9066  *     int _import_umath() except -1
9067  *
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)
9071  */
9072 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_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));
9078 
9079   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1023
9080  *
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)
9084  *
9085  */
9086   Py_INCREF(__pyx_v_base);
9087 
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)             # <<<<<<<<<<<<<<
9092  *
9093  * cdef inline object get_array_base(ndarray arr):
9094  */
9095   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
9096 
9097   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1022
9098  *     int _import_umath() except -1
9099  *
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)
9103  */
9104 
9105   /* function exit code */
9106   goto __pyx_L0;
9107   __pyx_L1_error:;
9108   __Pyx_WriteUnraisable("numpy.set_array_base", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
9109   __pyx_L0:;
9110   __Pyx_TraceReturn(Py_None, 0);
9111   __Pyx_RefNannyFinishContext();
9112 }
9113 
9114 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1026
9115  *     PyArray_SetBaseObject(arr, base)
9116  *
9117  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
9118  *     base = PyArray_BASE(arr)
9119  *     if base is NULL:
9120  */
9121 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_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
9127   int __pyx_t_1;
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));
9130 
9131   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1027
9132  *
9133  * cdef inline object get_array_base(ndarray arr):
9134  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
9135  *     if base is NULL:
9136  *         return None
9137  */
9138   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
9139 
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:             # <<<<<<<<<<<<<<
9144  *         return None
9145  *     return <object>base
9146  */
9147   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
9148   if (__pyx_t_1) {
9149 
9150     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1029
9151  *     base = PyArray_BASE(arr)
9152  *     if base is NULL:
9153  *         return None             # <<<<<<<<<<<<<<
9154  *     return <object>base
9155  *
9156  */
9157     __Pyx_XDECREF(__pyx_r);
9158     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
9159     goto __pyx_L0;
9160 
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:             # <<<<<<<<<<<<<<
9165  *         return None
9166  *     return <object>base
9167  */
9168   }
9169 
9170   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1030
9171  *     if base is NULL:
9172  *         return None
9173  *     return <object>base             # <<<<<<<<<<<<<<
9174  *
9175  * # Versions of the import_* functions which are more suitable for
9176  */
9177   __Pyx_XDECREF(__pyx_r);
9178   __Pyx_INCREF(((PyObject *)__pyx_v_base));
9179   __pyx_r = ((PyObject *)__pyx_v_base);
9180   goto __pyx_L0;
9181 
9182   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1026
9183  *     PyArray_SetBaseObject(arr, base)
9184  *
9185  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
9186  *     base = PyArray_BASE(arr)
9187  *     if base is NULL:
9188  */
9189 
9190   /* function exit code */
9191   __pyx_L1_error:;
9192   __Pyx_AddTraceback("numpy.get_array_base", __pyx_clineno, __pyx_lineno, __pyx_filename);
9193   __pyx_r = 0;
9194   __pyx_L0:;
9195   __Pyx_XGIVEREF(__pyx_r);
9196   __Pyx_TraceReturn(__pyx_r, 0);
9197   __Pyx_RefNannyFinishContext();
9198   return __pyx_r;
9199 }
9200 
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
9203  * # Cython code.
9204  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
9205  *     try:
9206  *         _import_array()
9207  */
9208 
__pyx_f_5numpy_import_array(void)9209 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
9210   int __pyx_r;
9211   __Pyx_TraceDeclarations
9212   __Pyx_RefNannyDeclarations
9213   PyObject *__pyx_t_1 = NULL;
9214   PyObject *__pyx_t_2 = NULL;
9215   PyObject *__pyx_t_3 = NULL;
9216   int __pyx_t_4;
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));
9223 
9224   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1035
9225  * # Cython code.
9226  * cdef inline int import_array() except -1:
9227  *     try:             # <<<<<<<<<<<<<<
9228  *         _import_array()
9229  *     except Exception:
9230  */
9231   {
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);
9238     /*try:*/ {
9239 
9240       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1036
9241  * cdef inline int import_array() except -1:
9242  *     try:
9243  *         _import_array()             # <<<<<<<<<<<<<<
9244  *     except Exception:
9245  *         raise ImportError("numpy.core.multiarray failed to import")
9246  */
9247       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1036, __pyx_L3_error)
9248 
9249       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1035
9250  * # Cython code.
9251  * cdef inline int import_array() except -1:
9252  *     try:             # <<<<<<<<<<<<<<
9253  *         _import_array()
9254  *     except Exception:
9255  */
9256     }
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;
9261     __pyx_L3_error:;
9262 
9263     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1037
9264  *     try:
9265  *         _import_array()
9266  *     except Exception:             # <<<<<<<<<<<<<<
9267  *         raise ImportError("numpy.core.multiarray failed to import")
9268  *
9269  */
9270     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
9271     if (__pyx_t_4) {
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);
9277 
9278       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1038
9279  *         _import_array()
9280  *     except Exception:
9281  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
9282  *
9283  * cdef inline int import_umath() except -1:
9284  */
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)
9290     }
9291     goto __pyx_L5_except_error;
9292     __pyx_L5_except_error:;
9293 
9294     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1035
9295  * # Cython code.
9296  * cdef inline int import_array() except -1:
9297  *     try:             # <<<<<<<<<<<<<<
9298  *         _import_array()
9299  *     except Exception:
9300  */
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;
9306     __pyx_L8_try_end:;
9307   }
9308 
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
9311  * # Cython code.
9312  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
9313  *     try:
9314  *         _import_array()
9315  */
9316 
9317   /* function exit code */
9318   __pyx_r = 0;
9319   goto __pyx_L0;
9320   __pyx_L1_error:;
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);
9326   __pyx_r = -1;
9327   __pyx_L0:;
9328   __Pyx_TraceReturn(Py_None, 0);
9329   __Pyx_RefNannyFinishContext();
9330   return __pyx_r;
9331 }
9332 
9333 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1040
9334  *         raise ImportError("numpy.core.multiarray failed to import")
9335  *
9336  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
9337  *     try:
9338  *         _import_umath()
9339  */
9340 
__pyx_f_5numpy_import_umath(void)9341 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
9342   int __pyx_r;
9343   __Pyx_TraceDeclarations
9344   __Pyx_RefNannyDeclarations
9345   PyObject *__pyx_t_1 = NULL;
9346   PyObject *__pyx_t_2 = NULL;
9347   PyObject *__pyx_t_3 = NULL;
9348   int __pyx_t_4;
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));
9355 
9356   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1041
9357  *
9358  * cdef inline int import_umath() except -1:
9359  *     try:             # <<<<<<<<<<<<<<
9360  *         _import_umath()
9361  *     except Exception:
9362  */
9363   {
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);
9370     /*try:*/ {
9371 
9372       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1042
9373  * cdef inline int import_umath() except -1:
9374  *     try:
9375  *         _import_umath()             # <<<<<<<<<<<<<<
9376  *     except Exception:
9377  *         raise ImportError("numpy.core.umath failed to import")
9378  */
9379       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1042, __pyx_L3_error)
9380 
9381       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1041
9382  *
9383  * cdef inline int import_umath() except -1:
9384  *     try:             # <<<<<<<<<<<<<<
9385  *         _import_umath()
9386  *     except Exception:
9387  */
9388     }
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;
9393     __pyx_L3_error:;
9394 
9395     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1043
9396  *     try:
9397  *         _import_umath()
9398  *     except Exception:             # <<<<<<<<<<<<<<
9399  *         raise ImportError("numpy.core.umath failed to import")
9400  *
9401  */
9402     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
9403     if (__pyx_t_4) {
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);
9409 
9410       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1044
9411  *         _import_umath()
9412  *     except Exception:
9413  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
9414  *
9415  * cdef inline int import_ufunc() except -1:
9416  */
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)
9422     }
9423     goto __pyx_L5_except_error;
9424     __pyx_L5_except_error:;
9425 
9426     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1041
9427  *
9428  * cdef inline int import_umath() except -1:
9429  *     try:             # <<<<<<<<<<<<<<
9430  *         _import_umath()
9431  *     except Exception:
9432  */
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;
9438     __pyx_L8_try_end:;
9439   }
9440 
9441   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1040
9442  *         raise ImportError("numpy.core.multiarray failed to import")
9443  *
9444  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
9445  *     try:
9446  *         _import_umath()
9447  */
9448 
9449   /* function exit code */
9450   __pyx_r = 0;
9451   goto __pyx_L0;
9452   __pyx_L1_error:;
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);
9458   __pyx_r = -1;
9459   __pyx_L0:;
9460   __Pyx_TraceReturn(Py_None, 0);
9461   __Pyx_RefNannyFinishContext();
9462   return __pyx_r;
9463 }
9464 
9465 /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1046
9466  *         raise ImportError("numpy.core.umath failed to import")
9467  *
9468  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
9469  *     try:
9470  *         _import_umath()
9471  */
9472 
__pyx_f_5numpy_import_ufunc(void)9473 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
9474   int __pyx_r;
9475   __Pyx_TraceDeclarations
9476   __Pyx_RefNannyDeclarations
9477   PyObject *__pyx_t_1 = NULL;
9478   PyObject *__pyx_t_2 = NULL;
9479   PyObject *__pyx_t_3 = NULL;
9480   int __pyx_t_4;
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));
9487 
9488   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1047
9489  *
9490  * cdef inline int import_ufunc() except -1:
9491  *     try:             # <<<<<<<<<<<<<<
9492  *         _import_umath()
9493  *     except Exception:
9494  */
9495   {
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);
9502     /*try:*/ {
9503 
9504       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1048
9505  * cdef inline int import_ufunc() except -1:
9506  *     try:
9507  *         _import_umath()             # <<<<<<<<<<<<<<
9508  *     except Exception:
9509  *         raise ImportError("numpy.core.umath failed to import")
9510  */
9511       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1048, __pyx_L3_error)
9512 
9513       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1047
9514  *
9515  * cdef inline int import_ufunc() except -1:
9516  *     try:             # <<<<<<<<<<<<<<
9517  *         _import_umath()
9518  *     except Exception:
9519  */
9520     }
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;
9525     __pyx_L3_error:;
9526 
9527     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1049
9528  *     try:
9529  *         _import_umath()
9530  *     except Exception:             # <<<<<<<<<<<<<<
9531  *         raise ImportError("numpy.core.umath failed to import")
9532  */
9533     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
9534     if (__pyx_t_4) {
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);
9540 
9541       /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1050
9542  *         _import_umath()
9543  *     except Exception:
9544  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
9545  */
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)
9551     }
9552     goto __pyx_L5_except_error;
9553     __pyx_L5_except_error:;
9554 
9555     /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1047
9556  *
9557  * cdef inline int import_ufunc() except -1:
9558  *     try:             # <<<<<<<<<<<<<<
9559  *         _import_umath()
9560  *     except Exception:
9561  */
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;
9567     __pyx_L8_try_end:;
9568   }
9569 
9570   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1046
9571  *         raise ImportError("numpy.core.umath failed to import")
9572  *
9573  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
9574  *     try:
9575  *         _import_umath()
9576  */
9577 
9578   /* function exit code */
9579   __pyx_r = 0;
9580   goto __pyx_L0;
9581   __pyx_L1_error:;
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);
9587   __pyx_r = -1;
9588   __pyx_L0:;
9589   __Pyx_TraceReturn(Py_None, 0);
9590   __Pyx_RefNannyFinishContext();
9591   return __pyx_r;
9592 }
9593 
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},
9600   {0, 0, 0, 0}
9601 };
9602 
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},
9610   {0, NULL}
9611 };
9612 #endif
9613 
9614 static struct PyModuleDef __pyx_moduledef = {
9615     PyModuleDef_HEAD_INIT,
9616     "Signal",
9617     __pyx_k_Module_Description_functions_to, /* m_doc */
9618   #if CYTHON_PEP489_MULTI_PHASE_INIT
9619     0, /* m_size */
9620   #else
9621     -1, /* m_size */
9622   #endif
9623     __pyx_methods /* m_methods */,
9624   #if CYTHON_PEP489_MULTI_PHASE_INIT
9625     __pyx_moduledef_slots, /* m_slots */
9626   #else
9627     NULL, /* m_reload */
9628   #endif
9629     NULL, /* m_traverse */
9630     NULL, /* m_clear */
9631     NULL /* m_free */
9632 };
9633 #endif
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))
9639 #else
9640     #define CYTHON_SMALL_CODE
9641 #endif
9642 #endif
9643 
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}
9710 };
__Pyx_InitCachedBuiltins(void)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)
9717   return 0;
9718   __pyx_L1_error:;
9719   return -1;
9720 }
9721 
__Pyx_InitCachedConstants(void)9722 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
9723   __Pyx_RefNannyDeclarations
9724   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
9725 
9726   /* "MACS2/Signal.pyx":44
9727  *         int i, v, v2
9728  *     if n == 0 or n == 1:
9729  *         ret = np.ndarray(0, 'int32')             # <<<<<<<<<<<<<<
9730  *         return ret
9731  *     else:
9732  */
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_);
9736 
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))
9743  */
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);
9747 
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")
9754  */
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);
9758 
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")
9765  */
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);
9769 
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
9776  */
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);
9780 
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")             # <<<<<<<<<<<<<<
9785  *
9786  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
9787  */
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);
9791 
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")             # <<<<<<<<<<<<<<
9796  *
9797  *             info.buf = PyArray_DATA(self)
9798  */
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);
9802 
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"
9809  */
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);
9813 
9814   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":856
9815  *
9816  *         if (end - f) - <int>(new_offset - offset[0]) < 15:
9817  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
9818  *
9819  *         if ((child.byteorder == c'>' and little_endian) or
9820  */
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);
9824 
9825   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":880
9826  *             t = child.type_num
9827  *             if end - f < 5:
9828  *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
9829  *
9830  *             # Until ticket #99 is fixed, use integers to avoid warnings
9831  */
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);
9835 
9836   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1038
9837  *         _import_array()
9838  *     except Exception:
9839  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
9840  *
9841  * cdef inline int import_umath() except -1:
9842  */
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);
9846 
9847   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1044
9848  *         _import_umath()
9849  *     except Exception:
9850  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
9851  *
9852  * cdef inline int import_ufunc() except -1:
9853  */
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();
9858   return 0;
9859   __pyx_L1_error:;
9860   __Pyx_RefNannyFinishContext();
9861   return -1;
9862 }
9863 
__Pyx_InitGlobals(void)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)
9871   return 0;
9872   __pyx_L1_error:;
9873   return -1;
9874 }
9875 
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*/
9883 
__Pyx_modinit_global_init_code(void)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();
9889   return 0;
9890 }
9891 
__Pyx_modinit_variable_export_code(void)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();
9897   return 0;
9898 }
9899 
__Pyx_modinit_function_export_code(void)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();
9905   return 0;
9906 }
9907 
__Pyx_modinit_type_init_code(void)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();
9913   return 0;
9914 }
9915 
__Pyx_modinit_type_import_code(void)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),
9926   #else
9927   sizeof(PyHeapTypeObject),
9928   #endif
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();
9956   return 0;
9957   __pyx_L1_error:;
9958   __Pyx_XDECREF(__pyx_t_1);
9959   __Pyx_RefNannyFinishContext();
9960   return -1;
9961 }
9962 
__Pyx_modinit_variable_import_code(void)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();
9968   return 0;
9969 }
9970 
__Pyx_modinit_function_import_code(void)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();
9976   return 0;
9977 }
9978 
9979 
9980 #if PY_MAJOR_VERSION < 3
9981 #ifdef CYTHON_NO_PYINIT_EXPORT
9982 #define __Pyx_PyMODINIT_FUNC void
9983 #else
9984 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
9985 #endif
9986 #else
9987 #ifdef CYTHON_NO_PYINIT_EXPORT
9988 #define __Pyx_PyMODINIT_FUNC PyObject *
9989 #else
9990 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
9991 #endif
9992 #endif
9993 
9994 
9995 #if PY_MAJOR_VERSION < 3
9996 __Pyx_PyMODINIT_FUNC initSignal(void) CYTHON_SMALL_CODE; /*proto*/
initSignal(void)9997 __Pyx_PyMODINIT_FUNC initSignal(void)
9998 #else
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
10002 {
10003   return PyModuleDef_Init(&__pyx_moduledef);
10004 }
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))
10013     #else
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))
10019     #endif
10020     {
10021         PyErr_SetString(
10022             PyExc_ImportError,
10023             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
10024         return -1;
10025     }
10026     return 0;
10027 }
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);
10030     int result = 0;
10031     if (likely(value)) {
10032         if (allow_none || value != Py_None) {
10033             result = PyDict_SetItemString(moddict, to_name, value);
10034         }
10035         Py_DECREF(value);
10036     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
10037         PyErr_Clear();
10038     } else {
10039         result = -1;
10040     }
10041     return result;
10042 }
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())
10046         return NULL;
10047     if (__pyx_m)
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;
10060     return module;
10061 bad:
10062     Py_XDECREF(module);
10063     return NULL;
10064 }
10065 
10066 
10067 static CYTHON_SMALL_CODE int __pyx_pymod_exec_Signal(PyObject *__pyx_pyinit_module)
10068 #endif
10069 #endif
10070 {
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
10076   if (__pyx_m) {
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.");
10079     return -1;
10080   }
10081   #elif PY_MAJOR_VERSION >= 3
10082   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
10083   #endif
10084   #if CYTHON_REFNANNY
10085 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
10086 if (!__Pyx_RefNanny) {
10087   PyErr_Clear();
10088   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
10089   if (!__Pyx_RefNanny)
10090       Py_FatalError("failed to import 'refnanny' module");
10091 }
10092 #endif
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();
10097   #endif
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)
10103   #endif
10104   #ifdef __Pyx_FusedFunction_USED
10105   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10106   #endif
10107   #ifdef __Pyx_Coroutine_USED
10108   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10109   #endif
10110   #ifdef __Pyx_Generator_USED
10111   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10112   #endif
10113   #ifdef __Pyx_AsyncGen_USED
10114   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10115   #endif
10116   #ifdef __Pyx_StopAsyncIteration_USED
10117   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
10118   #endif
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();
10124   #endif
10125   #endif
10126   /*--- Module creation code ---*/
10127   #if CYTHON_PEP489_MULTI_PHASE_INIT
10128   __pyx_m = __pyx_pyinit_module;
10129   Py_INCREF(__pyx_m);
10130   #else
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);
10133   #else
10134   __pyx_m = PyModule_Create(&__pyx_moduledef);
10135   #endif
10136   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
10137   #endif
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)
10149   #endif
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)
10152   }
10153   #if PY_MAJOR_VERSION >= 3
10154   {
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)
10158     }
10159   }
10160   #endif
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)
10176   #endif
10177   __Pyx_TraceCall("__Pyx_PyMODINIT_FUNC PyInit_Signal(void)", __pyx_f[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error));
10178 
10179   /* "MACS2/Signal.pyx":14
10180  *
10181  * # smoothing function
10182  * import numpy as np             # <<<<<<<<<<<<<<
10183  * cimport numpy as np
10184  * from cpython cimport bool
10185  */
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;
10190 
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
10196  *
10197  */
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;
10211 
10212   /* "MACS2/Signal.pyx":18
10213  * from cpython cimport bool
10214  * from math import sqrt as mathsqrt
10215  * from math import factorial as mathfactorial             # <<<<<<<<<<<<<<
10216  *
10217  * cpdef np.ndarray[np.int32_t, ndim=1] maxima(np.ndarray[np.float32_t, ndim=1] signal,
10218  */
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;
10232 
10233   /* "MACS2/Signal.pyx":1
10234  * # cython: language_level=3             # <<<<<<<<<<<<<<
10235  * # cython: profile=True
10236  * # Time-stamp: <2019-12-18 16:49:03 taoliu>
10237  */
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;
10242 
10243   /* "../../../Codes/TLPython3/lib/python3.8/site-packages/Cython/Includes/numpy/__init__.pxd":1046
10244  *         raise ImportError("numpy.core.umath failed to import")
10245  *
10246  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
10247  *     try:
10248  *         _import_umath()
10249  */
10250   __Pyx_TraceReturn(Py_None, 0);
10251 
10252   /*--- Wrapped vars code ---*/
10253 
10254   goto __pyx_L0;
10255   __pyx_L1_error:;
10256   __Pyx_XDECREF(__pyx_t_1);
10257   __Pyx_XDECREF(__pyx_t_2);
10258   if (__pyx_m) {
10259     if (__pyx_d) {
10260       __Pyx_AddTraceback("init MACS2.Signal", __pyx_clineno, __pyx_lineno, __pyx_filename);
10261     }
10262     Py_CLEAR(__pyx_m);
10263   } else if (!PyErr_Occurred()) {
10264     PyErr_SetString(PyExc_ImportError, "init MACS2.Signal");
10265   }
10266   __pyx_L0:;
10267   __Pyx_RefNannyFinishContext();
10268   #if CYTHON_PEP489_MULTI_PHASE_INIT
10269   return (__pyx_m != NULL) ? 0 : -1;
10270   #elif PY_MAJOR_VERSION >= 3
10271   return __pyx_m;
10272   #else
10273   return;
10274   #endif
10275 }
10276 
10277 /* --- Runtime support code --- */
10278 /* Refnanny */
10279 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)10280 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
10281     PyObject *m = NULL, *p = NULL;
10282     void *r = NULL;
10283     m = PyImport_ImportModule(modname);
10284     if (!m) goto end;
10285     p = PyObject_GetAttrString(m, "RefNannyAPI");
10286     if (!p) goto end;
10287     r = PyLong_AsVoidPtr(p);
10288 end:
10289     Py_XDECREF(p);
10290     Py_XDECREF(m);
10291     return (__Pyx_RefNannyAPIStruct *)r;
10292 }
10293 #endif
10294 
10295 /* PyObjectGetAttrStr */
10296 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)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));
10304 #endif
10305     return PyObject_GetAttr(obj, attr_name);
10306 }
10307 #endif
10308 
10309 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)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);
10316 #else
10317             "name '%.200s' is not defined", PyString_AS_STRING(name));
10318 #endif
10319     }
10320     return result;
10321 }
10322 
10323 /* PyErrFetchRestore */
10324 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)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);
10336 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** 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;
10344 }
10345 #endif
10346 
10347 /* Profile */
10348 #if CYTHON_PROFILE
__Pyx_TraceSetupAndCall(PyCodeObject ** code,PyFrameObject ** frame,PyThreadState * tstate,const char * funcname,const char * srcfile,int firstlineno)10349 static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
10350                                    PyFrameObject** frame,
10351                                    PyThreadState* tstate,
10352                                    const char *funcname,
10353                                    const char *srcfile,
10354                                    int firstlineno) {
10355     PyObject *type, *value, *traceback;
10356     int retval;
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;
10361         }
10362         *frame = PyFrame_New(
10363             tstate,                          /*PyThreadState *tstate*/
10364             *code,                           /*PyCodeObject *code*/
10365             __pyx_d,                  /*PyObject *globals*/
10366             0                                /*PyObject *locals*/
10367         );
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;
10372         }
10373 #if PY_VERSION_HEX < 0x030400B1
10374     } else {
10375         (*frame)->f_tstate = tstate;
10376 #endif
10377     }
10378       __Pyx_PyFrame_SetLineNumber(*frame, firstlineno);
10379     retval = 1;
10380     tstate->tracing++;
10381     tstate->use_tracing = 0;
10382     __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
10383     #if CYTHON_TRACE
10384     if (tstate->c_tracefunc)
10385         retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0;
10386     if (retval && tstate->c_profilefunc)
10387     #endif
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));
10391     tstate->tracing--;
10392     if (retval) {
10393         __Pyx_ErrRestoreInState(tstate, type, value, traceback);
10394         return tstate->use_tracing && retval;
10395     } else {
10396         Py_XDECREF(type);
10397         Py_XDECREF(value);
10398         Py_XDECREF(traceback);
10399         return -1;
10400     }
10401 }
__Pyx_createFrameCodeObject(const char * funcname,const char * srcfile,int firstlineno)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;
10408     }
10409 #else
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(
10417         0,
10418         0,
10419         0,
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,*/
10429         firstlineno,
10430         __pyx_empty_bytes      /*PyObject *lnotab*/
10431     );
10432 bad:
10433     Py_XDECREF(py_srcfile);
10434     Py_XDECREF(py_funcname);
10435 #endif
10436     return py_code;
10437 }
10438 #endif
10439 
10440 /* IsLittleEndian */
__Pyx_Is_Little_Endian(void)10441 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
10442 {
10443   union {
10444     uint32_t u32;
10445     uint8_t u8[4];
10446   } S;
10447   S.u32 = 0x01020304;
10448   return S.u8[0] == 4;
10449 }
10450 
10451 /* BufferFormatCheck */
__Pyx_BufFmt_Init(__Pyx_BufFmt_Context * ctx,__Pyx_BufFmt_StackElem * stack,__Pyx_TypeInfo * type)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;
10460   ctx->head = stack;
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;
10468   ctx->enc_type = 0;
10469   ctx->is_complex = 0;
10470   ctx->is_valid_array = 0;
10471   ctx->struct_alignment = 0;
10472   while (type->typegroup == 'S') {
10473     ++ctx->head;
10474     ctx->head->field = type->fields;
10475     ctx->head->parent_offset = 0;
10476     type = type->fields->type;
10477   }
10478 }
__Pyx_BufFmt_ParseNumber(const char ** ts)10479 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
10480     int count;
10481     const char* t = *ts;
10482     if (*t < '0' || *t > '9') {
10483       return -1;
10484     } else {
10485         count = *t++ - '0';
10486         while (*t >= '0' && *t <= '9') {
10487             count *= 10;
10488             count += *t++ - '0';
10489         }
10490     }
10491     *ts = t;
10492     return count;
10493 }
__Pyx_BufFmt_ExpectNumber(const char ** ts)10494 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
10495     int number = __Pyx_BufFmt_ParseNumber(ts);
10496     if (number == -1)
10497         PyErr_Format(PyExc_ValueError,\
10498                      "Does not understand character buffer dtype format string ('%c')", **ts);
10499     return number;
10500 }
__Pyx_BufFmt_RaiseUnexpectedChar(char ch)10501 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
10502   PyErr_Format(PyExc_ValueError,
10503                "Unexpected format string character: '%c'", ch);
10504 }
__Pyx_BufFmt_DescribeTypeChar(char ch,int is_complex)10505 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
10506   switch (ch) {
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";
10528   }
10529 }
__Pyx_BufFmt_TypeCharToStandardSize(char ch,int is_complex)10530 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
10531   switch (ch) {
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);
10538     case 'g': {
10539       PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
10540       return 0;
10541     }
10542     case 'O': case 'P': return sizeof(void*);
10543     default:
10544       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
10545       return 0;
10546     }
10547 }
__Pyx_BufFmt_TypeCharToNativeSize(char ch,int is_complex)10548 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
10549   switch (ch) {
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);
10556     #endif
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*);
10561     default: {
10562       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
10563       return 0;
10564     }
10565   }
10566 }
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;
10576 #endif
__Pyx_BufFmt_TypeCharToAlignment(char ch,CYTHON_UNUSED int is_complex)10577 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
10578   switch (ch) {
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);
10585 #endif
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*);
10590     default:
10591       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
10592       return 0;
10593     }
10594 }
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.
10598  */
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;
10608 #endif
__Pyx_BufFmt_TypeCharToPadding(char ch,CYTHON_UNUSED int is_complex)10609 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
10610   switch (ch) {
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);
10617 #endif
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*);
10622     default:
10623       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
10624       return 0;
10625     }
10626 }
__Pyx_BufFmt_TypeCharToGroup(char ch,int is_complex)10627 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
10628   switch (ch) {
10629     case 'c':
10630         return 'H';
10631     case 'b': case 'h': case 'i':
10632     case 'l': case 'q': case 's': case 'p':
10633         return 'I';
10634     case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
10635         return 'U';
10636     case 'f': case 'd': case 'g':
10637         return (is_complex ? 'C' : 'R');
10638     case 'O':
10639         return 'O';
10640     case 'P':
10641         return 'P';
10642     default: {
10643       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
10644       return 0;
10645     }
10646   }
10647 }
__Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context * ctx)10648 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
10649   if (ctx->head == NULL || ctx->head->field == &ctx->root) {
10650     const char* expected;
10651     const char* quote;
10652     if (ctx->head == NULL) {
10653       expected = "end";
10654       quote = "";
10655     } else {
10656       expected = ctx->head->field->type->name;
10657       quote = "'";
10658     }
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));
10663   } else {
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);
10670   }
10671 }
__Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context * ctx)10672 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
10673   char group;
10674   size_t size, offset, arraysize = 1;
10675   if (ctx->enc_type == 0) return 0;
10676   if (ctx->head->field->type->arraysize[0]) {
10677     int i, ndim = 0;
10678     if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
10679         ctx->is_valid_array = ctx->head->field->type->ndim == 1;
10680         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);
10685             return -1;
10686         }
10687     }
10688     if (!ctx->is_valid_array) {
10689       PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
10690                    ctx->head->field->type->ndim, ndim);
10691       return -1;
10692     }
10693     for (i = 0; i < ctx->head->field->type->ndim; i++) {
10694       arraysize *= ctx->head->field->type->arraysize[i];
10695     }
10696     ctx->is_valid_array = 0;
10697     ctx->enc_count = 1;
10698   }
10699   group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
10700   do {
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);
10705     } else {
10706       size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
10707     }
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,
10716                                                                  ctx->is_complex);
10717     }
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;
10721         ++ctx->head;
10722         ctx->head->field = type->fields;
10723         ctx->head->parent_offset = parent_offset;
10724         continue;
10725       }
10726       if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
10727       } else {
10728           __Pyx_BufFmt_RaiseExpected(ctx);
10729           return -1;
10730       }
10731     }
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);
10737       return -1;
10738     }
10739     ctx->fmt_offset += size;
10740     if (arraysize)
10741       ctx->fmt_offset += (arraysize - 1) * size;
10742     --ctx->enc_count;
10743     while (1) {
10744       if (field == &ctx->root) {
10745         ctx->head = NULL;
10746         if (ctx->enc_count != 0) {
10747           __Pyx_BufFmt_RaiseExpected(ctx);
10748           return -1;
10749         }
10750         break;
10751       }
10752       ctx->head->field = ++field;
10753       if (field->type == NULL) {
10754         --ctx->head;
10755         field = ctx->head->field;
10756         continue;
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;
10761         ++ctx->head;
10762         ctx->head->field = field;
10763         ctx->head->parent_offset = parent_offset;
10764         break;
10765       } else {
10766         break;
10767       }
10768     }
10769   } while (ctx->enc_count);
10770   ctx->enc_type = 0;
10771   ctx->is_complex = 0;
10772   return 0;
10773 }
10774 static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context * ctx,const char ** tsp)10775 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
10776 {
10777     const char *ts = *tsp;
10778     int i = 0, number;
10779     int ndim = ctx->head->field->type->ndim;
10780 ;
10781     ++ts;
10782     if (ctx->new_count != 1) {
10783         PyErr_SetString(PyExc_ValueError,
10784                         "Cannot handle repeated arrays in format string");
10785         return NULL;
10786     }
10787     if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
10788     while (*ts && *ts != ')') {
10789         switch (*ts) {
10790             case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
10791             default:  break;
10792         }
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++;
10803         i++;
10804     }
10805     if (i != ndim)
10806         return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
10807                             ctx->head->field->type->ndim, i);
10808     if (!*ts) {
10809         PyErr_SetString(PyExc_ValueError,
10810                         "Unexpected end of format string, expected ')'");
10811         return NULL;
10812     }
10813     ctx->is_valid_array = 1;
10814     ctx->new_count = 1;
10815     *tsp = ++ts;
10816     return Py_None;
10817 }
__Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context * ctx,const char * ts)10818 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
10819   int got_Z = 0;
10820   while (1) {
10821     switch(*ts) {
10822       case 0:
10823         if (ctx->enc_type != 0 && ctx->head == NULL) {
10824           __Pyx_BufFmt_RaiseExpected(ctx);
10825           return NULL;
10826         }
10827         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
10828         if (ctx->head != NULL) {
10829           __Pyx_BufFmt_RaiseExpected(ctx);
10830           return NULL;
10831         }
10832         return ts;
10833       case ' ':
10834       case '\r':
10835       case '\n':
10836         ++ts;
10837         break;
10838       case '<':
10839         if (!__Pyx_Is_Little_Endian()) {
10840           PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
10841           return NULL;
10842         }
10843         ctx->new_packmode = '=';
10844         ++ts;
10845         break;
10846       case '>':
10847       case '!':
10848         if (__Pyx_Is_Little_Endian()) {
10849           PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
10850           return NULL;
10851         }
10852         ctx->new_packmode = '=';
10853         ++ts;
10854         break;
10855       case '=':
10856       case '@':
10857       case '^':
10858         ctx->new_packmode = *ts++;
10859         break;
10860       case 'T':
10861         {
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;
10866           ++ts;
10867           if (*ts != '{') {
10868             PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
10869             return NULL;
10870           }
10871           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
10872           ctx->enc_type = 0;
10873           ctx->enc_count = 0;
10874           ctx->struct_alignment = 0;
10875           ++ts;
10876           ts_after_sub = ts;
10877           for (i = 0; i != struct_count; ++i) {
10878             ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
10879             if (!ts_after_sub) return NULL;
10880           }
10881           ts = ts_after_sub;
10882           if (struct_alignment) ctx->struct_alignment = struct_alignment;
10883         }
10884         break;
10885       case '}':
10886         {
10887           size_t alignment = ctx->struct_alignment;
10888           ++ts;
10889           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
10890           ctx->enc_type = 0;
10891           if (alignment && ctx->fmt_offset % alignment) {
10892             ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
10893           }
10894         }
10895         return ts;
10896       case 'x':
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;
10901         ctx->enc_type = 0;
10902         ctx->enc_packmode = ctx->new_packmode;
10903         ++ts;
10904         break;
10905       case 'Z':
10906         got_Z = 1;
10907         ++ts;
10908         if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
10909           __Pyx_BufFmt_RaiseUnexpectedChar('Z');
10910           return NULL;
10911         }
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;
10921           got_Z = 0;
10922           ++ts;
10923           break;
10924         }
10925         CYTHON_FALLTHROUGH;
10926       case 's':
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;
10932         ++ts;
10933         ctx->new_count = 1;
10934         got_Z = 0;
10935         break;
10936       case ':':
10937         ++ts;
10938         while(*ts != ':') ++ts;
10939         ++ts;
10940         break;
10941       case '(':
10942         if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
10943         break;
10944       default:
10945         {
10946           int number = __Pyx_BufFmt_ExpectNumber(&ts);
10947           if (number == -1) return NULL;
10948           ctx->new_count = (size_t)number;
10949         }
10950     }
10951   }
10952 }
10953 
10954 /* BufferGetAndValidate */
__Pyx_SafeReleaseBuffer(Py_buffer * info)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);
10959 }
__Pyx_ZeroBuffer(Py_buffer * buf)10960 static void __Pyx_ZeroBuffer(Py_buffer* buf) {
10961   buf->buf = NULL;
10962   buf->obj = NULL;
10963   buf->strides = __Pyx_zeros;
10964   buf->shape = __Pyx_zeros;
10965   buf->suboffsets = __Pyx_minusones;
10966 }
__Pyx__GetBufferAndValidate(Py_buffer * buf,PyObject * obj,__Pyx_TypeInfo * dtype,int flags,int nd,int cast,__Pyx_BufFmt_StackElem * stack)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)
10970 {
10971   buf->buf = NULL;
10972   if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
10973     __Pyx_ZeroBuffer(buf);
10974     return -1;
10975   }
10976   if (unlikely(buf->ndim != nd)) {
10977     PyErr_Format(PyExc_ValueError,
10978                  "Buffer has wrong number of dimensions (expected %d, got %d)",
10979                  nd, buf->ndim);
10980     goto fail;
10981   }
10982   if (!cast) {
10983     __Pyx_BufFmt_Context ctx;
10984     __Pyx_BufFmt_Init(&ctx, stack, dtype);
10985     if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
10986   }
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" : "");
10992     goto fail;
10993   }
10994   if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
10995   return 0;
10996 fail:;
10997   __Pyx_SafeReleaseBuffer(buf);
10998   return -1;
10999 }
11000 
11001 /* None */
__Pyx_div_long(long a,long b)11002   static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
11003     long q = a / b;
11004     long r = a - q*b;
11005     q -= ((r != 0) & ((r ^ b) < 0));
11006     return q;
11007 }
11008 
11009 /* PyCFunctionFastCall */
11010   #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)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);
11026     } else {
11027         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
11028     }
11029 }
11030 #endif
11031 
11032 /* PyFunctionFastCall */
11033   #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)11034 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
11035                                                PyObject *globals) {
11036     PyFrameObject *f;
11037     PyThreadState *tstate = __Pyx_PyThreadState_Current;
11038     PyObject **fastlocals;
11039     Py_ssize_t i;
11040     PyObject *result;
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.
11045        */
11046     assert(tstate != NULL);
11047     f = PyFrame_New(tstate, co, globals, NULL);
11048     if (f == NULL) {
11049         return NULL;
11050     }
11051     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
11052     for (i = 0; i < na; i++) {
11053         Py_INCREF(*args);
11054         fastlocals[i] = *args++;
11055     }
11056     result = PyEval_EvalFrameEx(f,0);
11057     ++tstate->recursion_depth;
11058     Py_DECREF(f);
11059     --tstate->recursion_depth;
11060     return result;
11061 }
11062 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)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);
11067     PyObject *closure;
11068 #if PY_MAJOR_VERSION >= 3
11069     PyObject *kwdefs;
11070 #endif
11071     PyObject *kwtuple, **k;
11072     PyObject **d;
11073     Py_ssize_t nd;
11074     Py_ssize_t nk;
11075     PyObject *result;
11076     assert(kwargs == NULL || PyDict_Check(kwargs));
11077     nk = kwargs ? PyDict_Size(kwargs) : 0;
11078     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
11079         return NULL;
11080     }
11081     if (
11082 #if PY_MAJOR_VERSION >= 3
11083             co->co_kwonlyargcount == 0 &&
11084 #endif
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);
11089             goto done;
11090         }
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);
11097             goto done;
11098         }
11099     }
11100     if (kwargs != NULL) {
11101         Py_ssize_t pos, i;
11102         kwtuple = PyTuple_New(2 * nk);
11103         if (kwtuple == NULL) {
11104             result = NULL;
11105             goto done;
11106         }
11107         k = &PyTuple_GET_ITEM(kwtuple, 0);
11108         pos = i = 0;
11109         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
11110             Py_INCREF(k[i]);
11111             Py_INCREF(k[i+1]);
11112             i += 2;
11113         }
11114         nk = i / 2;
11115     }
11116     else {
11117         kwtuple = NULL;
11118         k = NULL;
11119     }
11120     closure = PyFunction_GET_CLOSURE(func);
11121 #if PY_MAJOR_VERSION >= 3
11122     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
11123 #endif
11124     if (argdefs != NULL) {
11125         d = &PyTuple_GET_ITEM(argdefs, 0);
11126         nd = Py_SIZE(argdefs);
11127     }
11128     else {
11129         d = NULL;
11130         nd = 0;
11131     }
11132 #if PY_MAJOR_VERSION >= 3
11133     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
11134                                args, (int)nargs,
11135                                k, (int)nk,
11136                                d, (int)nd, kwdefs, closure);
11137 #else
11138     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
11139                                args, (int)nargs,
11140                                k, (int)nk,
11141                                d, (int)nd, closure);
11142 #endif
11143     Py_XDECREF(kwtuple);
11144 done:
11145     Py_LeaveRecursiveCall();
11146     return result;
11147 }
11148 #endif
11149 #endif
11150 
11151 /* PyObjectCall */
11152   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)11153 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
11154     PyObject *result;
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")))
11159         return NULL;
11160     result = (*call)(func, arg, kw);
11161     Py_LeaveRecursiveCall();
11162     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
11163         PyErr_SetString(
11164             PyExc_SystemError,
11165             "NULL result without error in PyObject_Call");
11166     }
11167     return result;
11168 }
11169 #endif
11170 
11171 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)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);
11178     }
11179     #endif
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);
11184     }
11185     #endif
11186     args = PyTuple_New(2);
11187     if (unlikely(!args)) goto done;
11188     Py_INCREF(arg1);
11189     PyTuple_SET_ITEM(args, 0, arg1);
11190     Py_INCREF(arg2);
11191     PyTuple_SET_ITEM(args, 1, arg2);
11192     Py_INCREF(function);
11193     result = __Pyx_PyObject_Call(function, args, NULL);
11194     Py_DECREF(args);
11195     Py_DECREF(function);
11196 done:
11197     return result;
11198 }
11199 
11200 /* PyObjectCallMethO */
11201   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)11202 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
11203     PyObject *self, *result;
11204     PyCFunction cfunc;
11205     cfunc = PyCFunction_GET_FUNCTION(func);
11206     self = PyCFunction_GET_SELF(func);
11207     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
11208         return NULL;
11209     result = cfunc(self, arg);
11210     Py_LeaveRecursiveCall();
11211     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
11212         PyErr_SetString(
11213             PyExc_SystemError,
11214             "NULL result without error in PyObject_Call");
11215     }
11216     return result;
11217 }
11218 #endif
11219 
11220 /* PyObjectCallOneArg */
11221   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)11222 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
11223     PyObject *result;
11224     PyObject *args = PyTuple_New(1);
11225     if (unlikely(!args)) return NULL;
11226     Py_INCREF(arg);
11227     PyTuple_SET_ITEM(args, 0, arg);
11228     result = __Pyx_PyObject_Call(func, args, NULL);
11229     Py_DECREF(args);
11230     return result;
11231 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)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);
11236     }
11237 #endif
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);
11244 #endif
11245         }
11246     }
11247     return __Pyx__PyObject_CallOneArg(func, arg);
11248 }
11249 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)11250 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
11251     PyObject *result;
11252     PyObject *args = PyTuple_Pack(1, arg);
11253     if (unlikely(!args)) return NULL;
11254     result = __Pyx_PyObject_Call(func, args, NULL);
11255     Py_DECREF(args);
11256     return result;
11257 }
11258 #endif
11259 
11260 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)11261   static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
11262     if (unlikely(!type)) {
11263         PyErr_SetString(PyExc_SystemError, "Missing type object");
11264         return 0;
11265     }
11266     if (likely(__Pyx_TypeCheck(obj, type)))
11267         return 1;
11268     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
11269                  Py_TYPE(obj)->tp_name, type->tp_name);
11270     return 0;
11271 }
11272 
11273 /* BufferFallbackError */
__Pyx_RaiseBufferFallbackError(void)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!");
11277 }
11278 
11279 /* PyDictVersioning */
11280   #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)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;
11284 }
__Pyx_get_object_dict_version(PyObject * obj)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;
11288     if (offset) {
11289 #if CYTHON_COMPILING_IN_CPYTHON
11290         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
11291 #else
11292         dictptr = _PyObject_GetDictPtr(obj);
11293 #endif
11294     }
11295     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
11296 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)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)))
11300         return 0;
11301     return obj_dict_version == __Pyx_get_object_dict_version(obj);
11302 }
11303 #endif
11304 
11305 /* GetModuleGlobalName */
11306   #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)11307 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
11308 #else
11309 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
11310 #endif
11311 {
11312     PyObject *result;
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())) {
11320         return NULL;
11321     }
11322 #else
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);
11327     }
11328 #endif
11329 #else
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);
11334     }
11335     PyErr_Clear();
11336 #endif
11337     return __Pyx_GetBuiltinName(name);
11338 }
11339 
11340 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)11341   static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
11342     PyObject *r;
11343     if (!j) return NULL;
11344     r = PyObject_GetItem(o, j);
11345     Py_DECREF(j);
11346     return r;
11347 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)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);
11355     }
11356     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
11357         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
11358         Py_INCREF(r);
11359         return r;
11360     }
11361     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
11362 #else
11363     return PySequence_GetItem(o, i);
11364 #endif
11365 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)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);
11373     }
11374     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
11375         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
11376         Py_INCREF(r);
11377         return r;
11378     }
11379     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
11380 #else
11381     return PySequence_GetItem(o, i);
11382 #endif
11383 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)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);
11392             Py_INCREF(r);
11393             return r;
11394         }
11395     }
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);
11400             Py_INCREF(r);
11401             return r;
11402         }
11403     } else {
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)) {
11409                     i += l;
11410                 } else {
11411                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
11412                         return NULL;
11413                     PyErr_Clear();
11414                 }
11415             }
11416             return m->sq_item(o, i);
11417         }
11418     }
11419 #else
11420     if (is_list || PySequence_Check(o)) {
11421         return PySequence_GetItem(o, i);
11422     }
11423 #endif
11424     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
11425 }
11426 
11427 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)11428   static void __Pyx_RaiseDoubleKeywordsError(
11429     const char* func_name,
11430     PyObject* kw_name)
11431 {
11432     PyErr_Format(PyExc_TypeError,
11433         #if PY_MAJOR_VERSION >= 3
11434         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
11435         #else
11436         "%s() got multiple values for keyword argument '%s'", func_name,
11437         PyString_AsString(kw_name));
11438         #endif
11439 }
11440 
11441 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)11442   static int __Pyx_ParseOptionalKeywords(
11443     PyObject *kwds,
11444     PyObject **argnames[],
11445     PyObject *kwds2,
11446     PyObject *values[],
11447     Py_ssize_t num_pos_args,
11448     const char* function_name)
11449 {
11450     PyObject *key = 0, *value = 0;
11451     Py_ssize_t pos = 0;
11452     PyObject*** name;
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++;
11457         if (*name) {
11458             values[name-argnames] = value;
11459             continue;
11460         }
11461         name = first_kw_arg;
11462         #if PY_MAJOR_VERSION < 3
11463         if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
11464             while (*name) {
11465                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
11466                         && _PyString_Eq(**name, key)) {
11467                     values[name-argnames] = value;
11468                     break;
11469                 }
11470                 name++;
11471             }
11472             if (*name) continue;
11473             else {
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;
11480                     }
11481                     argname++;
11482                 }
11483             }
11484         } else
11485         #endif
11486         if (likely(PyUnicode_Check(key))) {
11487             while (*name) {
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 :
11491                 #endif
11492                     PyUnicode_Compare(**name, key);
11493                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
11494                 if (cmp == 0) {
11495                     values[name-argnames] = value;
11496                     break;
11497                 }
11498                 name++;
11499             }
11500             if (*name) continue;
11501             else {
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 :
11507                     #endif
11508                         PyUnicode_Compare(**argname, key);
11509                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
11510                     if (cmp == 0) goto arg_passed_twice;
11511                     argname++;
11512                 }
11513             }
11514         } else
11515             goto invalid_keyword_type;
11516         if (kwds2) {
11517             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
11518         } else {
11519             goto invalid_keyword;
11520         }
11521     }
11522     return 0;
11523 arg_passed_twice:
11524     __Pyx_RaiseDoubleKeywordsError(function_name, key);
11525     goto bad;
11526 invalid_keyword_type:
11527     PyErr_Format(PyExc_TypeError,
11528         "%.200s() keywords must be strings", function_name);
11529     goto bad;
11530 invalid_keyword:
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));
11535     #else
11536         "%s() got an unexpected keyword argument '%U'",
11537         function_name, key);
11538     #endif
11539 bad:
11540     return -1;
11541 }
11542 
11543 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)11544   static void __Pyx_RaiseArgtupleInvalid(
11545     const char* func_name,
11546     int exact,
11547     Py_ssize_t num_min,
11548     Py_ssize_t num_max,
11549     Py_ssize_t num_found)
11550 {
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";
11556     } else {
11557         num_expected = num_max;
11558         more_or_less = "at most";
11559     }
11560     if (exact) {
11561         more_or_less = "exactly";
11562     }
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);
11567 }
11568 
11569 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)11570   static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
11571 {
11572     if (unlikely(!type)) {
11573         PyErr_SetString(PyExc_SystemError, "Missing type object");
11574         return 0;
11575     }
11576     else if (exact) {
11577         #if PY_MAJOR_VERSION == 2
11578         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
11579         #endif
11580     }
11581     else {
11582         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
11583     }
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);
11587     return 0;
11588 }
11589 
11590 /* BufferIndexError */
__Pyx_RaiseBufferIndexError(int axis)11591   static void __Pyx_RaiseBufferIndexError(int axis) {
11592   PyErr_Format(PyExc_IndexError,
11593      "Out of bounds on buffer access (axis %d)", axis);
11594 }
11595 
11596 /* ObjectGetItem */
11597   #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)11598 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
11599     PyObject *runerr;
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);
11604         return NULL;
11605     }
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);
11609     }
11610     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
11611         PyErr_Clear();
11612         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
11613     }
11614     return NULL;
11615 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)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);
11620     }
11621     return __Pyx_PyObject_GetIndex(obj, key);
11622 }
11623 #endif
11624 
11625 /* PyObjectCallNoArg */
11626   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)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);
11631     }
11632 #endif
11633 #ifdef __Pyx_CyFunction_USED
11634     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
11635 #else
11636     if (likely(PyCFunction_Check(func)))
11637 #endif
11638     {
11639         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
11640             return __Pyx_PyObject_CallMethO(func, NULL);
11641         }
11642     }
11643     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
11644 }
11645 #endif
11646 
11647 /* WriteUnraisableException */
__Pyx_WriteUnraisable(const char * name,CYTHON_UNUSED int clineno,CYTHON_UNUSED int lineno,CYTHON_UNUSED const char * filename,int full_traceback,CYTHON_UNUSED int nogil)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;
11652     PyObject *ctx;
11653     __Pyx_PyThreadState_declare
11654 #ifdef WITH_THREAD
11655     PyGILState_STATE state;
11656     if (nogil)
11657         state = PyGILState_Ensure();
11658 #ifdef _MSC_VER
11659     else state = (PyGILState_STATE)-1;
11660 #endif
11661 #endif
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);
11669         PyErr_PrintEx(1);
11670     }
11671     #if PY_MAJOR_VERSION < 3
11672     ctx = PyString_FromString(name);
11673     #else
11674     ctx = PyUnicode_FromString(name);
11675     #endif
11676     __Pyx_ErrRestore(old_exc, old_val, old_tb);
11677     if (!ctx) {
11678         PyErr_WriteUnraisable(Py_None);
11679     } else {
11680         PyErr_WriteUnraisable(ctx);
11681         Py_DECREF(ctx);
11682     }
11683 #ifdef WITH_THREAD
11684     if (nogil)
11685         PyGILState_Release(state);
11686 #endif
11687 }
11688 
11689 /* PyIntBinop */
11690   #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)11691 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
11692     (void)inplace;
11693     (void)zerodivision_check;
11694     #if PY_MAJOR_VERSION < 3
11695     if (likely(PyInt_CheckExact(op1))) {
11696         const long b = intval;
11697         long x;
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);
11703     }
11704     #endif
11705     #if CYTHON_USE_PYLONG_INTERNALS
11706     if (likely(PyLong_CheckExact(op1))) {
11707         const long b = intval;
11708         long a, x;
11709 #ifdef HAVE_LONG_LONG
11710         const PY_LONG_LONG llb = intval;
11711         PY_LONG_LONG lla, llx;
11712 #endif
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;
11718         } else {
11719             switch (size) {
11720                 case -2:
11721                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
11722                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
11723                         break;
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]));
11727                         goto long_long;
11728 #endif
11729                     }
11730                     CYTHON_FALLTHROUGH;
11731                 case 2:
11732                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
11733                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
11734                         break;
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]));
11738                         goto long_long;
11739 #endif
11740                     }
11741                     CYTHON_FALLTHROUGH;
11742                 case -3:
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]));
11745                         break;
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]));
11749                         goto long_long;
11750 #endif
11751                     }
11752                     CYTHON_FALLTHROUGH;
11753                 case 3:
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]));
11756                         break;
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]));
11760                         goto long_long;
11761 #endif
11762                     }
11763                     CYTHON_FALLTHROUGH;
11764                 case -4:
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]));
11767                         break;
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]));
11771                         goto long_long;
11772 #endif
11773                     }
11774                     CYTHON_FALLTHROUGH;
11775                 case 4:
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]));
11778                         break;
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]));
11782                         goto long_long;
11783 #endif
11784                     }
11785                     CYTHON_FALLTHROUGH;
11786                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
11787             }
11788         }
11789                 x = a + b;
11790             return PyLong_FromLong(x);
11791 #ifdef HAVE_LONG_LONG
11792         long_long:
11793                 llx = lla + llb;
11794             return PyLong_FromLongLong(llx);
11795 #endif
11796 
11797 
11798     }
11799     #endif
11800     if (PyFloat_CheckExact(op1)) {
11801         const long b = intval;
11802         double a = PyFloat_AS_DOUBLE(op1);
11803             double result;
11804             PyFPE_START_PROTECT("add", return NULL)
11805             result = ((double)a) + (double)b;
11806             PyFPE_END_PROTECT(result)
11807             return PyFloat_FromDouble(result);
11808     }
11809     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
11810 }
11811 #endif
11812 
11813 /* None */
__Pyx_mod_long(long a,long b)11814   static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
11815     long r = a % b;
11816     r += ((r != 0) & ((r ^ b) < 0)) * b;
11817     return r;
11818 }
11819 
11820 /* GetTopmostException */
11821   #if CYTHON_USE_EXC_INFO_STACK
11822 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)11823 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
11824 {
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)
11828     {
11829         exc_info = exc_info->previous_item;
11830     }
11831     return exc_info;
11832 }
11833 #endif
11834 
11835 /* SaveResetException */
11836   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)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;
11843     #else
11844     *type = tstate->exc_type;
11845     *value = tstate->exc_value;
11846     *tb = tstate->exc_traceback;
11847     #endif
11848     Py_XINCREF(*type);
11849     Py_XINCREF(*value);
11850     Py_XINCREF(*tb);
11851 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)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;
11862     #else
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;
11869     #endif
11870     Py_XDECREF(tmp_type);
11871     Py_XDECREF(tmp_value);
11872     Py_XDECREF(tmp_tb);
11873 }
11874 #endif
11875 
11876 /* PyErrExceptionMatches */
11877   #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)11878 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
11879     Py_ssize_t i, n;
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;
11884     }
11885 #endif
11886     for (i=0; i<n; i++) {
11887         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
11888     }
11889     return 0;
11890 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)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);
11898 }
11899 #endif
11900 
11901 /* GetException */
11902   #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)11903 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
11904 #else
11905 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
11906 #endif
11907 {
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;
11917 #else
11918     PyErr_Fetch(&local_type, &local_value, &local_tb);
11919 #endif
11920     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
11921 #if CYTHON_FAST_THREAD_STATE
11922     if (unlikely(tstate->curexc_type))
11923 #else
11924     if (unlikely(PyErr_Occurred()))
11925 #endif
11926         goto bad;
11927     #if PY_MAJOR_VERSION >= 3
11928     if (local_tb) {
11929         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
11930             goto bad;
11931     }
11932     #endif
11933     Py_XINCREF(local_tb);
11934     Py_XINCREF(local_type);
11935     Py_XINCREF(local_value);
11936     *type = local_type;
11937     *value = local_value;
11938     *tb = local_tb;
11939 #if CYTHON_FAST_THREAD_STATE
11940     #if CYTHON_USE_EXC_INFO_STACK
11941     {
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;
11949     }
11950     #else
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;
11957     #endif
11958     Py_XDECREF(tmp_type);
11959     Py_XDECREF(tmp_value);
11960     Py_XDECREF(tmp_tb);
11961 #else
11962     PyErr_SetExcInfo(local_type, local_value, local_tb);
11963 #endif
11964     return 0;
11965 bad:
11966     *type = 0;
11967     *value = 0;
11968     *tb = 0;
11969     Py_XDECREF(local_type);
11970     Py_XDECREF(local_value);
11971     Py_XDECREF(local_tb);
11972     return -1;
11973 }
11974 
11975 /* RaiseException */
11976   #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)11977 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
11978                         CYTHON_UNUSED PyObject *cause) {
11979     __Pyx_PyThreadState_declare
11980     Py_XINCREF(type);
11981     if (!value || value == Py_None)
11982         value = NULL;
11983     else
11984         Py_INCREF(value);
11985     if (!tb || tb == Py_None)
11986         tb = NULL;
11987     else {
11988         Py_INCREF(tb);
11989         if (!PyTraceBack_Check(tb)) {
11990             PyErr_SetString(PyExc_TypeError,
11991                 "raise: arg 3 must be a traceback or None");
11992             goto raise_error;
11993         }
11994     }
11995     if (PyType_Check(type)) {
11996 #if CYTHON_COMPILING_IN_PYPY
11997         if (!value) {
11998             Py_INCREF(Py_None);
11999             value = Py_None;
12000         }
12001 #endif
12002         PyErr_NormalizeException(&type, &value, &tb);
12003     } else {
12004         if (value) {
12005             PyErr_SetString(PyExc_TypeError,
12006                 "instance exception may not have a separate value");
12007             goto raise_error;
12008         }
12009         value = type;
12010         type = (PyObject*) Py_TYPE(type);
12011         Py_INCREF(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");
12015             goto raise_error;
12016         }
12017     }
12018     __Pyx_PyThreadState_assign
12019     __Pyx_ErrRestore(type, value, tb);
12020     return;
12021 raise_error:
12022     Py_XDECREF(value);
12023     Py_XDECREF(type);
12024     Py_XDECREF(tb);
12025     return;
12026 }
12027 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)12028 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
12029     PyObject* owned_instance = NULL;
12030     if (tb == Py_None) {
12031         tb = 0;
12032     } else if (tb && !PyTraceBack_Check(tb)) {
12033         PyErr_SetString(PyExc_TypeError,
12034             "raise: arg 3 must be a traceback or None");
12035         goto bad;
12036     }
12037     if (value == Py_None)
12038         value = 0;
12039     if (PyExceptionInstance_Check(type)) {
12040         if (value) {
12041             PyErr_SetString(PyExc_TypeError,
12042                 "instance exception may not have a separate value");
12043             goto bad;
12044         }
12045         value = type;
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)) {
12056                     goto bad;
12057                 } else {
12058                     type = instance_class;
12059                 }
12060             }
12061         }
12062         if (!instance_class) {
12063             PyObject *args;
12064             if (!value)
12065                 args = PyTuple_New(0);
12066             else if (PyTuple_Check(value)) {
12067                 Py_INCREF(value);
12068                 args = value;
12069             } else
12070                 args = PyTuple_Pack(1, value);
12071             if (!args)
12072                 goto bad;
12073             owned_instance = PyObject_Call(type, args, NULL);
12074             Py_DECREF(args);
12075             if (!owned_instance)
12076                 goto bad;
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));
12083                 goto bad;
12084             }
12085         }
12086     } else {
12087         PyErr_SetString(PyExc_TypeError,
12088             "raise: exception class must be a subclass of BaseException");
12089         goto bad;
12090     }
12091     if (cause) {
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)
12098                 goto bad;
12099         } else if (PyExceptionInstance_Check(cause)) {
12100             fixed_cause = cause;
12101             Py_INCREF(fixed_cause);
12102         } else {
12103             PyErr_SetString(PyExc_TypeError,
12104                             "exception causes must derive from "
12105                             "BaseException");
12106             goto bad;
12107         }
12108         PyException_SetCause(value, fixed_cause);
12109     }
12110     PyErr_SetObject(type, value);
12111     if (tb) {
12112 #if CYTHON_COMPILING_IN_PYPY
12113         PyObject *tmp_type, *tmp_value, *tmp_tb;
12114         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
12115         Py_INCREF(tb);
12116         PyErr_Restore(tmp_type, tmp_value, tb);
12117         Py_XDECREF(tmp_tb);
12118 #else
12119         PyThreadState *tstate = __Pyx_PyThreadState_Current;
12120         PyObject* tmp_tb = tstate->curexc_traceback;
12121         if (tb != tmp_tb) {
12122             Py_INCREF(tb);
12123             tstate->curexc_traceback = tb;
12124             Py_XDECREF(tmp_tb);
12125         }
12126 #endif
12127     }
12128 bad:
12129     Py_XDECREF(owned_instance);
12130     return;
12131 }
12132 #endif
12133 
12134 /* DictGetItem */
12135   #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
__Pyx_PyDict_GetItem(PyObject * d,PyObject * key)12136 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
12137     PyObject *value;
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);
12145                     Py_DECREF(args);
12146                 }
12147             } else {
12148                 PyErr_SetObject(PyExc_KeyError, key);
12149             }
12150         }
12151         return NULL;
12152     }
12153     Py_INCREF(value);
12154     return value;
12155 }
12156 #endif
12157 
12158 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)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);
12162 }
12163 
12164 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)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");
12169 }
12170 
12171 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)12172   static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
12173     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
12174 }
12175 
12176 /* TypeImport */
12177   #ifndef __PYX_HAVE_RT_ImportType
12178 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)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)
12181 {
12182     PyObject *result = 0;
12183     char warning[200];
12184     Py_ssize_t basicsize;
12185 #ifdef Py_LIMITED_API
12186     PyObject *py_basicsize;
12187 #endif
12188     result = PyObject_GetAttrString(module, class_name);
12189     if (!result)
12190         goto bad;
12191     if (!PyType_Check(result)) {
12192         PyErr_Format(PyExc_TypeError,
12193             "%.200s.%.200s is not a type object",
12194             module_name, class_name);
12195         goto bad;
12196     }
12197 #ifndef Py_LIMITED_API
12198     basicsize = ((PyTypeObject *)result)->tp_basicsize;
12199 #else
12200     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
12201     if (!py_basicsize)
12202         goto bad;
12203     basicsize = PyLong_AsSsize_t(py_basicsize);
12204     Py_DECREF(py_basicsize);
12205     py_basicsize = 0;
12206     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
12207         goto bad;
12208 #endif
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);
12214         goto bad;
12215     }
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);
12221         goto bad;
12222     }
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;
12229     }
12230     return (PyTypeObject *)result;
12231 bad:
12232     Py_XDECREF(result);
12233     return NULL;
12234 }
12235 #endif
12236 
12237 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)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;
12243     PyObject *list;
12244     #if PY_MAJOR_VERSION < 3
12245     PyObject *py_import;
12246     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
12247     if (!py_import)
12248         goto bad;
12249     #endif
12250     if (from_list)
12251         list = from_list;
12252     else {
12253         empty_list = PyList_New(0);
12254         if (!empty_list)
12255             goto bad;
12256         list = empty_list;
12257     }
12258     global_dict = PyModule_GetDict(__pyx_m);
12259     if (!global_dict)
12260         goto bad;
12261     empty_dict = PyDict_New();
12262     if (!empty_dict)
12263         goto bad;
12264     {
12265         #if PY_MAJOR_VERSION >= 3
12266         if (level == -1) {
12267             if (strchr(__Pyx_MODULE_NAME, '.')) {
12268                 module = PyImport_ImportModuleLevelObject(
12269                     name, global_dict, empty_dict, list, 1);
12270                 if (!module) {
12271                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
12272                         goto bad;
12273                     PyErr_Clear();
12274                 }
12275             }
12276             level = 0;
12277         }
12278         #endif
12279         if (!module) {
12280             #if PY_MAJOR_VERSION < 3
12281             PyObject *py_level = PyInt_FromLong(level);
12282             if (!py_level)
12283                 goto bad;
12284             module = PyObject_CallFunctionObjArgs(py_import,
12285                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
12286             Py_DECREF(py_level);
12287             #else
12288             module = PyImport_ImportModuleLevelObject(
12289                 name, global_dict, empty_dict, list, level);
12290             #endif
12291         }
12292     }
12293 bad:
12294     #if PY_MAJOR_VERSION < 3
12295     Py_XDECREF(py_import);
12296     #endif
12297     Py_XDECREF(empty_list);
12298     Py_XDECREF(empty_dict);
12299     return module;
12300 }
12301 
12302 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)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));
12309         #else
12310             "cannot import name %S", name);
12311         #endif
12312     }
12313     return value;
12314 }
12315 
12316 /* CLineInTraceback */
12317   #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(PyThreadState * tstate,int c_line)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;
12323 #endif
12324     if (unlikely(!__pyx_cython_runtime)) {
12325         return c_line;
12326     }
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))
12334     } else
12335 #endif
12336     {
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);
12341       } else {
12342         PyErr_Clear();
12343         use_cline = NULL;
12344       }
12345     }
12346     if (!use_cline) {
12347         c_line = 0;
12348         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
12349     }
12350     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
12351         c_line = 0;
12352     }
12353     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
12354     return c_line;
12355 }
12356 #endif
12357 
12358 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)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) {
12362         return count;
12363     }
12364     while (start < end) {
12365         mid = start + (end - start) / 2;
12366         if (code_line < entries[mid].code_line) {
12367             end = mid;
12368         } else if (code_line > entries[mid].code_line) {
12369              start = mid + 1;
12370         } else {
12371             return mid;
12372         }
12373     }
12374     if (code_line <= entries[mid].code_line) {
12375         return mid;
12376     } else {
12377         return mid + 1;
12378     }
12379 }
__pyx_find_code_object(int code_line)12380 static PyCodeObject *__pyx_find_code_object(int code_line) {
12381     PyCodeObject* code_object;
12382     int pos;
12383     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
12384         return NULL;
12385     }
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)) {
12388         return NULL;
12389     }
12390     code_object = __pyx_code_cache.entries[pos].code_object;
12391     Py_INCREF(code_object);
12392     return code_object;
12393 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)12394 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
12395     int pos, i;
12396     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
12397     if (unlikely(!code_line)) {
12398         return;
12399     }
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);
12409         }
12410         return;
12411     }
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;
12416         Py_DECREF(tmp);
12417         return;
12418     }
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)) {
12424             return;
12425         }
12426         __pyx_code_cache.entries = entries;
12427         __pyx_code_cache.max_count = new_max;
12428     }
12429     for (i=__pyx_code_cache.count; i>pos; i--) {
12430         entries[i] = entries[i-1];
12431     }
12432     entries[pos].code_line = code_line;
12433     entries[pos].code_object = code_object;
12434     __pyx_code_cache.count++;
12435     Py_INCREF(code_object);
12436 }
12437 
12438 /* AddTraceback */
12439   #include "compile.h"
12440 #include "frameobject.h"
12441 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)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);
12450     #else
12451     py_srcfile = PyUnicode_FromString(filename);
12452     #endif
12453     if (!py_srcfile) goto bad;
12454     if (c_line) {
12455         #if PY_MAJOR_VERSION < 3
12456         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
12457         #else
12458         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
12459         #endif
12460     }
12461     else {
12462         #if PY_MAJOR_VERSION < 3
12463         py_funcname = PyString_FromString(funcname);
12464         #else
12465         py_funcname = PyUnicode_FromString(funcname);
12466         #endif
12467     }
12468     if (!py_funcname) goto bad;
12469     py_code = __Pyx_PyCode_New(
12470         0,
12471         0,
12472         0,
12473         0,
12474         0,
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,*/
12483         py_line,
12484         __pyx_empty_bytes  /*PyObject *lnotab*/
12485     );
12486     Py_DECREF(py_srcfile);
12487     Py_DECREF(py_funcname);
12488     return py_code;
12489 bad:
12490     Py_XDECREF(py_srcfile);
12491     Py_XDECREF(py_funcname);
12492     return NULL;
12493 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)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;
12499     if (c_line) {
12500         c_line = __Pyx_CLineForTraceback(tstate, c_line);
12501     }
12502     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
12503     if (!py_code) {
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);
12508     }
12509     py_frame = PyFrame_New(
12510         tstate,            /*PyThreadState *tstate,*/
12511         py_code,           /*PyCodeObject *code,*/
12512         __pyx_d,    /*PyObject *globals,*/
12513         0                  /*PyObject *locals*/
12514     );
12515     if (!py_frame) goto bad;
12516     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
12517     PyTraceBack_Here(py_frame);
12518 bad:
12519     Py_XDECREF(py_code);
12520     Py_XDECREF(py_frame);
12521 }
12522 
12523 #if PY_MAJOR_VERSION < 3
__Pyx_GetBuffer(PyObject * obj,Py_buffer * view,int flags)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);
12528     return -1;
12529 }
__Pyx_ReleaseBuffer(Py_buffer * view)12530 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
12531     PyObject *obj = view->obj;
12532     if (!obj) return;
12533     if (PyObject_CheckBuffer(obj)) {
12534         PyBuffer_Release(view);
12535         return;
12536     }
12537     if ((0)) {}
12538         else if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view);
12539     view->obj = NULL;
12540     Py_DECREF(obj);
12541 }
12542 #endif
12543 
12544 
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)\
12551     {\
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;\
12560                 else\
12561                     goto raise_overflow;\
12562             }\
12563         }\
12564         return (target_type) value;\
12565     }
12566 
12567 /* CIntToPy */
__Pyx_PyInt_From_long(long 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;
12571     if (is_unsigned) {
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);
12579 #endif
12580         }
12581     } else {
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);
12587 #endif
12588         }
12589     }
12590     {
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);
12595     }
12596 }
12597 
12598 /* CIntToPy */
__Pyx_PyInt_From_npy_int32(npy_int32 value)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;
12602     if (is_unsigned) {
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);
12610 #endif
12611         }
12612     } else {
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);
12618 #endif
12619         }
12620     }
12621     {
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);
12626     }
12627 }
12628 
12629 /* CIntToPy */
__Pyx_PyInt_From_int(int value)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;
12633     if (is_unsigned) {
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);
12641 #endif
12642         }
12643     } else {
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);
12649 #endif
12650         }
12651     }
12652     {
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);
12657     }
12658 }
12659 
12660 /* None */
__Pyx_pow_long(long b,long e)12661   static CYTHON_INLINE long __Pyx_pow_long(long b, long e) {
12662     long t = b;
12663     switch (e) {
12664         case 3:
12665             t *= b;
12666         CYTHON_FALLTHROUGH;
12667         case 2:
12668             t *= b;
12669         CYTHON_FALLTHROUGH;
12670         case 1:
12671             return t;
12672         case 0:
12673             return 1;
12674     }
12675     #if 1
12676     if (unlikely(e<0)) return 0;
12677     #endif
12678     t = 1;
12679     while (likely(e)) {
12680         t *= (b * (e&1)) | ((~e)&1);
12681         b *= b;
12682         e >>= 1;
12683     }
12684     return t;
12685 }
12686 
12687 /* None */
__Pyx_pow_int(int b,int e)12688   static CYTHON_INLINE int __Pyx_pow_int(int b, int e) {
12689     int t = b;
12690     switch (e) {
12691         case 3:
12692             t *= b;
12693         CYTHON_FALLTHROUGH;
12694         case 2:
12695             t *= b;
12696         CYTHON_FALLTHROUGH;
12697         case 1:
12698             return t;
12699         case 0:
12700             return 1;
12701     }
12702     #if 1
12703     if (unlikely(e<0)) return 0;
12704     #endif
12705     t = 1;
12706     while (likely(e)) {
12707         t *= (b * (e&1)) | ((~e)&1);
12708         b *= b;
12709         e >>= 1;
12710     }
12711     return t;
12712 }
12713 
12714 /* Declarations */
12715   #if CYTHON_CCOMPLEX
12716   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)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);
12719     }
12720   #else
__pyx_t_float_complex_from_parts(float x,float 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;
12723     }
12724   #endif
12725 #else
__pyx_t_float_complex_from_parts(float x,float y)12726     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
12727       __pyx_t_float_complex z;
12728       z.real = x;
12729       z.imag = y;
12730       return z;
12731     }
12732 #endif
12733 
12734 /* Arithmetic */
12735   #if CYTHON_CCOMPLEX
12736 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)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);
12739     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)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;
12744         return z;
12745     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)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;
12750         return z;
12751     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)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;
12756         return z;
12757     }
12758     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)12759     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
12760         if (b.imag == 0) {
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);
12765             } else {
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);
12770             }
12771         } else {
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);
12776         }
12777     }
12778     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)12779     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
12780         if (b.imag == 0) {
12781             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
12782         } else {
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);
12787         }
12788     }
12789     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)12790     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
12791         __pyx_t_float_complex z;
12792         z.real = -a.real;
12793         z.imag = -a.imag;
12794         return z;
12795     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)12796     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
12797        return (a.real == 0) && (a.imag == 0);
12798     }
__Pyx_c_conj_float(__pyx_t_float_complex a)12799     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
12800         __pyx_t_float_complex z;
12801         z.real =  a.real;
12802         z.imag = -a.imag;
12803         return z;
12804     }
12805     #if 1
__Pyx_c_abs_float(__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);
12809           #else
12810             return hypotf(z.real, z.imag);
12811           #endif
12812         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)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) {
12817                 if (b.real < 0) {
12818                     float denom = a.real * a.real + a.imag * a.imag;
12819                     a.real = a.real / denom;
12820                     a.imag = -a.imag / denom;
12821                     b.real = -b.real;
12822                 }
12823                 switch ((int)b.real) {
12824                     case 0:
12825                         z.real = 1;
12826                         z.imag = 0;
12827                         return z;
12828                     case 1:
12829                         return a;
12830                     case 2:
12831                         return __Pyx_c_prod_float(a, a);
12832                     case 3:
12833                         z = __Pyx_c_prod_float(a, a);
12834                         return __Pyx_c_prod_float(z, a);
12835                     case 4:
12836                         z = __Pyx_c_prod_float(a, a);
12837                         return __Pyx_c_prod_float(z, z);
12838                 }
12839             }
12840             if (a.imag == 0) {
12841                 if (a.real == 0) {
12842                     return a;
12843                 } else if (b.imag == 0) {
12844                     z.real = powf(a.real, b.real);
12845                     z.imag = 0;
12846                     return z;
12847                 } else if (a.real > 0) {
12848                     r = a.real;
12849                     theta = 0;
12850                 } else {
12851                     r = -a.real;
12852                     theta = atan2f(0.0, -1.0);
12853                 }
12854             } else {
12855                 r = __Pyx_c_abs_float(a);
12856                 theta = atan2f(a.imag, a.real);
12857             }
12858             lnr = logf(r);
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);
12863             return z;
12864         }
12865     #endif
12866 #endif
12867 
12868 /* Declarations */
12869   #if CYTHON_CCOMPLEX
12870   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)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);
12873     }
12874   #else
__pyx_t_double_complex_from_parts(double x,double 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;
12877     }
12878   #endif
12879 #else
__pyx_t_double_complex_from_parts(double x,double y)12880     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
12881       __pyx_t_double_complex z;
12882       z.real = x;
12883       z.imag = y;
12884       return z;
12885     }
12886 #endif
12887 
12888 /* Arithmetic */
12889   #if CYTHON_CCOMPLEX
12890 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)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);
12893     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)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;
12898         return z;
12899     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)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;
12904         return z;
12905     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)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;
12910         return z;
12911     }
12912     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)12913     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
12914         if (b.imag == 0) {
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);
12919             } else {
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);
12924             }
12925         } else {
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);
12930         }
12931     }
12932     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)12933     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
12934         if (b.imag == 0) {
12935             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
12936         } else {
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);
12941         }
12942     }
12943     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)12944     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
12945         __pyx_t_double_complex z;
12946         z.real = -a.real;
12947         z.imag = -a.imag;
12948         return z;
12949     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)12950     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
12951        return (a.real == 0) && (a.imag == 0);
12952     }
__Pyx_c_conj_double(__pyx_t_double_complex a)12953     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
12954         __pyx_t_double_complex z;
12955         z.real =  a.real;
12956         z.imag = -a.imag;
12957         return z;
12958     }
12959     #if 1
__Pyx_c_abs_double(__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);
12963           #else
12964             return hypot(z.real, z.imag);
12965           #endif
12966         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)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) {
12971                 if (b.real < 0) {
12972                     double denom = a.real * a.real + a.imag * a.imag;
12973                     a.real = a.real / denom;
12974                     a.imag = -a.imag / denom;
12975                     b.real = -b.real;
12976                 }
12977                 switch ((int)b.real) {
12978                     case 0:
12979                         z.real = 1;
12980                         z.imag = 0;
12981                         return z;
12982                     case 1:
12983                         return a;
12984                     case 2:
12985                         return __Pyx_c_prod_double(a, a);
12986                     case 3:
12987                         z = __Pyx_c_prod_double(a, a);
12988                         return __Pyx_c_prod_double(z, a);
12989                     case 4:
12990                         z = __Pyx_c_prod_double(a, a);
12991                         return __Pyx_c_prod_double(z, z);
12992                 }
12993             }
12994             if (a.imag == 0) {
12995                 if (a.real == 0) {
12996                     return a;
12997                 } else if (b.imag == 0) {
12998                     z.real = pow(a.real, b.real);
12999                     z.imag = 0;
13000                     return z;
13001                 } else if (a.real > 0) {
13002                     r = a.real;
13003                     theta = 0;
13004                 } else {
13005                     r = -a.real;
13006                     theta = atan2(0.0, -1.0);
13007                 }
13008             } else {
13009                 r = __Pyx_c_abs_double(a);
13010                 theta = atan2(a.imag, a.real);
13011             }
13012             lnr = log(r);
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);
13017             return z;
13018         }
13019     #endif
13020 #endif
13021 
13022 /* CIntToPy */
__Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value)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;
13026     if (is_unsigned) {
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);
13034 #endif
13035         }
13036     } else {
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);
13042 #endif
13043         }
13044     }
13045     {
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);
13050     }
13051 }
13052 
13053 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)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))
13061         } else {
13062             long val = PyInt_AS_LONG(x);
13063             if (is_unsigned && unlikely(val < 0)) {
13064                 goto raise_neg_overflow;
13065             }
13066             return (int) val;
13067         }
13068     } else
13069 #endif
13070     if (likely(PyLong_Check(x))) {
13071         if (is_unsigned) {
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])
13077                 case 2:
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]));
13083                         }
13084                     }
13085                     break;
13086                 case 3:
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]));
13092                         }
13093                     }
13094                     break;
13095                 case 4:
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]));
13101                         }
13102                     }
13103                     break;
13104             }
13105 #endif
13106 #if CYTHON_COMPILING_IN_CPYTHON
13107             if (unlikely(Py_SIZE(x) < 0)) {
13108                 goto raise_neg_overflow;
13109             }
13110 #else
13111             {
13112                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
13113                 if (unlikely(result < 0))
13114                     return (int) -1;
13115                 if (unlikely(result == 1))
13116                     goto raise_neg_overflow;
13117             }
13118 #endif
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))
13124 #endif
13125             }
13126         } else {
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])
13133                 case -2:
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])));
13139                         }
13140                     }
13141                     break;
13142                 case 2:
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])));
13148                         }
13149                     }
13150                     break;
13151                 case -3:
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])));
13157                         }
13158                     }
13159                     break;
13160                 case 3:
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])));
13166                         }
13167                     }
13168                     break;
13169                 case -4:
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])));
13175                         }
13176                     }
13177                     break;
13178                 case 4:
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])));
13184                         }
13185                     }
13186                     break;
13187             }
13188 #endif
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))
13194 #endif
13195             }
13196         }
13197         {
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");
13201 #else
13202             int val;
13203             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
13204  #if PY_MAJOR_VERSION < 3
13205             if (likely(v) && !PyLong_Check(v)) {
13206                 PyObject *tmp = v;
13207                 v = PyNumber_Long(tmp);
13208                 Py_DECREF(tmp);
13209             }
13210  #endif
13211             if (likely(v)) {
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);
13217                 Py_DECREF(v);
13218                 if (likely(!ret))
13219                     return val;
13220             }
13221 #endif
13222             return (int) -1;
13223         }
13224     } else {
13225         int val;
13226         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
13227         if (!tmp) return (int) -1;
13228         val = __Pyx_PyInt_As_int(tmp);
13229         Py_DECREF(tmp);
13230         return val;
13231     }
13232 raise_overflow:
13233     PyErr_SetString(PyExc_OverflowError,
13234         "value too large to convert to int");
13235     return (int) -1;
13236 raise_neg_overflow:
13237     PyErr_SetString(PyExc_OverflowError,
13238         "can't convert negative value to int");
13239     return (int) -1;
13240 }
13241 
13242 /* CIntFromPy */
__Pyx_PyInt_As_npy_int32(PyObject * x)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))
13250         } else {
13251             long val = PyInt_AS_LONG(x);
13252             if (is_unsigned && unlikely(val < 0)) {
13253                 goto raise_neg_overflow;
13254             }
13255             return (npy_int32) val;
13256         }
13257     } else
13258 #endif
13259     if (likely(PyLong_Check(x))) {
13260         if (is_unsigned) {
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])
13266                 case 2:
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]));
13272                         }
13273                     }
13274                     break;
13275                 case 3:
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]));
13281                         }
13282                     }
13283                     break;
13284                 case 4:
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]));
13290                         }
13291                     }
13292                     break;
13293             }
13294 #endif
13295 #if CYTHON_COMPILING_IN_CPYTHON
13296             if (unlikely(Py_SIZE(x) < 0)) {
13297                 goto raise_neg_overflow;
13298             }
13299 #else
13300             {
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;
13306             }
13307 #endif
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))
13313 #endif
13314             }
13315         } else {
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])
13322                 case -2:
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])));
13328                         }
13329                     }
13330                     break;
13331                 case 2:
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])));
13337                         }
13338                     }
13339                     break;
13340                 case -3:
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])));
13346                         }
13347                     }
13348                     break;
13349                 case 3:
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])));
13355                         }
13356                     }
13357                     break;
13358                 case -4:
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])));
13364                         }
13365                     }
13366                     break;
13367                 case 4:
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])));
13373                         }
13374                     }
13375                     break;
13376             }
13377 #endif
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))
13383 #endif
13384             }
13385         }
13386         {
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");
13390 #else
13391             npy_int32 val;
13392             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
13393  #if PY_MAJOR_VERSION < 3
13394             if (likely(v) && !PyLong_Check(v)) {
13395                 PyObject *tmp = v;
13396                 v = PyNumber_Long(tmp);
13397                 Py_DECREF(tmp);
13398             }
13399  #endif
13400             if (likely(v)) {
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);
13406                 Py_DECREF(v);
13407                 if (likely(!ret))
13408                     return val;
13409             }
13410 #endif
13411             return (npy_int32) -1;
13412         }
13413     } else {
13414         npy_int32 val;
13415         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
13416         if (!tmp) return (npy_int32) -1;
13417         val = __Pyx_PyInt_As_npy_int32(tmp);
13418         Py_DECREF(tmp);
13419         return val;
13420     }
13421 raise_overflow:
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;
13429 }
13430 
13431 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)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))
13439         } else {
13440             long val = PyInt_AS_LONG(x);
13441             if (is_unsigned && unlikely(val < 0)) {
13442                 goto raise_neg_overflow;
13443             }
13444             return (long) val;
13445         }
13446     } else
13447 #endif
13448     if (likely(PyLong_Check(x))) {
13449         if (is_unsigned) {
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])
13455                 case 2:
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]));
13461                         }
13462                     }
13463                     break;
13464                 case 3:
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]));
13470                         }
13471                     }
13472                     break;
13473                 case 4:
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]));
13479                         }
13480                     }
13481                     break;
13482             }
13483 #endif
13484 #if CYTHON_COMPILING_IN_CPYTHON
13485             if (unlikely(Py_SIZE(x) < 0)) {
13486                 goto raise_neg_overflow;
13487             }
13488 #else
13489             {
13490                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
13491                 if (unlikely(result < 0))
13492                     return (long) -1;
13493                 if (unlikely(result == 1))
13494                     goto raise_neg_overflow;
13495             }
13496 #endif
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))
13502 #endif
13503             }
13504         } else {
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])
13511                 case -2:
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])));
13517                         }
13518                     }
13519                     break;
13520                 case 2:
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])));
13526                         }
13527                     }
13528                     break;
13529                 case -3:
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])));
13535                         }
13536                     }
13537                     break;
13538                 case 3:
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])));
13544                         }
13545                     }
13546                     break;
13547                 case -4:
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])));
13553                         }
13554                     }
13555                     break;
13556                 case 4:
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])));
13562                         }
13563                     }
13564                     break;
13565             }
13566 #endif
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))
13572 #endif
13573             }
13574         }
13575         {
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");
13579 #else
13580             long val;
13581             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
13582  #if PY_MAJOR_VERSION < 3
13583             if (likely(v) && !PyLong_Check(v)) {
13584                 PyObject *tmp = v;
13585                 v = PyNumber_Long(tmp);
13586                 Py_DECREF(tmp);
13587             }
13588  #endif
13589             if (likely(v)) {
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);
13595                 Py_DECREF(v);
13596                 if (likely(!ret))
13597                     return val;
13598             }
13599 #endif
13600             return (long) -1;
13601         }
13602     } else {
13603         long val;
13604         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
13605         if (!tmp) return (long) -1;
13606         val = __Pyx_PyInt_As_long(tmp);
13607         Py_DECREF(tmp);
13608         return val;
13609     }
13610 raise_overflow:
13611     PyErr_SetString(PyExc_OverflowError,
13612         "value too large to convert to long");
13613     return (long) -1;
13614 raise_neg_overflow:
13615     PyErr_SetString(PyExc_OverflowError,
13616         "can't convert negative value to long");
13617     return (long) -1;
13618 }
13619 
13620 /* FastTypeChecks */
13621   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)13622 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
13623     while (a) {
13624         a = a->tp_base;
13625         if (a == b)
13626             return 1;
13627     }
13628     return b == &PyBaseObject_Type;
13629 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)13630 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
13631     PyObject *mro;
13632     if (a == b) return 1;
13633     mro = a->tp_mro;
13634     if (likely(mro)) {
13635         Py_ssize_t i, n;
13636         n = PyTuple_GET_SIZE(mro);
13637         for (i = 0; i < n; i++) {
13638             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
13639                 return 1;
13640         }
13641         return 0;
13642     }
13643     return __Pyx_InBases(a, b);
13644 }
13645 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)13646 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
13647     PyObject *exception, *value, *tb;
13648     int res;
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);
13655         res = 0;
13656     }
13657     if (!res) {
13658         res = PyObject_IsSubclass(err, exc_type2);
13659         if (unlikely(res == -1)) {
13660             PyErr_WriteUnraisable(err);
13661             res = 0;
13662         }
13663     }
13664     __Pyx_ErrRestore(exception, value, tb);
13665     return res;
13666 }
13667 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)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;
13670     if (!res) {
13671         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
13672     }
13673     return res;
13674 }
13675 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)13676 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
13677     Py_ssize_t i, n;
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;
13683     }
13684 #endif
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;
13689         #endif
13690         if (likely(PyExceptionClass_Check(t))) {
13691             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
13692         } else {
13693         }
13694     }
13695     return 0;
13696 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)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);
13704         } else {
13705         }
13706     }
13707     return PyErr_GivenExceptionMatches(err, exc_type);
13708 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)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);
13715     }
13716     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
13717 }
13718 #endif
13719 
13720 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)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]) {
13726         char message[200];
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);
13732     }
13733     return 0;
13734 }
13735 
13736 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)13737   static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
13738     while (t->p) {
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);
13744         } else {
13745             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
13746         }
13747         #else
13748         if (t->is_unicode | t->is_str) {
13749             if (t->intern) {
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);
13753             } else {
13754                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
13755             }
13756         } else {
13757             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
13758         }
13759         #endif
13760         if (!*t->p)
13761             return -1;
13762         if (PyObject_Hash(*t->p) == -1)
13763             return -1;
13764         ++t;
13765     }
13766     return 0;
13767 }
13768 
__Pyx_PyUnicode_FromString(const char * c_str)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));
13771 }
__Pyx_PyObject_AsString(PyObject * o)13772 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
13773     Py_ssize_t ignore;
13774     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
13775 }
13776 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
13777 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)13778 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
13779     char* defenc_c;
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
13784     {
13785         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
13786         char* c;
13787         for (c = defenc_c; c < end; c++) {
13788             if ((unsigned char) (*c) >= 128) {
13789                 PyUnicode_AsASCIIString(o);
13790                 return NULL;
13791             }
13792         }
13793     }
13794 #endif
13795     *length = PyBytes_GET_SIZE(defenc);
13796     return defenc_c;
13797 }
13798 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)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);
13805     } else {
13806         PyUnicode_AsASCIIString(o);
13807         return NULL;
13808     }
13809 #else
13810     return PyUnicode_AsUTF8AndSize(o, length);
13811 #endif
13812 }
13813 #endif
13814 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * 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
13817     if (
13818 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
13819             __Pyx_sys_getdefaultencoding_not_ascii &&
13820 #endif
13821             PyUnicode_Check(o)) {
13822         return __Pyx_PyUnicode_AsStringAndSize(o, length);
13823     } else
13824 #endif
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);
13829     } else
13830 #endif
13831     {
13832         char* result;
13833         int r = PyBytes_AsStringAndSize(o, &result, length);
13834         if (unlikely(r < 0)) {
13835             return NULL;
13836         } else {
13837             return result;
13838         }
13839     }
13840 }
__Pyx_PyObject_IsTrue(PyObject * x)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);
13845 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)13846 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
13847     int retval;
13848     if (unlikely(!x)) return -1;
13849     retval = __Pyx_PyObject_IsTrue(x);
13850     Py_DECREF(x);
13851     return retval;
13852 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)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)) {
13861             Py_DECREF(result);
13862             return NULL;
13863         }
13864         return result;
13865     }
13866 #endif
13867     PyErr_Format(PyExc_TypeError,
13868                  "__%.4s__ returned non-%.4s (type %.200s)",
13869                  type_name, type_name, Py_TYPE(result)->tp_name);
13870     Py_DECREF(result);
13871     return NULL;
13872 }
__Pyx_PyNumber_IntOrLong(PyObject * x)13873 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
13874 #if CYTHON_USE_TYPE_SLOTS
13875   PyNumberMethods *m;
13876 #endif
13877   const char *name = NULL;
13878   PyObject *res = NULL;
13879 #if PY_MAJOR_VERSION < 3
13880   if (likely(PyInt_Check(x) || PyLong_Check(x)))
13881 #else
13882   if (likely(PyLong_Check(x)))
13883 #endif
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) {
13889     name = "int";
13890     res = m->nb_int(x);
13891   }
13892   else if (m && m->nb_long) {
13893     name = "long";
13894     res = m->nb_long(x);
13895   }
13896   #else
13897   if (likely(m && m->nb_int)) {
13898     name = "int";
13899     res = m->nb_int(x);
13900   }
13901   #endif
13902 #else
13903   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
13904     res = PyNumber_Int(x);
13905   }
13906 #endif
13907   if (likely(res)) {
13908 #if PY_MAJOR_VERSION < 3
13909     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
13910 #else
13911     if (unlikely(!PyLong_CheckExact(res))) {
13912 #endif
13913         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
13914     }
13915   }
13916   else if (!PyErr_Occurred()) {
13917     PyErr_SetString(PyExc_TypeError,
13918                     "an integer is required");
13919   }
13920   return res;
13921 }
13922 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
13923   Py_ssize_t ival;
13924   PyObject *x;
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);
13929     else
13930         return PyInt_AsSsize_t(b);
13931   }
13932 #endif
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;
13940         return ival;
13941     } else {
13942       switch (size) {
13943          case 2:
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]));
13946            }
13947            break;
13948          case -2:
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]));
13951            }
13952            break;
13953          case 3:
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]));
13956            }
13957            break;
13958          case -3:
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]));
13961            }
13962            break;
13963          case 4:
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]));
13966            }
13967            break;
13968          case -4:
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]));
13971            }
13972            break;
13973       }
13974     }
13975     #endif
13976     return PyLong_AsSsize_t(b);
13977   }
13978   x = PyNumber_Index(b);
13979   if (!x) return -1;
13980   ival = PyInt_AsSsize_t(x);
13981   Py_DECREF(x);
13982   return ival;
13983 }
13984 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
13985   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
13986 }
13987 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
13988     return PyInt_FromSize_t(ival);
13989 }
13990 
13991 
13992 #endif /* Py_PYTHON_H */
13993