Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

9265 lines (8699 sloc) 408.156 kB
/* Generated by Cython 0.16 on Fri Jun 22 14:51:19 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
#error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
#ifndef __stdcall
#define __stdcall
#endif
#ifndef __cdecl
#define __cdecl
#endif
#ifndef __fastcall
#define __fastcall
#endif
#endif
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
#define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
#define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyCFunction_Call PyObject_Call
#else
#define __Pyx_PyCFunction_Call PyCFunction_Call
#endif
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#define PY_FORMAT_SIZE_T ""
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o)
#define PyNumber_Index(o) PyNumber_Int(o)
#define PyIndex_Check(o) PyNumber_Check(o)
#define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#define __PYX_BUILD_PY_SSIZE_T "i"
#else
#define __PYX_BUILD_PY_SSIZE_T "n"
#endif
#if PY_VERSION_HEX < 0x02060000
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
#define PyType_Modified(t)
typedef struct {
void *buf;
PyObject *obj;
Py_ssize_t len;
Py_ssize_t itemsize;
int readonly;
int ndim;
char *format;
Py_ssize_t *shape;
Py_ssize_t *strides;
Py_ssize_t *suboffsets;
void *internal;
} Py_buffer;
#define PyBUF_SIMPLE 0
#define PyBUF_WRITABLE 0x0001
#define PyBUF_FORMAT 0x0004
#define PyBUF_ND 0x0008
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#if PY_MAJOR_VERSION < 3
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
#define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
#define Py_TPFLAGS_CHECKTYPES 0
#define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#endif
#if PY_VERSION_HEX < 0x02060000
#define PyBytesObject PyStringObject
#define PyBytes_Type PyString_Type
#define PyBytes_Check PyString_Check
#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_FromString PyString_FromString
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#define PyBytes_FromFormat PyString_FromFormat
#define PyBytes_DecodeEscape PyString_DecodeEscape
#define PyBytes_AsString PyString_AsString
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
#define PyBytes_Size PyString_Size
#define PyBytes_AS_STRING PyString_AS_STRING
#define PyBytes_GET_SIZE PyString_GET_SIZE
#define PyBytes_Repr PyString_Repr
#define PyBytes_Concat PyString_Concat
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#endif
#if PY_VERSION_HEX < 0x02060000
#define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
#define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
#define PyInt_Check(op) PyLong_Check(op)
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
#define PyInt_FromString PyLong_FromString
#define PyInt_FromUnicode PyLong_FromUnicode
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AS_LONG
#define PyInt_AsSsize_t PyLong_AsSsize_t
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBoolObject PyLongObject
#endif
#if PY_VERSION_HEX < 0x03020000
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
#define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
#define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
#define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
#define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
(PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
#define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
(PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
#define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
(PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
#define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
#define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
#define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
#define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
#else
#define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
#define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
#define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
#define __Pyx_NAMESTR(n) ((char *)(n))
#define __Pyx_DOCSTR(n) ((char *)(n))
#else
#define __Pyx_NAMESTR(n) (n)
#define __Pyx_DOCSTR(n) (n)
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
#else
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
#endif
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__MACS2__cSignal
#define __PYX_HAVE_API__MACS2__cSignal
#include "stdio.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "pythread.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif
/* inline attribute */
#ifndef CYTHON_INLINE
#if defined(__GNUC__)
#define CYTHON_INLINE __inline__
#elif defined(_MSC_VER)
#define CYTHON_INLINE __inline
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_INLINE inline
#else
#define CYTHON_INLINE
#endif
#endif
/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
/* Type Conversion Predeclarations */
#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
#if !defined(CYTHON_CCOMPLEX)
#if defined(__cplusplus)
#define CYTHON_CCOMPLEX 1
#elif defined(_Complex_I)
#define CYTHON_CCOMPLEX 1
#else
#define CYTHON_CCOMPLEX 0
#endif
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#include <complex>
#else
#include <complex.h>
#endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
#undef _Complex_I
#define _Complex_I 1.0fj
#endif
static const char *__pyx_f[] = {
"cSignal.pyx",
"numpy.pxd",
"bool.pxd",
"complex.pxd",
};
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
const char* name; /* for error messages only */
struct __Pyx_StructField_* fields;
size_t size; /* sizeof(type) */
size_t arraysize[8]; /* length of array in each dimension */
int ndim;
char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject */
char is_unsigned;
int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
__Pyx_TypeInfo* type;
const char* name;
size_t offset;
} __Pyx_StructField;
typedef struct {
__Pyx_StructField* field;
size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
__Pyx_StructField root;
__Pyx_BufFmt_StackElem* head;
size_t fmt_offset;
size_t new_count, enc_count;
size_t struct_alignment;
int is_complex;
char enc_type;
char new_packmode;
char enc_packmode;
char is_valid_array;
} __Pyx_BufFmt_Context;
/* "numpy.pxd":722
* # in Cython to enable them only on the right systems.
*
* ctypedef npy_int8 int8_t # <<<<<<<<<<<<<<
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t
*/
typedef npy_int8 __pyx_t_5numpy_int8_t;
/* "numpy.pxd":723
*
* ctypedef npy_int8 int8_t
* ctypedef npy_int16 int16_t # <<<<<<<<<<<<<<
* ctypedef npy_int32 int32_t
* ctypedef npy_int64 int64_t
*/
typedef npy_int16 __pyx_t_5numpy_int16_t;
/* "numpy.pxd":724
* ctypedef npy_int8 int8_t
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t # <<<<<<<<<<<<<<
* ctypedef npy_int64 int64_t
* #ctypedef npy_int96 int96_t
*/
typedef npy_int32 __pyx_t_5numpy_int32_t;
/* "numpy.pxd":725
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t
* ctypedef npy_int64 int64_t # <<<<<<<<<<<<<<
* #ctypedef npy_int96 int96_t
* #ctypedef npy_int128 int128_t
*/
typedef npy_int64 __pyx_t_5numpy_int64_t;
/* "numpy.pxd":729
* #ctypedef npy_int128 int128_t
*
* ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<<
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t
*/
typedef npy_uint8 __pyx_t_5numpy_uint8_t;
/* "numpy.pxd":730
*
* ctypedef npy_uint8 uint8_t
* ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<<
* ctypedef npy_uint32 uint32_t
* ctypedef npy_uint64 uint64_t
*/
typedef npy_uint16 __pyx_t_5numpy_uint16_t;
/* "numpy.pxd":731
* ctypedef npy_uint8 uint8_t
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<<
* ctypedef npy_uint64 uint64_t
* #ctypedef npy_uint96 uint96_t
*/
typedef npy_uint32 __pyx_t_5numpy_uint32_t;
/* "numpy.pxd":732
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t
* ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<<
* #ctypedef npy_uint96 uint96_t
* #ctypedef npy_uint128 uint128_t
*/
typedef npy_uint64 __pyx_t_5numpy_uint64_t;
/* "numpy.pxd":736
* #ctypedef npy_uint128 uint128_t
*
* ctypedef npy_float32 float32_t # <<<<<<<<<<<<<<
* ctypedef npy_float64 float64_t
* #ctypedef npy_float80 float80_t
*/
typedef npy_float32 __pyx_t_5numpy_float32_t;
/* "numpy.pxd":737
*
* ctypedef npy_float32 float32_t
* ctypedef npy_float64 float64_t # <<<<<<<<<<<<<<
* #ctypedef npy_float80 float80_t
* #ctypedef npy_float128 float128_t
*/
typedef npy_float64 __pyx_t_5numpy_float64_t;
/* "numpy.pxd":746
* # The int types are mapped a bit surprising --
* # numpy.int corresponds to 'l' and numpy.long to 'q'
* ctypedef npy_long int_t # <<<<<<<<<<<<<<
* ctypedef npy_longlong long_t
* ctypedef npy_longlong longlong_t
*/
typedef npy_long __pyx_t_5numpy_int_t;
/* "numpy.pxd":747
* # numpy.int corresponds to 'l' and numpy.long to 'q'
* ctypedef npy_long int_t
* ctypedef npy_longlong long_t # <<<<<<<<<<<<<<
* ctypedef npy_longlong longlong_t
*
*/
typedef npy_longlong __pyx_t_5numpy_long_t;
/* "numpy.pxd":748
* ctypedef npy_long int_t
* ctypedef npy_longlong long_t
* ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<<
*
* ctypedef npy_ulong uint_t
*/
typedef npy_longlong __pyx_t_5numpy_longlong_t;
/* "numpy.pxd":750
* ctypedef npy_longlong longlong_t
*
* ctypedef npy_ulong uint_t # <<<<<<<<<<<<<<
* ctypedef npy_ulonglong ulong_t
* ctypedef npy_ulonglong ulonglong_t
*/
typedef npy_ulong __pyx_t_5numpy_uint_t;
/* "numpy.pxd":751
*
* ctypedef npy_ulong uint_t
* ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<<
* ctypedef npy_ulonglong ulonglong_t
*
*/
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
/* "numpy.pxd":752
* ctypedef npy_ulong uint_t
* ctypedef npy_ulonglong ulong_t
* ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<<
*
* ctypedef npy_intp intp_t
*/
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
/* "numpy.pxd":754
* ctypedef npy_ulonglong ulonglong_t
*
* ctypedef npy_intp intp_t # <<<<<<<<<<<<<<
* ctypedef npy_uintp uintp_t
*
*/
typedef npy_intp __pyx_t_5numpy_intp_t;
/* "numpy.pxd":755
*
* ctypedef npy_intp intp_t
* ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<<
*
* ctypedef npy_double float_t
*/
typedef npy_uintp __pyx_t_5numpy_uintp_t;
/* "numpy.pxd":757
* ctypedef npy_uintp uintp_t
*
* ctypedef npy_double float_t # <<<<<<<<<<<<<<
* ctypedef npy_double double_t
* ctypedef npy_longdouble longdouble_t
*/
typedef npy_double __pyx_t_5numpy_float_t;
/* "numpy.pxd":758
*
* ctypedef npy_double float_t
* ctypedef npy_double double_t # <<<<<<<<<<<<<<
* ctypedef npy_longdouble longdouble_t
*
*/
typedef npy_double __pyx_t_5numpy_double_t;
/* "numpy.pxd":759
* ctypedef npy_double float_t
* ctypedef npy_double double_t
* ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<<
*
* ctypedef npy_cfloat cfloat_t
*/
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< float > __pyx_t_float_complex;
#else
typedef float _Complex __pyx_t_float_complex;
#endif
#else
typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< double > __pyx_t_double_complex;
#else
typedef double _Complex __pyx_t_double_complex;
#endif
#else
typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
/*--- Type declarations ---*/
/* "numpy.pxd":761
* ctypedef npy_longdouble longdouble_t
*
* ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<<
* ctypedef npy_cdouble cdouble_t
* ctypedef npy_clongdouble clongdouble_t
*/
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
/* "numpy.pxd":762
*
* ctypedef npy_cfloat cfloat_t
* ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<<
* ctypedef npy_clongdouble clongdouble_t
*
*/
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
/* "numpy.pxd":763
* ctypedef npy_cfloat cfloat_t
* ctypedef npy_cdouble cdouble_t
* ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<<
*
* ctypedef npy_cdouble complex_t
*/
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
/* "numpy.pxd":765
* ctypedef npy_clongdouble clongdouble_t
*
* ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_MultiIterNew1(a):
*/
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_opt_args_5MACS2_7cSignal_maxima;
struct __pyx_opt_args_5MACS2_7cSignal_enforce_valleys;
struct __pyx_opt_args_5MACS2_7cSignal_savitzky_golay_order2;
/* "MACS2/cSignal.pyx":7
* from math import sqrt as mathsqrt
*
* cpdef maxima(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* int window_size=51):
* """return the local maxima in a signal after applying a 2nd order
*/
struct __pyx_opt_args_5MACS2_7cSignal_maxima {
int __pyx_n;
int window_size;
};
/* "MACS2/cSignal.pyx":149
* # return n
*
* cpdef enforce_valleys(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* np.ndarray[np.int32_t, ndim=1] summits,
* float min_valley = 0.8):
*/
struct __pyx_opt_args_5MACS2_7cSignal_enforce_valleys {
int __pyx_n;
float min_valley;
};
/* "MACS2/cSignal.pyx":185
* # needs sane input paramters, window size > 4
* # switched to double precision for internal accuracy
* cpdef savitzky_golay_order2(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* int window_size, int deriv=0):
* r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
*/
struct __pyx_opt_args_5MACS2_7cSignal_savitzky_golay_order2 {
int __pyx_n;
int deriv;
};
#ifndef CYTHON_REFNANNY
#define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
typedef struct {
void (*INCREF)(void*, PyObject*, int);
void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int);
void* (*SetupContext)(const char*, int, const char*);
void (*FinishContext)(void**);
} __Pyx_RefNannyAPIStruct;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
#define __Pyx_RefNannySetupContext(name, acquire_gil) \
if (acquire_gil) { \
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
PyGILState_Release(__pyx_gilstate_save); \
} else { \
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
}
#else
#define __Pyx_RefNannySetupContext(name, acquire_gil) \
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
#define __Pyx_RefNannyFinishContext() \
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
#define __Pyx_RefNannyDeclarations
#define __Pyx_RefNannySetupContext(name, acquire_gil)
#define __Pyx_RefNannyFinishContext()
#define __Pyx_INCREF(r) Py_INCREF(r)
#define __Pyx_DECREF(r) Py_DECREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_XINCREF(r) Py_XINCREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_XGOTREF(r)
#define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
__Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
PyObject *r;
if (!j) return NULL;
r = PyObject_GetItem(o, j);
Py_DECREF(j);
return r;
}
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_List_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
if (likely(o != Py_None)) {
if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, i);
Py_INCREF(r);
return r;
}
else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
Py_INCREF(r);
return r;
}
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_Tuple_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
if (likely(o != Py_None)) {
if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, i);
Py_INCREF(r);
return r;
}
else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
Py_INCREF(r);
return r;
}
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
if (PyList_CheckExact(o)) {
Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
}
else if (PyTuple_CheckExact(o)) {
Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
}
else if (likely(i >= 0)) {
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_item)) {
return m->sq_item(o, i);
}
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
const char* function_name); /*proto*/
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact); /*proto*/
static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/
#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
static CYTHON_INLINE long __Pyx_mod_long(long, long); /* proto */
static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/
typedef struct {
Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
size_t refcount;
Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
__Pyx_Buffer *rcbuffer;
char *data;
__Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
#define __Pyx_GetBuffer PyObject_GetBuffer
#define __Pyx_ReleaseBuffer PyBuffer_Release
#endif
static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name);
static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int32(npy_int32);
static CYTHON_INLINE npy_int32 __Pyx_PyInt_from_py_npy_int32(PyObject *);
static CYTHON_INLINE long __Pyx_pow_long(long, long); /* proto */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#define __Pyx_CREAL(z) ((z).real())
#define __Pyx_CIMAG(z) ((z).imag())
#else
#define __Pyx_CREAL(z) (__real__(z))
#define __Pyx_CIMAG(z) (__imag__(z))
#endif
#else
#define __Pyx_CREAL(z) ((z).real)
#define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
#define __Pyx_SET_CREAL(z,x) ((z).real(x))
#define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
#define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
#define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
#if CYTHON_CCOMPLEX
#define __Pyx_c_eqf(a, b) ((a)==(b))
#define __Pyx_c_sumf(a, b) ((a)+(b))
#define __Pyx_c_difff(a, b) ((a)-(b))
#define __Pyx_c_prodf(a, b) ((a)*(b))
#define __Pyx_c_quotf(a, b) ((a)/(b))
#define __Pyx_c_negf(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zerof(z) ((z)==(float)0)
#define __Pyx_c_conjf(z) (::std::conj(z))
#if 1
#define __Pyx_c_absf(z) (::std::abs(z))
#define __Pyx_c_powf(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zerof(z) ((z)==0)
#define __Pyx_c_conjf(z) (conjf(z))
#if 1
#define __Pyx_c_absf(z) (cabsf(z))
#define __Pyx_c_powf(a, b) (cpowf(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
#if 1
static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
#endif
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
#if CYTHON_CCOMPLEX
#define __Pyx_c_eq(a, b) ((a)==(b))
#define __Pyx_c_sum(a, b) ((a)+(b))
#define __Pyx_c_diff(a, b) ((a)-(b))
#define __Pyx_c_prod(a, b) ((a)*(b))
#define __Pyx_c_quot(a, b) ((a)/(b))
#define __Pyx_c_neg(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zero(z) ((z)==(double)0)
#define __Pyx_c_conj(z) (::std::conj(z))
#if 1
#define __Pyx_c_abs(z) (::std::abs(z))
#define __Pyx_c_pow(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zero(z) ((z)==0)
#define __Pyx_c_conj(z) (conj(z))
#if 1
#define __Pyx_c_abs(z) (cabs(z))
#define __Pyx_c_pow(a, b) (cpow(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
#if 1
static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
#endif
#endif
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
static void __Pyx_WriteUnraisable(const char *name, int clineno,
int lineno, const char *filename); /*proto*/
static int __Pyx_check_binary_version(void);
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/
static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
typedef struct {
int code_line;
PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
int count;
int max_count;
__Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename); /*proto*/
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from 'cpython.buffer' */
/* Module declarations from 'cpython.ref' */
/* Module declarations from 'libc.stdio' */
/* Module declarations from 'cpython.object' */
/* Module declarations from 'libc.stdlib' */
/* Module declarations from 'numpy' */
/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
/* Module declarations from 'cpython.version' */
/* Module declarations from 'cpython.exc' */
/* Module declarations from 'cpython.module' */
/* Module declarations from 'cpython.mem' */
/* Module declarations from 'cpython.tuple' */
/* Module declarations from 'cpython.list' */
/* Module declarations from 'cpython.sequence' */
/* Module declarations from 'cpython.mapping' */
/* Module declarations from 'cpython.iterator' */
/* Module declarations from 'cpython.type' */
/* Module declarations from 'cpython.number' */
/* Module declarations from 'cpython.int' */
/* Module declarations from '__builtin__' */
/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
/* Module declarations from 'cpython.long' */
/* Module declarations from 'cpython.float' */
/* Module declarations from '__builtin__' */
/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
/* Module declarations from 'cpython.string' */
/* Module declarations from 'cpython.unicode' */
/* Module declarations from 'cpython.dict' */
/* Module declarations from 'cpython.instance' */
/* Module declarations from 'cpython.function' */
/* Module declarations from 'cpython.method' */
/* Module declarations from 'cpython.weakref' */
/* Module declarations from 'cpython.getargs' */
/* Module declarations from 'cpython.pythread' */
/* Module declarations from 'cpython.pystate' */
/* Module declarations from 'cpython.cobject' */
/* Module declarations from 'cpython.oldbuffer' */
/* Module declarations from 'cpython.set' */
/* Module declarations from 'cpython.bytes' */
/* Module declarations from 'cpython.pycapsule' */
/* Module declarations from 'cpython' */
/* Module declarations from 'MACS2.cSignal' */
static PyObject *__pyx_f_5MACS2_7cSignal_maxima(PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5MACS2_7cSignal_maxima *__pyx_optional_args); /*proto*/
static PyArrayObject *__pyx_f_5MACS2_7cSignal_internal_minima(PyArrayObject *, PyArrayObject *); /*proto*/
static CYTHON_INLINE float __pyx_f_5MACS2_7cSignal_sqrt(float); /*proto*/
static PyObject *__pyx_f_5MACS2_7cSignal_enforce_peakyness(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/
static PyBoolObject *__pyx_f_5MACS2_7cSignal_is_valid_peak(PyArrayObject *, int); /*proto*/
static PyBoolObject *__pyx_f_5MACS2_7cSignal_too_flat(PyArrayObject *); /*proto*/
static PyArrayObject *__pyx_f_5MACS2_7cSignal_hard_clip(PyArrayObject *, int); /*proto*/
static PyObject *__pyx_f_5MACS2_7cSignal_enforce_valleys(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5MACS2_7cSignal_enforce_valleys *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_5MACS2_7cSignal_savitzky_golay_order2(PyArrayObject *, int, int __pyx_skip_dispatch, struct __pyx_opt_args_5MACS2_7cSignal_savitzky_golay_order2 *__pyx_optional_args); /*proto*/
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 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_5numpy_int32_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t = { "int64_t", NULL, sizeof(__pyx_t_5numpy_int64_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_5numpy_int64_t), 0 };
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 };
#define __Pyx_MODULE_NAME "MACS2.cSignal"
int __pyx_module_is_main_MACS2__cSignal = 0;
/* Implementation of 'MACS2.cSignal' */
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_pf_5MACS2_7cSignal_maxima(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_signal, int __pyx_v_window_size); /* proto */
static PyObject *__pyx_pf_5MACS2_7cSignal_2enforce_peakyness(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_signal, PyArrayObject *__pyx_v_maxima); /* proto */
static PyObject *__pyx_pf_5MACS2_7cSignal_4enforce_valleys(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_signal, PyArrayObject *__pyx_v_summits, float __pyx_v_min_valley); /* proto */
static PyObject *__pyx_pf_5MACS2_7cSignal_6savitzky_golay_order2(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_signal, int __pyx_v_window_size, int __pyx_v_deriv); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static char __pyx_k_1[] = "savitzky_golay_order2";
static char __pyx_k_8[] = "ndarray is not C contiguous";
static char __pyx_k_10[] = "ndarray is not Fortran contiguous";
static char __pyx_k_12[] = "Non-native byte order not supported";
static char __pyx_k_14[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_15[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_18[] = "Format string allocated too short.";
static char __pyx_k__A[] = "A";
static char __pyx_k__B[] = "B";
static char __pyx_k__H[] = "H";
static char __pyx_k__I[] = "I";
static char __pyx_k__L[] = "L";
static char __pyx_k__O[] = "O";
static char __pyx_k__Q[] = "Q";
static char __pyx_k__b[] = "b";
static char __pyx_k__d[] = "d";
static char __pyx_k__f[] = "f";
static char __pyx_k__g[] = "g";
static char __pyx_k__h[] = "h";
static char __pyx_k__i[] = "i";
static char __pyx_k__l[] = "l";
static char __pyx_k__q[] = "q";
static char __pyx_k__Zd[] = "Zd";
static char __pyx_k__Zf[] = "Zf";
static char __pyx_k__Zg[] = "Zg";
static char __pyx_k__np[] = "np";
static char __pyx_k__abs[] = "abs";
static char __pyx_k__any[] = "any";
static char __pyx_k__mat[] = "mat";
static char __pyx_k__min[] = "min";
static char __pyx_k__copy[] = "copy";
static char __pyx_k__diff[] = "diff";
static char __pyx_k__math[] = "math";
static char __pyx_k__mode[] = "mode";
static char __pyx_k__pinv[] = "pinv";
static char __pyx_k__sign[] = "sign";
static char __pyx_k__sqrt[] = "sqrt";
static char __pyx_k__deriv[] = "deriv";
static char __pyx_k__dtype[] = "dtype";
static char __pyx_k__int32[] = "int32";
static char __pyx_k__int64[] = "int64";
static char __pyx_k__numpy[] = "numpy";
static char __pyx_k__range[] = "range";
static char __pyx_k__shape[] = "shape";
static char __pyx_k__valid[] = "valid";
static char __pyx_k__where[] = "where";
static char __pyx_k__zeros[] = "zeros";
static char __pyx_k__astype[] = "astype";
static char __pyx_k__linalg[] = "linalg";
static char __pyx_k__maxima[] = "maxima";
static char __pyx_k__resize[] = "resize";
static char __pyx_k__signal[] = "signal";
static char __pyx_k__unique[] = "unique";
static char __pyx_k__float32[] = "float32";
static char __pyx_k__float64[] = "float64";
static char __pyx_k__summits[] = "summits";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__convolve[] = "convolve";
static char __pyx_k__mathsqrt[] = "mathsqrt";
static char __pyx_k__refcheck[] = "refcheck";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__min_valley[] = "min_valley";
static char __pyx_k__concatenate[] = "concatenate";
static char __pyx_k__window_size[] = "window_size";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static PyObject *__pyx_n_s_1;
static PyObject *__pyx_kp_u_10;
static PyObject *__pyx_kp_u_12;
static PyObject *__pyx_kp_u_14;
static PyObject *__pyx_kp_u_15;
static PyObject *__pyx_kp_u_18;
static PyObject *__pyx_kp_u_8;
static PyObject *__pyx_n_s__A;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__abs;
static PyObject *__pyx_n_s__any;
static PyObject *__pyx_n_s__astype;
static PyObject *__pyx_n_s__concatenate;
static PyObject *__pyx_n_s__convolve;
static PyObject *__pyx_n_s__copy;
static PyObject *__pyx_n_s__deriv;
static PyObject *__pyx_n_s__diff;
static PyObject *__pyx_n_s__dtype;
static PyObject *__pyx_n_s__float32;
static PyObject *__pyx_n_s__float64;
static PyObject *__pyx_n_s__int32;
static PyObject *__pyx_n_s__int64;
static PyObject *__pyx_n_s__linalg;
static PyObject *__pyx_n_s__mat;
static PyObject *__pyx_n_s__math;
static PyObject *__pyx_n_s__mathsqrt;
static PyObject *__pyx_n_s__maxima;
static PyObject *__pyx_n_s__min;
static PyObject *__pyx_n_s__min_valley;
static PyObject *__pyx_n_s__mode;
static PyObject *__pyx_n_s__np;
static PyObject *__pyx_n_s__numpy;
static PyObject *__pyx_n_s__pinv;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__refcheck;
static PyObject *__pyx_n_s__resize;
static PyObject *__pyx_n_s__shape;
static PyObject *__pyx_n_s__sign;
static PyObject *__pyx_n_s__signal;
static PyObject *__pyx_n_s__sqrt;
static PyObject *__pyx_n_s__summits;
static PyObject *__pyx_n_s__unique;
static PyObject *__pyx_n_s__valid;
static PyObject *__pyx_n_s__where;
static PyObject *__pyx_n_s__window_size;
static PyObject *__pyx_n_s__zeros;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_6;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_15;
static PyObject *__pyx_k_slice_4;
static PyObject *__pyx_k_slice_5;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_3;
static PyObject *__pyx_k_tuple_6;
static PyObject *__pyx_k_tuple_7;
static PyObject *__pyx_k_tuple_9;
static PyObject *__pyx_k_tuple_11;
static PyObject *__pyx_k_tuple_13;
static PyObject *__pyx_k_tuple_16;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_19;
/* "MACS2/cSignal.pyx":7
* from math import sqrt as mathsqrt
*
* cpdef maxima(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* int window_size=51):
* """return the local maxima in a signal after applying a 2nd order
*/
static PyObject *__pyx_pw_5MACS2_7cSignal_1maxima(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5MACS2_7cSignal_maxima(PyArrayObject *__pyx_v_signal, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_5MACS2_7cSignal_maxima *__pyx_optional_args) {
int __pyx_v_window_size = ((int)51);
PyArrayObject *__pyx_v_m = 0;
__Pyx_LocalBuf_ND __pyx_pybuffernd_m;
__Pyx_Buffer __pyx_pybuffer_m;
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyArrayObject *__pyx_t_8 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("maxima", 0);
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_window_size = __pyx_optional_args->window_size;
}
}
__pyx_pybuffer_m.pybuffer.buf = NULL;
__pyx_pybuffer_m.refcount = 0;
__pyx_pybuffernd_m.data = NULL;
__pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
/* "MACS2/cSignal.pyx":12
* Savitsky-Golay (polynomial) filter using window_size specified
* """
* cdef np.ndarray[np.int32_t, ndim=1] m = np.where(np.diff(np.sign(savitzky_golay_order2(signal, window_size, deriv=1))) == 2)[0].astype('int32') # <<<<<<<<<<<<<<
* return m
*
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__where); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__diff); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__sign); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_5 = PyInt_FromLong(__pyx_v_window_size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_INCREF(((PyObject *)__pyx_v_signal));
PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_signal));
__Pyx_GIVEREF(((PyObject *)__pyx_v_signal));
PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
__pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__deriv), __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
__Pyx_GIVEREF(__pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
__Pyx_GIVEREF(__pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
__pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_int_2, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
__pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_GetItemInt(__pyx_t_5, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_5 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__astype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_8 = ((PyArrayObject *)__pyx_t_7);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
__pyx_v_m = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_m.rcbuffer->pybuffer.buf = NULL;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
} else {__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];
}
}
__pyx_t_8 = 0;
__pyx_v_m = ((PyArrayObject *)__pyx_t_7);
__pyx_t_7 = 0;
/* "MACS2/cSignal.pyx":13
* """
* cdef np.ndarray[np.int32_t, ndim=1] m = np.where(np.diff(np.sign(savitzky_golay_order2(signal, window_size, deriv=1))) == 2)[0].astype('int32')
* return m # <<<<<<<<<<<<<<
*
* cdef np.ndarray[np.int32_t, ndim=1] internal_minima(np.ndarray[np.float32_t, ndim=1] signal,
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_m));
__pyx_r = ((PyObject *)__pyx_v_m);
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.maxima", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XDECREF((PyObject *)__pyx_v_m);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_7cSignal_1maxima(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_7cSignal_maxima[] = "return the local maxima in a signal after applying a 2nd order\n Savitsky-Golay (polynomial) filter using window_size specified \n ";
static PyObject *__pyx_pw_5MACS2_7cSignal_1maxima(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyArrayObject *__pyx_v_signal = 0;
int __pyx_v_window_size;
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__signal,&__pyx_n_s__window_size,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("maxima (wrapper)", 0);
__pyx_self = __pyx_self;
{
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__signal);
if (likely(values[0])) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__window_size);
if (value) { values[1] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "maxima") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
if (values[1]) {
} else {
__pyx_v_window_size = ((int)51);
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_signal = ((PyArrayObject *)values[0]);
if (values[1]) {
__pyx_v_window_size = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_window_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
} else {
__pyx_v_window_size = ((int)51);
}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("maxima", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("MACS2.cSignal.maxima", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_signal), __pyx_ptype_5numpy_ndarray, 1, "signal", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = __pyx_pf_5MACS2_7cSignal_maxima(__pyx_self, __pyx_v_signal, __pyx_v_window_size);
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":7
* from math import sqrt as mathsqrt
*
* cpdef maxima(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* int window_size=51):
* """return the local maxima in a signal after applying a 2nd order
*/
static PyObject *__pyx_pf_5MACS2_7cSignal_maxima(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_signal, int __pyx_v_window_size) {
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
struct __pyx_opt_args_5MACS2_7cSignal_maxima __pyx_t_2;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("maxima", 0);
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
__Pyx_XDECREF(__pyx_r);
__pyx_t_2.__pyx_n = 1;
__pyx_t_2.window_size = __pyx_v_window_size;
__pyx_t_1 = __pyx_f_5MACS2_7cSignal_maxima(__pyx_v_signal, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.maxima", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":15
* return m
*
* cdef np.ndarray[np.int32_t, ndim=1] internal_minima(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* np.ndarray[np.int32_t, ndim=1] maxima):
* cdef:
*/
static PyArrayObject *__pyx_f_5MACS2_7cSignal_internal_minima(PyArrayObject *__pyx_v_signal, PyArrayObject *__pyx_v_maxima) {
PyArrayObject *__pyx_v_ret = 0;
int __pyx_v_n;
int __pyx_v_i;
PyObject *__pyx_v_pos1 = NULL;
PyObject *__pyx_v_pos2 = NULL;
__Pyx_LocalBuf_ND __pyx_pybuffernd_maxima;
__Pyx_Buffer __pyx_pybuffer_maxima;
__Pyx_LocalBuf_ND __pyx_pybuffernd_ret;
__Pyx_Buffer __pyx_pybuffer_ret;
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyArrayObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyArrayObject *__pyx_t_8 = NULL;
int __pyx_t_9;
long __pyx_t_10;
long __pyx_t_11;
int __pyx_t_12;
Py_ssize_t __pyx_t_13;
Py_ssize_t __pyx_t_14;
PyObject *__pyx_t_15 = NULL;
__pyx_t_5numpy_int32_t __pyx_t_16;
int __pyx_t_17;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("internal_minima", 0);
__pyx_pybuffer_ret.pybuffer.buf = NULL;
__pyx_pybuffer_ret.refcount = 0;
__pyx_pybuffernd_ret.data = NULL;
__pyx_pybuffernd_ret.rcbuffer = &__pyx_pybuffer_ret;
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
__pyx_pybuffer_maxima.pybuffer.buf = NULL;
__pyx_pybuffer_maxima.refcount = 0;
__pyx_pybuffernd_maxima.data = NULL;
__pyx_pybuffernd_maxima.rcbuffer = &__pyx_pybuffer_maxima;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
/* "MACS2/cSignal.pyx":19
* cdef:
* np.ndarray[np.int32_t, ndim=1] ret
* int n = maxima.shape[0] # <<<<<<<<<<<<<<
* int i, v, v2
* if n == 0 or n == 1:
*/
__pyx_v_n = (__pyx_v_maxima->dimensions[0]);
/* "MACS2/cSignal.pyx":21
* int n = maxima.shape[0]
* int i, v, v2
* if n == 0 or n == 1: # <<<<<<<<<<<<<<
* ret = np.ndarray(0, 'int32')
* return ret
*/
switch (__pyx_v_n) {
case 0:
case 1:
/* "MACS2/cSignal.pyx":22
* int i, v, v2
* if n == 0 or n == 1:
* ret = np.ndarray(0, 'int32') # <<<<<<<<<<<<<<
* return ret
* else:
*/
__pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret.rcbuffer->pybuffer);
__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);
if (unlikely(__pyx_t_2 < 0)) {
PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
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)) {
Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5);
__Pyx_RaiseBufferFallbackError();
} else {
PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5);
}
}
__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];
if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_ret = ((PyArrayObject *)__pyx_t_1);
__pyx_t_1 = 0;
/* "MACS2/cSignal.pyx":23
* if n == 0 or n == 1:
* ret = np.ndarray(0, 'int32')
* return ret # <<<<<<<<<<<<<<
* else:
* ret = np.zeros(n - 1, 'int32')
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__Pyx_INCREF(((PyObject *)__pyx_v_ret));
__pyx_r = ((PyArrayObject *)__pyx_v_ret);
goto __pyx_L0;
break;
default:
/* "MACS2/cSignal.pyx":25
* return ret
* else:
* ret = np.zeros(n - 1, 'int32') # <<<<<<<<<<<<<<
* pos1 = maxima[i]
* for i in range(n - 1):
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyInt_FromLong((__pyx_v_n - 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)__pyx_n_s__int32));
PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__int32));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__int32));
__pyx_t_1 = 0;
__pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret.rcbuffer->pybuffer);
__pyx_t_2 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_2 < 0)) {
PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
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)) {
Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3);
__Pyx_RaiseBufferFallbackError();
} else {
PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_3);
}
}
__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];
if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_8 = 0;
__pyx_v_ret = ((PyArrayObject *)__pyx_t_1);
__pyx_t_1 = 0;
/* "MACS2/cSignal.pyx":26
* else:
* ret = np.zeros(n - 1, 'int32')
* pos1 = maxima[i] # <<<<<<<<<<<<<<
* for i in range(n - 1):
* pos2 = maxima[i + 1]
*/
__pyx_t_2 = __pyx_v_i;
__pyx_t_9 = -1;
if (__pyx_t_2 < 0) {
__pyx_t_2 += __pyx_pybuffernd_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_2 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_maxima.diminfo[0].shape)) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __Pyx_PyInt_to_py_npy_int32((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_maxima.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_maxima.diminfo[0].strides))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_pos1 = __pyx_t_1;
__pyx_t_1 = 0;
/* "MACS2/cSignal.pyx":27
* ret = np.zeros(n - 1, 'int32')
* pos1 = maxima[i]
* for i in range(n - 1): # <<<<<<<<<<<<<<
* pos2 = maxima[i + 1]
* ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
*/
__pyx_t_10 = (__pyx_v_n - 1);
for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9+=1) {
__pyx_v_i = __pyx_t_9;
/* "MACS2/cSignal.pyx":28
* pos1 = maxima[i]
* for i in range(n - 1):
* pos2 = maxima[i + 1] # <<<<<<<<<<<<<<
* ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
* pos1 = pos2
*/
__pyx_t_11 = (__pyx_v_i + 1);
__pyx_t_12 = -1;
if (__pyx_t_11 < 0) {
__pyx_t_11 += __pyx_pybuffernd_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_11 < 0)) __pyx_t_12 = 0;
} else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_maxima.diminfo[0].shape)) __pyx_t_12 = 0;
if (unlikely(__pyx_t_12 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_12);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __Pyx_PyInt_to_py_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_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_v_pos2);
__pyx_v_pos2 = __pyx_t_1;
__pyx_t_1 = 0;
/* "MACS2/cSignal.pyx":29
* for i in range(n - 1):
* pos2 = maxima[i + 1]
* ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1 # <<<<<<<<<<<<<<
* pos1 = pos2
* return ret
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_7 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__where); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_v_pos1); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_v_pos2); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_signal), __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_v_pos1); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_v_pos2); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_6 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_signal), __pyx_t_14, __pyx_t_13); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_15 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__min); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_15);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
__pyx_t_15 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_EQ); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_15);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15);
__Pyx_GIVEREF(__pyx_t_15);
__pyx_t_15 = 0;
__pyx_t_15 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_15);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
__pyx_t_6 = __Pyx_GetItemInt(__pyx_t_15, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
__pyx_t_15 = __Pyx_GetItemInt(__pyx_t_6, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_15);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = PyNumber_Add(__pyx_t_15, __pyx_v_pos1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
__pyx_t_16 = __Pyx_PyInt_from_py_npy_int32(__pyx_t_6); if (unlikely((__pyx_t_16 == (npy_int32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_12 = __pyx_v_i;
__pyx_t_17 = -1;
if (__pyx_t_12 < 0) {
__pyx_t_12 += __pyx_pybuffernd_ret.diminfo[0].shape;
if (unlikely(__pyx_t_12 < 0)) __pyx_t_17 = 0;
} else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_ret.diminfo[0].shape)) __pyx_t_17 = 0;
if (unlikely(__pyx_t_17 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_17);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_ret.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_ret.diminfo[0].strides) = __pyx_t_16;
/* "MACS2/cSignal.pyx":30
* pos2 = maxima[i + 1]
* ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
* pos1 = pos2 # <<<<<<<<<<<<<<
* return ret
*
*/
__Pyx_INCREF(__pyx_v_pos2);
__Pyx_DECREF(__pyx_v_pos1);
__pyx_v_pos1 = __pyx_v_pos2;
}
/* "MACS2/cSignal.pyx":31
* ret[i] = np.where(signal[pos1:pos2] == signal[pos1:pos2].min())[0][0] + pos1
* pos1 = pos2
* return ret # <<<<<<<<<<<<<<
*
* cdef inline float sqrt(float threshold):
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__Pyx_INCREF(((PyObject *)__pyx_v_ret));
__pyx_r = ((PyArrayObject *)__pyx_v_ret);
goto __pyx_L0;
break;
}
__pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_15);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.internal_minima", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XDECREF((PyObject *)__pyx_v_ret);
__Pyx_XDECREF(__pyx_v_pos1);
__Pyx_XDECREF(__pyx_v_pos2);
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":33
* return ret
*
* cdef inline float sqrt(float threshold): # <<<<<<<<<<<<<<
* return mathsqrt(threshold)
*
*/
static CYTHON_INLINE float __pyx_f_5MACS2_7cSignal_sqrt(float __pyx_v_threshold) {
float __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
float __pyx_t_4;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("sqrt", 0);
/* "MACS2/cSignal.pyx":34
*
* cdef inline float sqrt(float threshold):
* return mathsqrt(threshold) # <<<<<<<<<<<<<<
*
* cpdef enforce_peakyness(np.ndarray[np.float32_t, ndim=1] signal,
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__mathsqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__pyx_t_4 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_4;
goto __pyx_L0;
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_WriteUnraisable("MACS2.cSignal.sqrt", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":36
* return mathsqrt(threshold)
*
* cpdef enforce_peakyness(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* np.ndarray[np.int32_t, ndim=1] maxima):
* """requires peaks described by a signal and a set of points where the signal
*/
static PyObject *__pyx_pw_5MACS2_7cSignal_3enforce_peakyness(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5MACS2_7cSignal_enforce_peakyness(PyArrayObject *__pyx_v_signal, PyArrayObject *__pyx_v_maxima, CYTHON_UNUSED int __pyx_skip_dispatch) {
PyArrayObject *__pyx_v_minima = 0;
PyArrayObject *__pyx_v_new_signal = 0;
int __pyx_v_n;
float __pyx_v_threshold;
PyArrayObject *__pyx_v_peaky_maxima = 0;
int __pyx_v_j;
PyObject *__pyx_v_i = NULL;
PyObject *__pyx_v_new_maximum = NULL;
__Pyx_LocalBuf_ND __pyx_pybuffernd_maxima;
__Pyx_Buffer __pyx_pybuffer_maxima;
__Pyx_LocalBuf_ND __pyx_pybuffernd_minima;
__Pyx_Buffer __pyx_pybuffer_minima;
__Pyx_LocalBuf_ND __pyx_pybuffernd_new_signal;
__Pyx_Buffer __pyx_pybuffer_new_signal;
__Pyx_LocalBuf_ND __pyx_pybuffernd_peaky_maxima;
__Pyx_Buffer __pyx_pybuffer_peaky_maxima;
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyArrayObject *__pyx_t_3 = NULL;
int __pyx_t_4;
long __pyx_t_5;
int __pyx_t_6;
__pyx_t_5numpy_int32_t __pyx_t_7;
long __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
PyArrayObject *__pyx_t_10 = NULL;
PyObject *__pyx_t_11 = NULL;
PyObject *__pyx_t_12 = NULL;
PyObject *__pyx_t_13 = NULL;
long __pyx_t_14;
long __pyx_t_15;
long __pyx_t_16;
Py_ssize_t __pyx_t_17;
PyObject *(*__pyx_t_18)(PyObject *);
PyObject *__pyx_t_19 = NULL;
PyObject *__pyx_t_20 = NULL;
float __pyx_t_21;
Py_ssize_t __pyx_t_22;
Py_ssize_t __pyx_t_23;
__pyx_t_5numpy_int32_t __pyx_t_24;
int __pyx_t_25;
long __pyx_t_26;
long __pyx_t_27;
long __pyx_t_28;
long __pyx_t_29;
long __pyx_t_30;
int __pyx_t_31;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("enforce_peakyness", 0);
__pyx_pybuffer_minima.pybuffer.buf = NULL;
__pyx_pybuffer_minima.refcount = 0;
__pyx_pybuffernd_minima.data = NULL;
__pyx_pybuffernd_minima.rcbuffer = &__pyx_pybuffer_minima;
__pyx_pybuffer_new_signal.pybuffer.buf = NULL;
__pyx_pybuffer_new_signal.refcount = 0;
__pyx_pybuffernd_new_signal.data = NULL;
__pyx_pybuffernd_new_signal.rcbuffer = &__pyx_pybuffer_new_signal;
__pyx_pybuffer_peaky_maxima.pybuffer.buf = NULL;
__pyx_pybuffer_peaky_maxima.refcount = 0;
__pyx_pybuffernd_peaky_maxima.data = NULL;
__pyx_pybuffernd_peaky_maxima.rcbuffer = &__pyx_pybuffer_peaky_maxima;
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
__pyx_pybuffer_maxima.pybuffer.buf = NULL;
__pyx_pybuffer_maxima.refcount = 0;
__pyx_pybuffernd_maxima.data = NULL;
__pyx_pybuffernd_maxima.rcbuffer = &__pyx_pybuffer_maxima;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
/* "MACS2/cSignal.pyx":53
* """
* cdef:
* np.ndarray[np.int32_t, ndim=1] minima = internal_minima(signal, maxima) # <<<<<<<<<<<<<<
* np.ndarray[np.float32_t, ndim=1] new_signal
* int n = minima.shape[0]
*/
__pyx_t_1 = ((PyObject *)__pyx_f_5MACS2_7cSignal_internal_minima(((PyArrayObject *)__pyx_v_signal), ((PyArrayObject *)__pyx_v_maxima))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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)) {
__pyx_v_minima = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_minima.rcbuffer->pybuffer.buf = NULL;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
} 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];
}
}
__pyx_v_minima = ((PyArrayObject *)__pyx_t_1);
__pyx_t_1 = 0;
/* "MACS2/cSignal.pyx":55
* np.ndarray[np.int32_t, ndim=1] minima = internal_minima(signal, maxima)
* np.ndarray[np.float32_t, ndim=1] new_signal
* int n = minima.shape[0] # <<<<<<<<<<<<<<
* float threshold
* np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
*/
__pyx_v_n = (__pyx_v_minima->dimensions[0]);
/* "MACS2/cSignal.pyx":57
* int n = minima.shape[0]
* float threshold
* np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy() # <<<<<<<<<<<<<<
* int j = 0
* if n == 0: return maxima
*/
__pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_maxima), __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = ((PyArrayObject *)__pyx_t_2);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_peaky_maxima.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
__pyx_v_peaky_maxima = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_peaky_maxima.rcbuffer->pybuffer.buf = NULL;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
} 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];
}
}
__pyx_t_3 = 0;
__pyx_v_peaky_maxima = ((PyArrayObject *)__pyx_t_2);
__pyx_t_2 = 0;
/* "MACS2/cSignal.pyx":58
* float threshold
* np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
* int j = 0 # <<<<<<<<<<<<<<
* if n == 0: return maxima
* # else:
*/
__pyx_v_j = 0;
/* "MACS2/cSignal.pyx":59
* np.ndarray[np.int32_t, ndim=1] peaky_maxima = maxima.copy()
* int j = 0
* if n == 0: return maxima # <<<<<<<<<<<<<<
* # else:
* threshold = signal[minima[0]]
*/
__pyx_t_4 = (__pyx_v_n == 0);
if (__pyx_t_4) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_maxima));
__pyx_r = ((PyObject *)__pyx_v_maxima);
goto __pyx_L0;
goto __pyx_L3;
}
__pyx_L3:;
/* "MACS2/cSignal.pyx":61
* if n == 0: return maxima
* # else:
* threshold = signal[minima[0]] # <<<<<<<<<<<<<<
* threshold += sqrt(threshold)
* new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
*/
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_pybuffernd_minima.diminfo[0].shape;
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_minima.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_minima.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_minima.diminfo[0].strides));
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_pybuffernd_signal.diminfo[0].shape;
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_pybuffernd_signal.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_threshold = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_signal.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_signal.diminfo[0].strides));
/* "MACS2/cSignal.pyx":62
* # else:
* threshold = signal[minima[0]]
* threshold += sqrt(threshold) # <<<<<<<<<<<<<<
* new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
* # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
*/
__pyx_v_threshold = (__pyx_v_threshold + __pyx_f_5MACS2_7cSignal_sqrt(__pyx_v_threshold));
/* "MACS2/cSignal.pyx":63
* threshold = signal[minima[0]]
* threshold += sqrt(threshold)
* new_signal = signal[0:minima[0]] - threshold - sqrt(threshold) # <<<<<<<<<<<<<<
* # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
* if is_valid_peak(new_signal, maxima[0]):
*/
__pyx_t_8 = 0;
__pyx_t_6 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_pybuffernd_minima.diminfo[0].shape;
if (unlikely(__pyx_t_8 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_minima.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_2 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_signal), 0, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_minima.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_minima.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_9 = PyNumber_Subtract(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyFloat_FromDouble(__pyx_f_5MACS2_7cSignal_sqrt(__pyx_v_threshold)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyNumber_Subtract(__pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_10 = ((PyArrayObject *)__pyx_t_2);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal.rcbuffer->pybuffer);
__pyx_t_6 = __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);
if (unlikely(__pyx_t_6 < 0)) {
PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
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)) {
Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
__Pyx_RaiseBufferFallbackError();
} else {
PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
}
}
__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];
if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_10 = 0;
__pyx_v_new_signal = ((PyArrayObject *)__pyx_t_2);
__pyx_t_2 = 0;
/* "MACS2/cSignal.pyx":65
* new_signal = signal[0:minima[0]] - threshold - sqrt(threshold)
* # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
* if is_valid_peak(new_signal, maxima[0]): # <<<<<<<<<<<<<<
* peaky_maxima[0] = maxima[0]
* j += 1
*/
__pyx_t_14 = 0;
__pyx_t_6 = -1;
if (__pyx_t_14 < 0) {
__pyx_t_14 += __pyx_pybuffernd_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_14 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_maxima.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_2 = ((PyObject *)__pyx_f_5MACS2_7cSignal_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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (__pyx_t_4) {
/* "MACS2/cSignal.pyx":66
* # assert maxima[0] < minima[0], '%d > %d' % ( maxima[0], minima[0] )
* if is_valid_peak(new_signal, maxima[0]):
* peaky_maxima[0] = maxima[0] # <<<<<<<<<<<<<<
* j += 1
* for i in range(n - 1):
*/
__pyx_t_15 = 0;
__pyx_t_6 = -1;
if (__pyx_t_15 < 0) {
__pyx_t_15 += __pyx_pybuffernd_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_15 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_maxima.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_16 = 0;
__pyx_t_6 = -1;
if (__pyx_t_16 < 0) {
__pyx_t_16 += __pyx_pybuffernd_peaky_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_16 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_peaky_maxima.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__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));
/* "MACS2/cSignal.pyx":67
* if is_valid_peak(new_signal, maxima[0]):
* peaky_maxima[0] = maxima[0]
* j += 1 # <<<<<<<<<<<<<<
* for i in range(n - 1):
* threshold = max(signal[minima[i]], signal[minima[i + 1]])
*/
__pyx_v_j = (__pyx_v_j + 1);
goto __pyx_L4;
}
__pyx_L4:;
/* "MACS2/cSignal.pyx":68
* peaky_maxima[0] = maxima[0]
* j += 1
* for i in range(n - 1): # <<<<<<<<<<<<<<
* threshold = max(signal[minima[i]], signal[minima[i + 1]])
* threshold += sqrt(threshold)
*/
__pyx_t_2 = PyInt_FromLong((__pyx_v_n - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
__pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_17 = 0;
__pyx_t_18 = NULL;
} else {
__pyx_t_17 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_18 = Py_TYPE(__pyx_t_1)->tp_iternext;
}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
for (;;) {
if (!__pyx_t_18 && PyList_CheckExact(__pyx_t_1)) {
if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_1)) break;
__pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_17); __Pyx_INCREF(__pyx_t_2); __pyx_t_17++;
} else if (!__pyx_t_18 && PyTuple_CheckExact(__pyx_t_1)) {
if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_17); __Pyx_INCREF(__pyx_t_2); __pyx_t_17++;
} else {
__pyx_t_2 = __pyx_t_18(__pyx_t_1);
if (unlikely(!__pyx_t_2)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
__Pyx_GOTREF(__pyx_t_2);
}
__Pyx_XDECREF(__pyx_v_i);
__pyx_v_i = __pyx_t_2;
__pyx_t_2 = 0;
/* "MACS2/cSignal.pyx":69
* j += 1
* for i in range(n - 1):
* threshold = max(signal[minima[i]], signal[minima[i + 1]]) # <<<<<<<<<<<<<<
* threshold += sqrt(threshold)
* new_signal = signal[minima[i]:minima[i+1]] - threshold
*/
__pyx_t_2 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_minima), __pyx_t_2); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_signal), __pyx_t_9); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_minima), __pyx_v_i); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_19 = PyObject_GetItem(((PyObject *)__pyx_v_signal), __pyx_t_9); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_20 = PyObject_RichCompare(__pyx_t_2, __pyx_t_19, Py_GT); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_20);
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_20); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
if (__pyx_t_4) {
__Pyx_INCREF(__pyx_t_2);
__pyx_t_9 = __pyx_t_2;
} else {
__Pyx_INCREF(__pyx_t_19);
__pyx_t_9 = __pyx_t_19;
}
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_21 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_21 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_threshold = __pyx_t_21;
/* "MACS2/cSignal.pyx":70
* for i in range(n - 1):
* threshold = max(signal[minima[i]], signal[minima[i + 1]])
* threshold += sqrt(threshold) # <<<<<<<<<<<<<<
* new_signal = signal[minima[i]:minima[i+1]] - threshold
* new_maximum = maxima[i+1] - minima[i]
*/
__pyx_v_threshold = (__pyx_v_threshold + __pyx_f_5MACS2_7cSignal_sqrt(__pyx_v_threshold));
/* "MACS2/cSignal.pyx":71
* threshold = max(signal[minima[i]], signal[minima[i + 1]])
* threshold += sqrt(threshold)
* new_signal = signal[minima[i]:minima[i+1]] - threshold # <<<<<<<<<<<<<<
* new_maximum = maxima[i+1] - minima[i]
* if is_valid_peak(new_signal, new_maximum):
*/
__pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_minima), __pyx_v_i); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_22 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_22 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_minima), __pyx_t_9); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_23 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_23 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_signal), __pyx_t_22, __pyx_t_23); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_9 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_19 = PyNumber_Subtract(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
if (!(likely(((__pyx_t_19) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_19, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_10 = ((PyArrayObject *)__pyx_t_19);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal.rcbuffer->pybuffer);
__pyx_t_6 = __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);
if (unlikely(__pyx_t_6 < 0)) {
PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
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)) {
Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
__Pyx_RaiseBufferFallbackError();
} else {
PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
}
}
__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];
if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_10 = 0;
__Pyx_DECREF(((PyObject *)__pyx_v_new_signal));
__pyx_v_new_signal = ((PyArrayObject *)__pyx_t_19);
__pyx_t_19 = 0;
/* "MACS2/cSignal.pyx":72
* threshold += sqrt(threshold)
* new_signal = signal[minima[i]:minima[i+1]] - threshold
* new_maximum = maxima[i+1] - minima[i] # <<<<<<<<<<<<<<
* if is_valid_peak(new_signal, new_maximum):
* peaky_maxima[j] = maxima[i + 1]
*/
__pyx_t_19 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_maxima), __pyx_t_19); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
__pyx_t_19 = PyObject_GetItem(((PyObject *)__pyx_v_minima), __pyx_v_i); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__pyx_t_2 = PyNumber_Subtract(__pyx_t_9, __pyx_t_19); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
__Pyx_XDECREF(__pyx_v_new_maximum);
__pyx_v_new_maximum = __pyx_t_2;
__pyx_t_2 = 0;
/* "MACS2/cSignal.pyx":73
* new_signal = signal[minima[i]:minima[i+1]] - threshold
* new_maximum = maxima[i+1] - minima[i]
* if is_valid_peak(new_signal, new_maximum): # <<<<<<<<<<<<<<
* peaky_maxima[j] = maxima[i + 1]
* j += 1
*/
__pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_new_maximum); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = ((PyObject *)__pyx_f_5MACS2_7cSignal_is_valid_peak(((PyArrayObject *)__pyx_v_new_signal), __pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (__pyx_t_4) {
/* "MACS2/cSignal.pyx":74
* new_maximum = maxima[i+1] - minima[i]
* if is_valid_peak(new_signal, new_maximum):
* peaky_maxima[j] = maxima[i + 1] # <<<<<<<<<<<<<<
* j += 1
* threshold = signal[minima[-1]]
*/
__pyx_t_2 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_19 = PyObject_GetItem(((PyObject *)__pyx_v_maxima), __pyx_t_2); if (!__pyx_t_19) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_24 = __Pyx_PyInt_from_py_npy_int32(__pyx_t_19); if (unlikely((__pyx_t_24 == (npy_int32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
__pyx_t_6 = __pyx_v_j;
__pyx_t_25 = -1;
if (__pyx_t_6 < 0) {
__pyx_t_6 += __pyx_pybuffernd_peaky_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_6 < 0)) __pyx_t_25 = 0;
} else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_peaky_maxima.diminfo[0].shape)) __pyx_t_25 = 0;
if (unlikely(__pyx_t_25 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_25);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_peaky_maxima.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_peaky_maxima.diminfo[0].strides) = __pyx_t_24;
/* "MACS2/cSignal.pyx":75
* if is_valid_peak(new_signal, new_maximum):
* peaky_maxima[j] = maxima[i + 1]
* j += 1 # <<<<<<<<<<<<<<
* threshold = signal[minima[-1]]
* threshold += sqrt(threshold)
*/
__pyx_v_j = (__pyx_v_j + 1);
goto __pyx_L7;
}
__pyx_L7:;
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "MACS2/cSignal.pyx":76
* peaky_maxima[j] = maxima[i + 1]
* j += 1
* threshold = signal[minima[-1]] # <<<<<<<<<<<<<<
* threshold += sqrt(threshold)
* new_signal = signal[minima[-1]:] - threshold
*/
__pyx_t_26 = -1;
__pyx_t_25 = -1;
if (__pyx_t_26 < 0) {
__pyx_t_26 += __pyx_pybuffernd_minima.diminfo[0].shape;
if (unlikely(__pyx_t_26 < 0)) __pyx_t_25 = 0;
} else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_minima.diminfo[0].shape)) __pyx_t_25 = 0;
if (unlikely(__pyx_t_25 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_25);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_24 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_minima.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_minima.diminfo[0].strides));
__pyx_t_25 = -1;
if (__pyx_t_24 < 0) {
__pyx_t_24 += __pyx_pybuffernd_signal.diminfo[0].shape;
if (unlikely(__pyx_t_24 < 0)) __pyx_t_25 = 0;
} else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_signal.diminfo[0].shape)) __pyx_t_25 = 0;
if (unlikely(__pyx_t_25 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_25);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_threshold = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_signal.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_signal.diminfo[0].strides));
/* "MACS2/cSignal.pyx":77
* j += 1
* threshold = signal[minima[-1]]
* threshold += sqrt(threshold) # <<<<<<<<<<<<<<
* new_signal = signal[minima[-1]:] - threshold
* new_maximum = maxima[-1] - minima[-1]
*/
__pyx_v_threshold = (__pyx_v_threshold + __pyx_f_5MACS2_7cSignal_sqrt(__pyx_v_threshold));
/* "MACS2/cSignal.pyx":78
* threshold = signal[minima[-1]]
* threshold += sqrt(threshold)
* new_signal = signal[minima[-1]:] - threshold # <<<<<<<<<<<<<<
* new_maximum = maxima[-1] - minima[-1]
* if is_valid_peak(new_signal, new_maximum):
*/
__pyx_t_27 = -1;
__pyx_t_25 = -1;
if (__pyx_t_27 < 0) {
__pyx_t_27 += __pyx_pybuffernd_minima.diminfo[0].shape;
if (unlikely(__pyx_t_27 < 0)) __pyx_t_25 = 0;
} else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_minima.diminfo[0].shape)) __pyx_t_25 = 0;
if (unlikely(__pyx_t_25 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_25);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_signal), (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_minima.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_minima.diminfo[0].strides)), PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_19 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_t_19); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_10 = ((PyArrayObject *)__pyx_t_2);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal.rcbuffer->pybuffer);
__pyx_t_25 = __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);
if (unlikely(__pyx_t_25 < 0)) {
PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
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)) {
Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
__Pyx_RaiseBufferFallbackError();
} else {
PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
}
}
__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];
if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_10 = 0;
__Pyx_DECREF(((PyObject *)__pyx_v_new_signal));
__pyx_v_new_signal = ((PyArrayObject *)__pyx_t_2);
__pyx_t_2 = 0;
/* "MACS2/cSignal.pyx":79
* threshold += sqrt(threshold)
* new_signal = signal[minima[-1]:] - threshold
* new_maximum = maxima[-1] - minima[-1] # <<<<<<<<<<<<<<
* if is_valid_peak(new_signal, new_maximum):
* peaky_maxima[j] = maxima[-1]
*/
__pyx_t_28 = -1;
__pyx_t_25 = -1;
if (__pyx_t_28 < 0) {
__pyx_t_28 += __pyx_pybuffernd_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_28 < 0)) __pyx_t_25 = 0;
} else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_maxima.diminfo[0].shape)) __pyx_t_25 = 0;
if (unlikely(__pyx_t_25 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_25);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_29 = -1;
__pyx_t_25 = -1;
if (__pyx_t_29 < 0) {
__pyx_t_29 += __pyx_pybuffernd_minima.diminfo[0].shape;
if (unlikely(__pyx_t_29 < 0)) __pyx_t_25 = 0;
} else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_minima.diminfo[0].shape)) __pyx_t_25 = 0;
if (unlikely(__pyx_t_25 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_25);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_2 = PyInt_FromLong(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_maxima.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_maxima.diminfo[0].strides)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_minima.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_minima.diminfo[0].strides)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_v_new_maximum);
__pyx_v_new_maximum = __pyx_t_2;
__pyx_t_2 = 0;
/* "MACS2/cSignal.pyx":80
* new_signal = signal[minima[-1]:] - threshold
* new_maximum = maxima[-1] - minima[-1]
* if is_valid_peak(new_signal, new_maximum): # <<<<<<<<<<<<<<
* peaky_maxima[j] = maxima[-1]
* j += 1
*/
__pyx_t_25 = __Pyx_PyInt_AsInt(__pyx_v_new_maximum); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = ((PyObject *)__pyx_f_5MACS2_7cSignal_is_valid_peak(((PyArrayObject *)__pyx_v_new_signal), __pyx_t_25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (__pyx_t_4) {
/* "MACS2/cSignal.pyx":81
* new_maximum = maxima[-1] - minima[-1]
* if is_valid_peak(new_signal, new_maximum):
* peaky_maxima[j] = maxima[-1] # <<<<<<<<<<<<<<
* j += 1
* peaky_maxima.resize(j, refcheck=False)
*/
__pyx_t_30 = -1;
__pyx_t_25 = -1;
if (__pyx_t_30 < 0) {
__pyx_t_30 += __pyx_pybuffernd_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_30 < 0)) __pyx_t_25 = 0;
} else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_maxima.diminfo[0].shape)) __pyx_t_25 = 0;
if (unlikely(__pyx_t_25 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_25);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_25 = __pyx_v_j;
__pyx_t_31 = -1;
if (__pyx_t_25 < 0) {
__pyx_t_25 += __pyx_pybuffernd_peaky_maxima.diminfo[0].shape;
if (unlikely(__pyx_t_25 < 0)) __pyx_t_31 = 0;
} else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_peaky_maxima.diminfo[0].shape)) __pyx_t_31 = 0;
if (unlikely(__pyx_t_31 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_31);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_peaky_maxima.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_peaky_maxima.diminfo[0].strides) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_maxima.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_maxima.diminfo[0].strides));
/* "MACS2/cSignal.pyx":82
* if is_valid_peak(new_signal, new_maximum):
* peaky_maxima[j] = maxima[-1]
* j += 1 # <<<<<<<<<<<<<<
* peaky_maxima.resize(j, refcheck=False)
* return peaky_maxima
*/
__pyx_v_j = (__pyx_v_j + 1);
goto __pyx_L8;
}
__pyx_L8:;
/* "MACS2/cSignal.pyx":83
* peaky_maxima[j] = maxima[-1]
* j += 1
* peaky_maxima.resize(j, refcheck=False) # <<<<<<<<<<<<<<
* return peaky_maxima
*
*/
__pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_peaky_maxima), __pyx_n_s__resize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_19 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_19);
__Pyx_GIVEREF(__pyx_t_19);
__pyx_t_19 = 0;
__pyx_t_19 = PyDict_New(); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_19));
__pyx_t_9 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
if (PyDict_SetItem(__pyx_t_19, ((PyObject *)__pyx_n_s__refcheck), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_19)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
/* "MACS2/cSignal.pyx":84
* j += 1
* peaky_maxima.resize(j, refcheck=False)
* return peaky_maxima # <<<<<<<<<<<<<<
*
* # hardcoded minimum peak width = 50
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_peaky_maxima));
__pyx_r = ((PyObject *)__pyx_v_peaky_maxima);
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_19);
__Pyx_XDECREF(__pyx_t_20);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_minima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_peaky_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.enforce_peakyness", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_minima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_signal.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_peaky_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XDECREF((PyObject *)__pyx_v_minima);
__Pyx_XDECREF((PyObject *)__pyx_v_new_signal);
__Pyx_XDECREF((PyObject *)__pyx_v_peaky_maxima);
__Pyx_XDECREF(__pyx_v_i);
__Pyx_XDECREF(__pyx_v_new_maximum);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_5MACS2_7cSignal_3enforce_peakyness(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5MACS2_7cSignal_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 ";
static PyObject *__pyx_pw_5MACS2_7cSignal_3enforce_peakyness(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyArrayObject *__pyx_v_signal = 0;
PyArrayObject *__pyx_v_maxima = 0;
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__signal,&__pyx_n_s__maxima,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("enforce_peakyness (wrapper)", 0);
__pyx_self = __pyx_self;
{
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__signal);
if (likely(values[0])) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__maxima);
if (likely(values[1])) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("enforce_peakyness", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "enforce_peakyness") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_signal = ((PyArrayObject *)values[0]);
__pyx_v_maxima = ((PyArrayObject *)values[1]);
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("enforce_peakyness", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("MACS2.cSignal.enforce_peakyness", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_signal), __pyx_ptype_5numpy_ndarray, 1, "signal", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_maxima), __pyx_ptype_5numpy_ndarray, 1, "maxima", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = __pyx_pf_5MACS2_7cSignal_2enforce_peakyness(__pyx_self, __pyx_v_signal, __pyx_v_maxima);
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":36
* return mathsqrt(threshold)
*
* cpdef enforce_peakyness(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* np.ndarray[np.int32_t, ndim=1] maxima):
* """requires peaks described by a signal and a set of points where the signal
*/
static PyObject *__pyx_pf_5MACS2_7cSignal_2enforce_peakyness(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_signal, PyArrayObject *__pyx_v_maxima) {
__Pyx_LocalBuf_ND __pyx_pybuffernd_maxima;
__Pyx_Buffer __pyx_pybuffer_maxima;
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("enforce_peakyness", 0);
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
__pyx_pybuffer_maxima.pybuffer.buf = NULL;
__pyx_pybuffer_maxima.refcount = 0;
__pyx_pybuffernd_maxima.data = NULL;
__pyx_pybuffernd_maxima.rcbuffer = &__pyx_pybuffer_maxima;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_f_5MACS2_7cSignal_enforce_peakyness(__pyx_v_signal, __pyx_v_maxima, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.enforce_peakyness", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxima.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":87
*
* # hardcoded minimum peak width = 50
* cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum): # <<<<<<<<<<<<<<
* cdef:
* s = hard_clip(signal, maximum)
*/
static PyBoolObject *__pyx_f_5MACS2_7cSignal_is_valid_peak(PyArrayObject *__pyx_v_signal, int __pyx_v_maximum) {
PyObject *__pyx_v_s = 0;
int __pyx_v_length;
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyBoolObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("is_valid_peak", 0);
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
/* "MACS2/cSignal.pyx":89
* cdef bool is_valid_peak(np.ndarray[np.float32_t, ndim=1] signal, int maximum):
* cdef:
* s = hard_clip(signal, maximum) # <<<<<<<<<<<<<<
* int length = s.shape[0]
* if length < 50: return False
*/
__pyx_t_1 = ((PyObject *)__pyx_f_5MACS2_7cSignal_hard_clip(((PyArrayObject *)__pyx_v_signal), __pyx_v_maximum)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_s = __pyx_t_1;
__pyx_t_1 = 0;
/* "MACS2/cSignal.pyx":90
* cdef:
* s = hard_clip(signal, maximum)
* int length = s.shape[0] # <<<<<<<<<<<<<<
* if length < 50: return False
* elif too_flat(s): return False
*/
__pyx_t_1 = PyObject_GetAttr(__pyx_v_s, __pyx_n_s__shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_length = __pyx_t_3;
/* "MACS2/cSignal.pyx":91
* s = hard_clip(signal, maximum)
* int length = s.shape[0]
* if length < 50: return False # <<<<<<<<<<<<<<
* elif too_flat(s): return False
* return True
*/
__pyx_t_4 = (__pyx_v_length < 50);
if (__pyx_t_4) {
__Pyx_XDECREF(((PyObject *)__pyx_r));
__pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((PyBoolObject *)__pyx_t_2);
__pyx_t_2 = 0;
goto __pyx_L0;
goto __pyx_L3;
}
/* "MACS2/cSignal.pyx":92
* int length = s.shape[0]
* if length < 50: return False
* elif too_flat(s): return False # <<<<<<<<<<<<<<
* return True
*
*/
if (!(likely(((__pyx_v_s) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_s, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = __pyx_v_s;
__Pyx_INCREF(__pyx_t_2);
__pyx_t_1 = ((PyObject *)__pyx_f_5MACS2_7cSignal_too_flat(((PyArrayObject *)__pyx_t_2))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_4) {
__Pyx_XDECREF(((PyObject *)__pyx_r));
__pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((PyBoolObject *)__pyx_t_1);
__pyx_t_1 = 0;
goto __pyx_L0;
goto __pyx_L3;
}
__pyx_L3:;
/* "MACS2/cSignal.pyx":93
* if length < 50: return False
* elif too_flat(s): return False
* return True # <<<<<<<<<<<<<<
*
* # require at least 6 different float values -- prevents broad flat peaks
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((PyBoolObject *)__pyx_t_1);
__pyx_t_1 = 0;
goto __pyx_L0;
__pyx_r = ((PyBoolObject *)Py_None); __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.is_valid_peak", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XDECREF(__pyx_v_s);
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":96
*
* # require at least 6 different float values -- prevents broad flat peaks
* cdef bool too_flat(np.ndarray[np.float32_t, ndim=1] signal): # <<<<<<<<<<<<<<
* # """return whether signal has at least 6 unique values
* # """
*/
static PyBoolObject *__pyx_f_5MACS2_7cSignal_too_flat(PyArrayObject *__pyx_v_signal) {
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyBoolObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("too_flat", 0);
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
/* "MACS2/cSignal.pyx":99
* # """return whether signal has at least 6 unique values
* # """
* return np.unique(signal).shape[0] < 6 # <<<<<<<<<<<<<<
*
* # hard clip a region with negative values
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__unique); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)__pyx_v_signal));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_signal));
__Pyx_GIVEREF(((PyObject *)__pyx_v_signal));
__pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_int_6, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((PyBoolObject *)__pyx_t_1);
__pyx_t_1 = 0;
goto __pyx_L0;
__pyx_r = ((PyBoolObject *)Py_None); __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.too_flat", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":102
*
* # hard clip a region with negative values
* cdef np.ndarray[np.float32_t, ndim=1] hard_clip(np.ndarray[np.float32_t, ndim=1] signal, int maximum): # <<<<<<<<<<<<<<
* # """clip the signal in both directions at the nearest values <= 0
* # to position maximum
*/
static PyArrayObject *__pyx_f_5MACS2_7cSignal_hard_clip(PyArrayObject *__pyx_v_signal, int __pyx_v_maximum) {
int __pyx_v_i;
int __pyx_v_left;
int __pyx_v_right;
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
PyArrayObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
int __pyx_t_6;
PyObject *__pyx_t_7 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("hard_clip", 0);
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
/* "MACS2/cSignal.pyx":108
* cdef:
* int i
* int left = 0 # <<<<<<<<<<<<<<
* int right = signal.shape[0]
* # clip left
*/
__pyx_v_left = 0;
/* "MACS2/cSignal.pyx":109
* int i
* int left = 0
* int right = signal.shape[0] # <<<<<<<<<<<<<<
* # clip left
* for i in range(right - maximum, 0):
*/
__pyx_v_right = (__pyx_v_signal->dimensions[0]);
/* "MACS2/cSignal.pyx":111
* int right = signal.shape[0]
* # clip left
* for i in range(right - maximum, 0): # <<<<<<<<<<<<<<
* if signal[-i] < 0:
* left = i
*/
for (__pyx_t_1 = (__pyx_v_right - __pyx_v_maximum); __pyx_t_1 < 0; __pyx_t_1+=1) {
__pyx_v_i = __pyx_t_1;
/* "MACS2/cSignal.pyx":112
* # clip left
* for i in range(right - maximum, 0):
* if signal[-i] < 0: # <<<<<<<<<<<<<<
* left = i
* break
*/
__pyx_t_2 = (-__pyx_v_i);
__pyx_t_3 = -1;
if (__pyx_t_2 < 0) {
__pyx_t_2 += __pyx_pybuffernd_signal.diminfo[0].shape;
if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 0;
} else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_signal.diminfo[0].shape)) __pyx_t_3 = 0;
if (unlikely(__pyx_t_3 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_3);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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);
if (__pyx_t_4) {
/* "MACS2/cSignal.pyx":113
* for i in range(right - maximum, 0):
* if signal[-i] < 0:
* left = i # <<<<<<<<<<<<<<
* break
* for i in range(maximum, right):
*/
__pyx_v_left = __pyx_v_i;
/* "MACS2/cSignal.pyx":114
* if signal[-i] < 0:
* left = i
* break # <<<<<<<<<<<<<<
* for i in range(maximum, right):
* if signal[i] < 0:
*/
goto __pyx_L4_break;
goto __pyx_L5;
}
__pyx_L5:;
}
__pyx_L4_break:;
/* "MACS2/cSignal.pyx":115
* left = i
* break
* for i in range(maximum, right): # <<<<<<<<<<<<<<
* if signal[i] < 0:
* right = i
*/
__pyx_t_1 = __pyx_v_right;
for (__pyx_t_3 = __pyx_v_maximum; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "MACS2/cSignal.pyx":116
* break
* for i in range(maximum, right):
* if signal[i] < 0: # <<<<<<<<<<<<<<
* right = i
* break
*/
__pyx_t_5 = __pyx_v_i;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_pybuffernd_signal.diminfo[0].shape;
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_signal.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_4 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_signal.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_signal.diminfo[0].strides)) < 0.0);
if (__pyx_t_4) {
/* "MACS2/cSignal.pyx":117
* for i in range(maximum, right):
* if signal[i] < 0:
* right = i # <<<<<<<<<<<<<<
* break
* return signal[left:right]
*/
__pyx_v_right = __pyx_v_i;
/* "MACS2/cSignal.pyx":118
* if signal[i] < 0:
* right = i
* break # <<<<<<<<<<<<<<
* return signal[left:right]
*
*/
goto __pyx_L7_break;
goto __pyx_L8;
}
__pyx_L8:;
}
__pyx_L7_break:;
/* "MACS2/cSignal.pyx":119
* right = i
* break
* return signal[left:right] # <<<<<<<<<<<<<<
*
* # for all maxima, set min_subpeak_width = 0
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__pyx_t_7 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_signal), __pyx_v_left, __pyx_v_right); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((PyArrayObject *)__pyx_t_7);
__pyx_t_7 = 0;
goto __pyx_L0;
__pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_7);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_AddTraceback("MACS2.cSignal.hard_clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_signal.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "MACS2/cSignal.pyx":149
* # return n
*
* cpdef enforce_valleys(np.ndarray[np.float32_t, ndim=1] signal, # <<<<<<<<<<<<<<
* np.ndarray[np.int32_t, ndim=1] summits,
* float min_valley = 0.8):
*/
static PyObject *__pyx_pw_5MACS2_7cSignal_5enforce_valleys(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5MACS2_7cSignal_enforce_valleys(PyArrayObject *__pyx_v_signal, PyArrayObject *__pyx_v_summits, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_5MACS2_7cSignal_enforce_valleys *__pyx_optional_args) {
/* "MACS2/cSignal.pyx":151
* cpdef enforce_valleys(np.ndarray[np.float32_t, ndim=1] signal,
* np.ndarray[np.int32_t, ndim=1] summits,
* float min_valley = 0.8): # <<<<<<<<<<<<<<
* """require a value of <= min_valley * lower summit
* between each pair of summits
*/
float __pyx_v_min_valley = ((float)0.8);
float __pyx_v_req_min;
float __pyx_v_v;
float __pyx_v_prev_v;
int __pyx_v_summit_pos;
int __pyx_v_prev_summit_pos;
int __pyx_v_n_summits;
int __pyx_v_n_valid_summits;
PyArrayObject *__pyx_v_valid_summits = 0;
long __pyx_v_i;
__Pyx_LocalBuf_ND __pyx_pybuffernd_signal;
__Pyx_Buffer __pyx_pybuffer_signal;
__Pyx_LocalBuf_ND __pyx_pybuffernd_summits;
__Pyx_Buffer __pyx_pybuffer_summits;
__Pyx_LocalBuf_ND __pyx_pybuffernd_valid_summits;
__Pyx_Buffer __pyx_pybuffer_valid_summits;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyArrayObject *__pyx_t_3 = NULL;
int __pyx_t_4;
int __pyx_t_5;
long __pyx_t_6;
long __pyx_t_7;
int __pyx_t_8;
long __pyx_t_9;
int __pyx_t_10;
int __pyx_t_11;
float __pyx_t_12;
float __pyx_t_13;
float __pyx_t_14;
PyObject *__pyx_t_15 = NULL;
int __pyx_t_16;
long __pyx_t_17;
PyObject *__pyx_t_18 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("enforce_valleys", 0);
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_min_valley = __pyx_optional_args->min_valley;
}
}
__pyx_pybuffer_valid_summits.pybuffer.buf = NULL;
__pyx_pybuffer_valid_summits.refcount = 0;
__pyx_pybuffernd_valid_summits.data = NULL;
__pyx_pybuffernd_valid_summits.rcbuffer = &__pyx_pybuffer_valid_summits;
__pyx_pybuffer_signal.pybuffer.buf = NULL;
__pyx_pybuffer_signal.refcount = 0;
__pyx_pybuffernd_signal.data = NULL;
__pyx_pybuffernd_signal.rcbuffer = &__pyx_pybuffer_signal;
__pyx_pybuffer_summits.pybuffer.buf = NULL;
__pyx_pybuffer_summits.refcount = 0;
__pyx_pybuffernd_summits.data = NULL;
__pyx_pybuffernd_summits.rcbuffer = &__pyx_pybuffer_summits;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
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_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__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];
/* "MACS2/cSignal.pyx":158
* float req_min, v, prev_v
* int summit_pos, prev_summit_pos
* int n_summits = summits.shape[0] # <<<<<<<<<<<<<<
* int n_valid_summits = 1
* np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy()
*/
__pyx_v_n_summits = (__pyx_v_summits->dimensions[0]);
/* "MACS2/cSignal.pyx":159
* int summit_pos, prev_summit_pos
* int n_summits = summits.shape[0]
* int n_valid_summits = 1 # <<<<<<<<<<<<<<
* np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy()
* # Step 1: Remove peaks that do not have sufficient valleys
*/
__pyx_v_n_valid_summits = 1;
/* "MACS2/cSignal.pyx":160
* int n_summits = summits.shape[0]
* int n_valid_summits = 1
* np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy() # <<<<<<<<<<<<<<
* # Step 1: Remove peaks that do not have sufficient valleys
* if n_summits == 1: return summits
*/
__pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_summits), __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = ((PyArrayObject *)__pyx_t_2);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_valid_summits.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
__pyx_v_valid_summits = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_valid_summits.rcbuffer->pybuffer.buf = NULL;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
} 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];
}
}
__pyx_t_3 = 0;
__pyx_v_valid_summits = ((PyArrayObject *)__pyx_t_2);
__pyx_t_2 = 0;
/* "MACS2/cSignal.pyx":162
* np.ndarray[np.int32_t, ndim=1] valid_summits = summits.copy()
* # Step 1: Remove peaks that do not have sufficient valleys
* if n_summits == 1: return summits # <<<<<<<<<<<<<<
* for i in range(1, n_summits):
* prev_summit_pos = valid_summits[n_valid_summits-1]
*/
__pyx_t_4 = (__pyx_v_n_summits == 1);
if (__pyx_t_4) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_summits));
__pyx_r = ((PyObject *)__pyx_v_summits);
goto __pyx_L0;
goto __pyx_L3;
}
__pyx_L3:;
/* "MACS2/cSignal.pyx":163
* # Step 1: Remove peaks that do not have sufficient valleys
* if n_summits == 1: return summits
* for i in range(1, n_summits): # <<<<<<<<<<<<<<
* prev_summit_pos = valid_summits[n_valid_summits-1]
* summit_pos = summits[i]
*/
__pyx_t_5 = __pyx_v_n_summits;
for (__pyx_t_6 = 1; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "MACS2/cSignal.pyx":164
* if n_summits == 1: return summits
* for i in range(1, n_summits):
* prev_summit_pos = valid_summits[n_valid_summits-1] # <<<<<<<<<<<<<<
* summit_pos = summits[i]
* prev_v = signal[prev_summit_pos]
*/
__pyx_t_7 = (__pyx_v_n_valid_summits - 1);
__pyx_t_8 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_pybuffernd_valid_summits.diminfo[0].shape;
if (unlikely(__pyx_t_7 < 0)) __pyx_t_8 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_pybuffernd_valid_summits.diminfo[0].shape)) __pyx_t_8 = 0;
if (unlikely(__pyx_t_8 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_8);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_prev_summit_pos = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_valid_summits.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_valid_summits.diminfo[0].strides));
/* "MACS2/cSignal.pyx":165
* for i in range(1, n_summits):
* prev_summit_pos = valid_summits[n_valid_summits-1]
* summit_pos = summits[i] # <<<<<<<<<<<<<<
* prev_v = signal[prev_summit_pos]
* v = signal[summit_pos]
*/
__pyx_t_9 = __pyx_v_i;
__pyx_t_8 = -1;
if (__pyx_t_9 < 0) {
__pyx_t_9 += __pyx_pybuffernd_summits.diminfo[0].shape;
if (unlikely(__pyx_t_9 < 0)) __pyx_t_8 = 0;
} else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_summits.diminfo[0].shape)) __pyx_t_8 = 0;
if (unlikely(__pyx_t_8 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_8);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_summit_pos = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_summits.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_summits.diminfo[0].strides));
/* "MACS2/cSignal.pyx":166
* prev_summit_pos = valid_summits[n_valid_summits-1]
* summit_pos = summits[i]
* prev_v = signal[prev_summit_pos] # <<<<<<<<<<<<<<
* v = signal[summit_pos]
* req_min = min_valley * min(prev_v, v)
*/
__pyx_t_8 = __pyx_v_prev_summit_pos;
__pyx_t_10 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_pybuffernd_signal.diminfo[0].shape;