Generated by Cython 0.29.20
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: pelt_cython.c
+001: import numpy as np
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
002: cimport numpy as np
+003: import math
__pyx_t_1 = __Pyx_Import(__pyx_n_s_math, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_math, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
004: cimport cython
005:
006: from libc.math cimport sqrt, log, M_PI, fmax, isnan
007: cimport cost_function
008: from cost_function cimport mll_mean, mll_var, mll_meanvar, mll_meanvar_exp, mll_meanvar_poisson, mbic_var, mbic_meanvar, mbic_mean, mbic_meanvar_exp, mbic_meanvar_poisson
009: from cost_function cimport mll_nonparametric_ed, mll_nonparametric_ed_mbic
010:
011: cimport utils
012: from utils cimport order_vec
013: from cython.parallel import prange
014:
015:
+016: DTYPE = np.float64
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+017: ITYPE = np.int64
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_ITYPE, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+018: ctypedef np.float64_t DTYPE_t
typedef __pyx_t_5numpy_float64_t __pyx_t_14pychangepoints_11cython_pelt_DTYPE_t;
019: ctypedef np.int64_t ITYPE_t
020:
021:
022: """
023: def cpelt2 (np.ndarray[DTYPE_t, ndim=3] sumstat, double pen, int minseglen):
024: cdef int n = sumstat.shape[0]
025: cdef int error = 0
026: cdef int nchecklist
027:
028: cdef int [:] cptsout = np.zeros(n+1).astype(int)
029: cdef int [:] lastchangecpts = np.zeros(2*(n + 1)).astype(int)
030: cdef double [:] lastchangelike = np.zeros(n+1)
031: cdef int [:] checklist = np.zeros(n+1).astype(int)
032: cdef double [:] tmplike = np.zeros(n+1)
033: cdef int [:] tmpt = np.zeros(n+1).astype(int)
034: cdef int [:] numchangecpts = np.zeros(n+1).astype(int)
035: cdef int tstar,i,j,k,whichout,nchecktmp
036: cdef double minout
037:
038: lastchangelike[0] = -pen
039: lastchangecpts[0] = 0
040: lastchangecpts[n + 0] = 0
041: lastchangecpts[n + 1] = 1
042: lastchangecpts[n + 2] = 2
043: lastchangecpts[n + 3] = 3
044: for j in range(minseglen, 2 * minseglen):
045: lastchangelike[j] = mll_mean(sumstat[j, 0], sumstat[j, 1], j)
046: lastchangecpts[j] = 0
047: nchecklist = 2
048: checklist[0] = 0
049: checklist[1] = minseglen
050: for tstar in range(2 * minseglen, n + 1):
051: for i in range(0,nchecklist):
052: print(tstar-checklist[i])
053: tmplike[i]=lastchangelike[checklist[i]] + mll_mean(sumstat[tstar,0]-sumstat[checklist[i],0],sumstat[tstar,1]-sumstat[checklist[i],1], tstar-checklist[i])+pen
054: whichout = np.argmin(tmplike[0:nchecklist])
055: minout = tmplike[whichout]
056: lastchangelike[tstar] = minout
057: lastchangecpts[tstar] = checklist[whichout]
058: lastchangecpts[n + tstar] = tstar
059: nchecktmp = 0
060: for k in range(0,nchecklist):
061: if (tmplike[k]<=lastchangelike[tstar] + pen):
062: checklist[nchecktmp]=checklist[k]
063: nchecktmp+=1
064: checklist[nchecktmp] = (tstar - (minseglen - 1))
065: nchecktmp += 1
066: nchecklist = nchecktmp
067:
068: cdef int ncpts = 0
069: cdef int last = n
070: changepoints = np.array(0)
071: while (last != 0):
072: if (last != n):
073: changepoints = np.append(changepoints, last)
074: last = int(lastchangecpts[last])
075: ncpts += 1
076: changepoints = np.sort(changepoints)
077: return changepoints
078: """
079: @cython.wraparound(False)
080: @cython.boundscheck(False)
+081: def cpelt(np.ndarray[DTYPE_t, ndim=1] sumstat, double pen, int minseglen, int n, str method):
/* Python wrapper */ static PyObject *__pyx_pw_14pychangepoints_11cython_pelt_1cpelt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_14pychangepoints_11cython_pelt_1cpelt = {"cpelt", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14pychangepoints_11cython_pelt_1cpelt, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_14pychangepoints_11cython_pelt_1cpelt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_sumstat = 0; double __pyx_v_pen; int __pyx_v_minseglen; int __pyx_v_n; PyObject *__pyx_v_method = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cpelt (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sumstat,&__pyx_n_s_pen,&__pyx_n_s_minseglen,&__pyx_n_s_n,&__pyx_n_s_method,0}; PyObject* values[5] = {0,0,0,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 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sumstat)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pen)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cpelt", 1, 5, 5, 1); __PYX_ERR(0, 81, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_minseglen)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cpelt", 1, 5, 5, 2); __PYX_ERR(0, 81, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cpelt", 1, 5, 5, 3); __PYX_ERR(0, 81, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cpelt", 1, 5, 5, 4); __PYX_ERR(0, 81, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cpelt") < 0)) __PYX_ERR(0, 81, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } __pyx_v_sumstat = ((PyArrayObject *)values[0]); __pyx_v_pen = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_pen == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L3_error) __pyx_v_minseglen = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minseglen == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L3_error) __pyx_v_n = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L3_error) __pyx_v_method = ((PyObject*)values[4]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cpelt", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 81, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pychangepoints.cython_pelt.cpelt", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sumstat), __pyx_ptype_5numpy_ndarray, 1, "sumstat", 0))) __PYX_ERR(0, 81, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_method), (&PyString_Type), 1, "method", 1))) __PYX_ERR(0, 81, __pyx_L1_error) __pyx_r = __pyx_pf_14pychangepoints_11cython_pelt_cpelt(__pyx_self, __pyx_v_sumstat, __pyx_v_pen, __pyx_v_minseglen, __pyx_v_n, __pyx_v_method); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_14pychangepoints_11cython_pelt_cpelt(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sumstat, double __pyx_v_pen, int __pyx_v_minseglen, int __pyx_v_n, PyObject *__pyx_v_method) { CYTHON_UNUSED int __pyx_v_error; int __pyx_v_nchecklist; __Pyx_memviewslice __pyx_v_cptsout = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_lastchangecpts = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_checklist = { 0, 0, { 0 }, { 0 }, { 0 } }; CYTHON_UNUSED __Pyx_memviewslice __pyx_v_tmpt = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_numchangecpts = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_v_a = NULL; PyObject *__pyx_v_b = NULL; PyObject *__pyx_v_c = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_e = NULL; __Pyx_memviewslice __pyx_v_lastchangelike = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_tmplike = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_v_zeros_array_double = NULL; PyObject *__pyx_v_zeros_array_double_2 = NULL; int __pyx_v_tstar; int __pyx_v_i; int __pyx_v_whichout; int __pyx_v_nchecktmp; double __pyx_v_minout; __pyx_t_14pychangepoints_13cost_function_DTYPE_t (*__pyx_v_current_cost)(__pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_ITYPE_t); int __pyx_v_j; __pyx_t_14pychangepoints_11cython_pelt_DTYPE_t __pyx_v_a1; __pyx_t_14pychangepoints_11cython_pelt_DTYPE_t __pyx_v_a2; __pyx_t_14pychangepoints_11cython_pelt_DTYPE_t __pyx_v_a3; int __pyx_v_ncpts; int __pyx_v_last; __Pyx_LocalBuf_ND __pyx_pybuffernd_sumstat; __Pyx_Buffer __pyx_pybuffer_sumstat; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cpelt", 0); __pyx_pybuffer_sumstat.pybuffer.buf = NULL; __pyx_pybuffer_sumstat.refcount = 0; __pyx_pybuffernd_sumstat.data = NULL; __pyx_pybuffernd_sumstat.rcbuffer = &__pyx_pybuffer_sumstat; { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumstat, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 81, __pyx_L1_error) } __pyx_pybuffernd_sumstat.diminfo[0].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumstat.diminfo[0].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[0]; /* … */ /* function exit code */ __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_XDEC_MEMVIEW(&__pyx_t_6, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("pychangepoints.cython_pelt.cpelt", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer); __pyx_L2:; __PYX_XDEC_MEMVIEW(&__pyx_v_cptsout, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_lastchangecpts, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_checklist, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmpt, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_numchangecpts, 1); __Pyx_XDECREF(__pyx_v_a); __Pyx_XDECREF(__pyx_v_b); __Pyx_XDECREF(__pyx_v_c); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_e); __PYX_XDEC_MEMVIEW(&__pyx_v_lastchangelike, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmplike, 1); __Pyx_XDECREF(__pyx_v_zeros_array_double); __Pyx_XDECREF(__pyx_v_zeros_array_double_2); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__27 = PyTuple_Pack(33, __pyx_n_s_sumstat, __pyx_n_s_pen, __pyx_n_s_minseglen, __pyx_n_s_n, __pyx_n_s_method, __pyx_n_s_error, __pyx_n_s_nchecklist, __pyx_n_s_cptsout, __pyx_n_s_lastchangecpts, __pyx_n_s_checklist, __pyx_n_s_tmpt, __pyx_n_s_numchangecpts, __pyx_n_s_a, __pyx_n_s_b, __pyx_n_s_c, __pyx_n_s_d, __pyx_n_s_e, __pyx_n_s_lastchangelike, __pyx_n_s_tmplike, __pyx_n_s_zeros_array_double, __pyx_n_s_zeros_array_double_2, __pyx_n_s_tstar, __pyx_n_s_i, __pyx_n_s_whichout, __pyx_n_s_nchecktmp, __pyx_n_s_minout, __pyx_n_s_current_cost, __pyx_n_s_j, __pyx_n_s_a1, __pyx_n_s_a2, __pyx_n_s_a3, __pyx_n_s_ncpts, __pyx_n_s_last); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__27); __Pyx_GIVEREF(__pyx_tuple__27); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14pychangepoints_11cython_pelt_1cpelt, NULL, __pyx_n_s_pychangepoints_cython_pelt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_cpelt, __pyx_t_1) < 0) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(5, 0, 33, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pychangepoints_pelt_cython_pyx, __pyx_n_s_cpelt, 81, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 81, __pyx_L1_error)
082: #cdef int n = sumstat.shape[0] - 1
+083: cdef int error = 0
__pyx_v_error = 0;
084: cdef int nchecklist
085:
086: cdef int [:] cptsout, lastchangecpts, checklist, tmpt, numchangecpts
+087: a = np.zeros(n+1, dtype=np.intc)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_intc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_a = __pyx_t_5; __pyx_t_5 = 0;
+088: cptsout = a
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_a, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 88, __pyx_L1_error) __pyx_v_cptsout = __pyx_t_6; __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
+089: b = np.zeros(n+1, dtype=np.intc)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_intc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_b = __pyx_t_4; __pyx_t_4 = 0;
090:
+091: lastchangecpts = b
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_b, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 91, __pyx_L1_error) __pyx_v_lastchangecpts = __pyx_t_6; __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
+092: c= np.zeros(n+1, dtype=np.intc)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_intc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_c = __pyx_t_2; __pyx_t_2 = 0;
+093: checklist = c
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_c, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 93, __pyx_L1_error) __pyx_v_checklist = __pyx_t_6; __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
+094: d = np.zeros(n+1, dtype=np.intc)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_intc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_d = __pyx_t_1; __pyx_t_1 = 0;
+095: tmpt = d
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_d, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 95, __pyx_L1_error) __pyx_v_tmpt = __pyx_t_6; __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
+096: e = np.zeros(n+1, dtype=np.intc)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_intc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_e = __pyx_t_5; __pyx_t_5 = 0;
097:
+098: numchangecpts = e
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_e, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 98, __pyx_L1_error) __pyx_v_numchangecpts = __pyx_t_6; __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
099: cdef double [:] lastchangelike, tmplike
+100: zeros_array_double = np.zeros(n+1)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_zeros_array_double = __pyx_t_5; __pyx_t_5 = 0;
+101: lastchangelike = zeros_array_double
__pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_zeros_array_double, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 101, __pyx_L1_error) __pyx_v_lastchangelike = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
+102: zeros_array_double_2 = np.zeros(n+1)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_zeros_array_double_2 = __pyx_t_5; __pyx_t_5 = 0;
103:
+104: tmplike = zeros_array_double_2
__pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_zeros_array_double_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 104, __pyx_L1_error) __pyx_v_tmplike = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
105: cdef int tstar, i, whichout, nchecktmp
106: cdef double minout
+107: lastchangelike[0] = -pen
__pyx_t_8 = 0; *((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_8 * __pyx_v_lastchangelike.strides[0]) )) = (-__pyx_v_pen);
+108: lastchangecpts[0] = 0
__pyx_t_9 = 0; *((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_9 * __pyx_v_lastchangecpts.strides[0]) )) = 0;
+109: numchangecpts[0] = 0
__pyx_t_10 = 0; *((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_10 * __pyx_v_numchangecpts.strides[0]) )) = 0;
+110: if method == "mll_mean":
__pyx_t_11 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_mean, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 110, __pyx_L1_error) __pyx_t_12 = (__pyx_t_11 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+111: current_cost = mll_mean
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_mean;
+112: elif method == "mll_var":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_var, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 112, __pyx_L1_error) __pyx_t_11 = (__pyx_t_12 != 0); if (__pyx_t_11) { /* … */ goto __pyx_L3; }
+113: current_cost = mll_var
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_var;
+114: elif method == "mll_meanvar":
__pyx_t_11 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 114, __pyx_L1_error) __pyx_t_12 = (__pyx_t_11 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+115: current_cost = mll_meanvar
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar;
+116: elif method == "mll_meanvar_exp":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar_exp, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 116, __pyx_L1_error) __pyx_t_11 = (__pyx_t_12 != 0); if (__pyx_t_11) { /* … */ goto __pyx_L3; }
+117: current_cost = mll_meanvar_exp
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar_exp;
+118: elif method == "mll_meanvar_poisson":
__pyx_t_11 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar_poisson, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 118, __pyx_L1_error) __pyx_t_12 = (__pyx_t_11 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+119: current_cost = mll_meanvar_poisson
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar_poisson;
+120: elif method == "mbic_var":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_var, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 120, __pyx_L1_error) __pyx_t_11 = (__pyx_t_12 != 0); if (__pyx_t_11) { /* … */ goto __pyx_L3; }
+121: current_cost = mbic_var
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_var;
+122: elif method == "mbic_meanvar":
__pyx_t_11 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 122, __pyx_L1_error) __pyx_t_12 = (__pyx_t_11 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+123: current_cost = mbic_meanvar
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar;
+124: elif method == "mbic_mean":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_mean, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 124, __pyx_L1_error) __pyx_t_11 = (__pyx_t_12 != 0); if (__pyx_t_11) { /* … */ goto __pyx_L3; }
+125: current_cost = mbic_mean
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_mean;
+126: elif method == "mbic_meanvar_exp":
__pyx_t_11 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar_exp, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 126, __pyx_L1_error) __pyx_t_12 = (__pyx_t_11 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+127: current_cost = mbic_meanvar_exp
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar_exp;
+128: elif method == "mbic_meanvar_poisson":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar_poisson, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) __pyx_t_11 = (__pyx_t_12 != 0); if (__pyx_t_11) { /* … */ goto __pyx_L3; }
+129: current_cost = mbic_meanvar_poisson
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar_poisson;
130: else:
+131: current_cost = mbic_meanvar
/*else*/ { __pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar; } __pyx_L3:;
132:
133: cdef int j
+134: for j in range(minseglen, 2*minseglen):
__pyx_t_13 = (2 * __pyx_v_minseglen); __pyx_t_14 = __pyx_t_13; for (__pyx_t_15 = __pyx_v_minseglen; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_j = __pyx_t_15;
+135: lastchangelike[j] = current_cost(sumstat[j], sumstat[j+n+1], sumstat[j+2*(n+1)], j)
__pyx_t_16 = __pyx_v_j; __pyx_t_17 = ((__pyx_v_j + __pyx_v_n) + 1); __pyx_t_18 = (__pyx_v_j + (2 * (__pyx_v_n + 1))); __pyx_t_19 = __pyx_v_j; *((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_19 * __pyx_v_lastchangelike.strides[0]) )) = __pyx_v_current_cost((*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_sumstat.diminfo[0].strides)), (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[0].strides)), (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_sumstat.diminfo[0].strides)), __pyx_v_j); }
+136: for j in range(minseglen, 2*minseglen):
__pyx_t_13 = (2 * __pyx_v_minseglen); __pyx_t_14 = __pyx_t_13; for (__pyx_t_15 = __pyx_v_minseglen; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_j = __pyx_t_15;
+137: numchangecpts[j] = 1
__pyx_t_18 = __pyx_v_j; *((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_18 * __pyx_v_numchangecpts.strides[0]) )) = 1; }
+138: for j in range(minseglen, 2*minseglen):
__pyx_t_13 = (2 * __pyx_v_minseglen); __pyx_t_14 = __pyx_t_13; for (__pyx_t_15 = __pyx_v_minseglen; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_j = __pyx_t_15;
+139: lastchangecpts[j] = 1
__pyx_t_17 = __pyx_v_j; *((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_17 * __pyx_v_lastchangecpts.strides[0]) )) = 1; }
140: cdef DTYPE_t a1 , a2, a3
141:
+142: nchecklist = 2
__pyx_v_nchecklist = 2;
+143: checklist[0] = 0
__pyx_t_16 = 0; *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_16 * __pyx_v_checklist.strides[0]) )) = 0;
+144: checklist[1] = minseglen
__pyx_t_20 = 1; *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_20 * __pyx_v_checklist.strides[0]) )) = __pyx_v_minseglen;
+145: for tstar in range(2*minseglen, n+1):
__pyx_t_13 = (__pyx_v_n + 1); __pyx_t_14 = __pyx_t_13; for (__pyx_t_15 = (2 * __pyx_v_minseglen); __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_v_tstar = __pyx_t_15;
+146: if lastchangelike[tstar] == 0:
__pyx_t_21 = __pyx_v_tstar; __pyx_t_11 = (((*((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_21 * __pyx_v_lastchangelike.strides[0]) ))) == 0.0) != 0); if (__pyx_t_11) { /* … */ }
+147: for i in range(0, nchecklist+1):
__pyx_t_22 = (__pyx_v_nchecklist + 1); __pyx_t_23 = __pyx_t_22; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) { __pyx_v_i = __pyx_t_24;
+148: a1 = sumstat[tstar]-sumstat[checklist[i]]
__pyx_t_21 = __pyx_v_tstar; __pyx_t_25 = __pyx_v_i; __pyx_t_26 = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_25 * __pyx_v_checklist.strides[0]) ))); __pyx_v_a1 = ((*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides)) - (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[0].strides)));
+149: a2 = sumstat[tstar+n+1]-sumstat[checklist[i]+n+1]
__pyx_t_25 = ((__pyx_v_tstar + __pyx_v_n) + 1); __pyx_t_26 = __pyx_v_i; __pyx_t_21 = (((*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_26 * __pyx_v_checklist.strides[0]) ))) + __pyx_v_n) + 1); __pyx_v_a2 = ((*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[0].strides)) - (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides)));
+150: a3 = sumstat[tstar+2*(n+1)]-sumstat[checklist[i]+2*(n+1)]
__pyx_t_26 = (__pyx_v_tstar + (2 * (__pyx_v_n + 1))); __pyx_t_21 = __pyx_v_i; __pyx_t_25 = ((*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_21 * __pyx_v_checklist.strides[0]) ))) + (2 * (__pyx_v_n + 1))); __pyx_v_a3 = ((*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[0].strides)) - (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[0].strides)));
+151: tmplike[i] = lastchangelike[checklist[i]] + current_cost(a1, a2, a3, tstar-checklist[i])+pen
__pyx_t_21 = __pyx_v_i; __pyx_t_25 = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_21 * __pyx_v_checklist.strides[0]) ))); __pyx_t_26 = __pyx_v_i; __pyx_t_27 = __pyx_v_i; *((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_27 * __pyx_v_tmplike.strides[0]) )) = (((*((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_25 * __pyx_v_lastchangelike.strides[0]) ))) + __pyx_v_current_cost(__pyx_v_a1, __pyx_v_a2, __pyx_v_a3, (__pyx_v_tstar - (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_26 * __pyx_v_checklist.strides[0]) )))))) + __pyx_v_pen); }
+152: minout = tmplike[0]
__pyx_t_26 = 0; __pyx_v_minout = (*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_26 * __pyx_v_tmplike.strides[0]) )));
+153: whichout = 0
__pyx_v_whichout = 0;
+154: for i in range(0, nchecklist):
__pyx_t_24 = __pyx_v_nchecklist; __pyx_t_28 = __pyx_t_24; for (__pyx_t_29 = 0; __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) { __pyx_v_i = __pyx_t_29;
+155: if tmplike[i] <= minout:
__pyx_t_26 = __pyx_v_i; __pyx_t_11 = (((*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_26 * __pyx_v_tmplike.strides[0]) ))) <= __pyx_v_minout) != 0); if (__pyx_t_11) { /* … */ } }
+156: minout = tmplike[i]
__pyx_t_26 = __pyx_v_i; __pyx_v_minout = (*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_26 * __pyx_v_tmplike.strides[0]) )));
+157: whichout = i
__pyx_v_whichout = __pyx_v_i;
+158: lastchangelike[tstar] = minout
__pyx_t_26 = __pyx_v_tstar; *((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_26 * __pyx_v_lastchangelike.strides[0]) )) = __pyx_v_minout;
+159: lastchangecpts[tstar] = checklist[whichout]
__pyx_t_21 = __pyx_v_whichout; __pyx_t_25 = __pyx_v_tstar; *((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_25 * __pyx_v_lastchangecpts.strides[0]) )) = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_21 * __pyx_v_checklist.strides[0]) )));
+160: numchangecpts[tstar] = numchangecpts[lastchangecpts[tstar]]+1
__pyx_t_21 = __pyx_v_tstar; __pyx_t_30 = (*((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_21 * __pyx_v_lastchangecpts.strides[0]) ))); __pyx_t_31 = __pyx_v_tstar; *((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_31 * __pyx_v_numchangecpts.strides[0]) )) = ((*((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_30 * __pyx_v_numchangecpts.strides[0]) ))) + 1);
+161: nchecktmp = 0
__pyx_v_nchecktmp = 0;
+162: for i in range(0, nchecklist):
__pyx_t_24 = __pyx_v_nchecklist; __pyx_t_28 = __pyx_t_24; for (__pyx_t_29 = 0; __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) { __pyx_v_i = __pyx_t_29;
+163: if(tmplike[i] <= (lastchangelike[tstar]+pen)):
__pyx_t_21 = __pyx_v_i; __pyx_t_30 = __pyx_v_tstar; __pyx_t_11 = (((*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_21 * __pyx_v_tmplike.strides[0]) ))) <= ((*((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_30 * __pyx_v_lastchangelike.strides[0]) ))) + __pyx_v_pen)) != 0); if (__pyx_t_11) { /* … */ } }
+164: checklist[nchecktmp] = checklist[i]
__pyx_t_30 = __pyx_v_i; __pyx_t_21 = __pyx_v_nchecktmp; *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_21 * __pyx_v_checklist.strides[0]) )) = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_30 * __pyx_v_checklist.strides[0]) )));
+165: nchecktmp = nchecktmp+1
__pyx_v_nchecktmp = (__pyx_v_nchecktmp + 1);
+166: nchecklist = nchecktmp
__pyx_v_nchecklist = __pyx_v_nchecktmp;
+167: checklist[nchecklist] = tstar-(minseglen-1)
__pyx_t_30 = __pyx_v_nchecklist; *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_30 * __pyx_v_checklist.strides[0]) )) = (__pyx_v_tstar - (__pyx_v_minseglen - 1));
+168: nchecklist += 1
__pyx_v_nchecklist = (__pyx_v_nchecklist + 1); }
169:
+170: cdef int ncpts = 0
__pyx_v_ncpts = 0;
+171: cdef int last = n
__pyx_v_last = __pyx_v_n;
+172: while (last != 0):
while (1) { __pyx_t_11 = ((__pyx_v_last != 0) != 0); if (!__pyx_t_11) break;
+173: cptsout[ncpts] = last
__pyx_t_32 = __pyx_v_ncpts; *((int *) ( /* dim=0 */ (__pyx_v_cptsout.data + __pyx_t_32 * __pyx_v_cptsout.strides[0]) )) = __pyx_v_last;
+174: last = lastchangecpts[last]
__pyx_t_33 = __pyx_v_last; __pyx_v_last = (*((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_33 * __pyx_v_lastchangecpts.strides[0]) )));
+175: ncpts += 1
__pyx_v_ncpts = (__pyx_v_ncpts + 1); }
+176: return np.array(cptsout)[0:(ncpts)], ncpts
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_cptsout, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, __pyx_v_ncpts, NULL, NULL, NULL, 1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_ncpts); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
177:
178:
179: @cython.wraparound(False)
180: @cython.boundscheck(False)
+181: def cbin_seg(np.ndarray[DTYPE_t, ndim=2] sumstat, ITYPE_t Q, ITYPE_t minseglen, str method):
/* Python wrapper */ static PyObject *__pyx_pw_14pychangepoints_11cython_pelt_3cbin_seg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_14pychangepoints_11cython_pelt_3cbin_seg = {"cbin_seg", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14pychangepoints_11cython_pelt_3cbin_seg, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_14pychangepoints_11cython_pelt_3cbin_seg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_sumstat = 0; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_Q; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_minseglen; PyObject *__pyx_v_method = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cbin_seg (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sumstat,&__pyx_n_s_Q,&__pyx_n_s_minseglen,&__pyx_n_s_method,0}; PyObject* values[4] = {0,0,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 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sumstat)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cbin_seg", 1, 4, 4, 1); __PYX_ERR(0, 181, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_minseglen)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cbin_seg", 1, 4, 4, 2); __PYX_ERR(0, 181, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cbin_seg", 1, 4, 4, 3); __PYX_ERR(0, 181, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cbin_seg") < 0)) __PYX_ERR(0, 181, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_sumstat = ((PyArrayObject *)values[0]); __pyx_v_Q = __Pyx_PyInt_As_npy_int64(values[1]); if (unlikely((__pyx_v_Q == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 181, __pyx_L3_error) __pyx_v_minseglen = __Pyx_PyInt_As_npy_int64(values[2]); if (unlikely((__pyx_v_minseglen == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 181, __pyx_L3_error) __pyx_v_method = ((PyObject*)values[3]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cbin_seg", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pychangepoints.cython_pelt.cbin_seg", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sumstat), __pyx_ptype_5numpy_ndarray, 1, "sumstat", 0))) __PYX_ERR(0, 181, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_method), (&PyString_Type), 1, "method", 1))) __PYX_ERR(0, 181, __pyx_L1_error) __pyx_r = __pyx_pf_14pychangepoints_11cython_pelt_2cbin_seg(__pyx_self, __pyx_v_sumstat, __pyx_v_Q, __pyx_v_minseglen, __pyx_v_method); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_14pychangepoints_11cython_pelt_2cbin_seg(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sumstat, __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_Q, __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_minseglen, PyObject *__pyx_v_method) { __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_n; PyArrayObject *__pyx_v_cptsout = 0; __Pyx_memviewslice __pyx_v_likeout = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_lambda_ = { 0, 0, { 0 }, { 0 }, { 0 } }; PyArrayObject *__pyx_v_tau_ = 0; double __pyx_v_null; double __pyx_v_oldmax; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_q; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_i; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_j; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_st; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_end; __pyx_t_14pychangepoints_13cost_function_DTYPE_t (*__pyx_v_current_cost)(__pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_ITYPE_t); PyObject *__pyx_v_max_out = NULL; PyObject *__pyx_v_whichout = NULL; __Pyx_LocalBuf_ND __pyx_pybuffernd_cptsout; __Pyx_Buffer __pyx_pybuffer_cptsout; __Pyx_LocalBuf_ND __pyx_pybuffernd_sumstat; __Pyx_Buffer __pyx_pybuffer_sumstat; __Pyx_LocalBuf_ND __pyx_pybuffernd_tau_; __Pyx_Buffer __pyx_pybuffer_tau_; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cbin_seg", 0); __pyx_pybuffer_cptsout.pybuffer.buf = NULL; __pyx_pybuffer_cptsout.refcount = 0; __pyx_pybuffernd_cptsout.data = NULL; __pyx_pybuffernd_cptsout.rcbuffer = &__pyx_pybuffer_cptsout; __pyx_pybuffer_tau_.pybuffer.buf = NULL; __pyx_pybuffer_tau_.refcount = 0; __pyx_pybuffernd_tau_.data = NULL; __pyx_pybuffernd_tau_.rcbuffer = &__pyx_pybuffer_tau_; __pyx_pybuffer_sumstat.pybuffer.buf = NULL; __pyx_pybuffer_sumstat.refcount = 0; __pyx_pybuffernd_sumstat.data = NULL; __pyx_pybuffernd_sumstat.rcbuffer = &__pyx_pybuffer_sumstat; { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumstat, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 181, __pyx_L1_error) } __pyx_pybuffernd_sumstat.diminfo[0].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumstat.diminfo[0].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sumstat.diminfo[1].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sumstat.diminfo[1].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[1]; /* … */ /* function exit code */ __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_XDEC_MEMVIEW(&__pyx_t_7, 1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cptsout.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tau_.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("pychangepoints.cython_pelt.cbin_seg", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cptsout.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tau_.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_cptsout); __PYX_XDEC_MEMVIEW(&__pyx_v_likeout, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_lambda_, 1); __Pyx_XDECREF((PyObject *)__pyx_v_tau_); __Pyx_XDECREF(__pyx_v_max_out); __Pyx_XDECREF(__pyx_v_whichout); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__29 = PyTuple_Pack(21, __pyx_n_s_sumstat, __pyx_n_s_Q, __pyx_n_s_minseglen, __pyx_n_s_method, __pyx_n_s_n, __pyx_n_s_cptsout, __pyx_n_s_likeout, __pyx_n_s_op_cps, __pyx_n_s_lambda, __pyx_n_s_tau, __pyx_n_s_null, __pyx_n_s_oldmax, __pyx_n_s_q, __pyx_n_s_p, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_st, __pyx_n_s_end, __pyx_n_s_current_cost, __pyx_n_s_max_out, __pyx_n_s_whichout); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14pychangepoints_11cython_pelt_3cbin_seg, NULL, __pyx_n_s_pychangepoints_cython_pelt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_cbin_seg, __pyx_t_1) < 0) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(4, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pychangepoints_pelt_cython_pyx, __pyx_n_s_cbin_seg, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 181, __pyx_L1_error)
+182: cdef ITYPE_t n = sumstat.shape[0] - 1
__pyx_v_n = ((__pyx_v_sumstat->dimensions[0]) - 1);
+183: cdef np.ndarray[ITYPE_t, ndim=1] cptsout = np.zeros(Q, dtype=np.int64)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 183, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_5); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cptsout.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_cptsout = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.buf = NULL; __PYX_ERR(0, 183, __pyx_L1_error) } else {__pyx_pybuffernd_cptsout.diminfo[0].strides = __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cptsout.diminfo[0].shape = __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.shape[0]; } } __pyx_t_6 = 0; __pyx_v_cptsout = ((PyArrayObject *)__pyx_t_5); __pyx_t_5 = 0;
+184: cdef double [:] likeout = np.zeros(Q)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_likeout = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
185: cdef ITYPE_t op_cps
+186: cdef double [:] lambda_ = np.zeros(n)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_lambda_ = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
+187: cdef np.ndarray[ITYPE_t, ndim=1] tau_ = np.zeros(Q+2).astype(np.int64)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_npy_int64((__pyx_v_Q + 2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 187, __pyx_L1_error) __pyx_t_8 = ((PyArrayObject *)__pyx_t_5); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tau_.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_tau_ = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf = NULL; __PYX_ERR(0, 187, __pyx_L1_error) } else {__pyx_pybuffernd_tau_.diminfo[0].strides = __pyx_pybuffernd_tau_.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tau_.diminfo[0].shape = __pyx_pybuffernd_tau_.rcbuffer->pybuffer.shape[0]; } } __pyx_t_8 = 0; __pyx_v_tau_ = ((PyArrayObject *)__pyx_t_5); __pyx_t_5 = 0;
+188: tau_[0] = 0
__pyx_t_9 = 0; *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_tau_.diminfo[0].strides) = 0;
+189: tau_[1] = n
__pyx_t_10 = 1; *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_tau_.diminfo[0].strides) = __pyx_v_n;
190: cdef double null
+191: cdef double oldmax = np.inf
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_inf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_oldmax = __pyx_t_11;
192: cdef ITYPE_t q, p, i, j, st, end
193:
+194: if method == "mll_mean":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_mean, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 194, __pyx_L1_error) __pyx_t_13 = (__pyx_t_12 != 0); if (__pyx_t_13) { /* … */ goto __pyx_L3; }
+195: current_cost = mll_mean
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_mean;
+196: elif method == "mll_var":
__pyx_t_13 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_var, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 196, __pyx_L1_error) __pyx_t_12 = (__pyx_t_13 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+197: current_cost = mll_var
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_var;
+198: elif method == "mll_meanvar":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 198, __pyx_L1_error) __pyx_t_13 = (__pyx_t_12 != 0); if (__pyx_t_13) { /* … */ goto __pyx_L3; }
+199: current_cost = mll_meanvar
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar;
+200: elif method == "mll_meanvar_exp":
__pyx_t_13 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar_exp, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 200, __pyx_L1_error) __pyx_t_12 = (__pyx_t_13 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+201: current_cost = mll_meanvar_exp
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar_exp;
+202: elif method == "mll_meanvar_poisson":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar_poisson, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 202, __pyx_L1_error) __pyx_t_13 = (__pyx_t_12 != 0); if (__pyx_t_13) { /* … */ goto __pyx_L3; }
+203: current_cost = mll_meanvar_poisson
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar_poisson;
+204: elif method == "mbic_var":
__pyx_t_13 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_var, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 204, __pyx_L1_error) __pyx_t_12 = (__pyx_t_13 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+205: current_cost = mbic_var
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_var;
+206: elif method == "mbic_meanvar":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 206, __pyx_L1_error) __pyx_t_13 = (__pyx_t_12 != 0); if (__pyx_t_13) { /* … */ goto __pyx_L3; }
+207: current_cost = mbic_meanvar
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar;
+208: elif method == "mbic_mean":
__pyx_t_13 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_mean, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 208, __pyx_L1_error) __pyx_t_12 = (__pyx_t_13 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+209: current_cost = mbic_mean
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_mean;
+210: elif method == "mbic_meanvar_exp":
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar_exp, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 210, __pyx_L1_error) __pyx_t_13 = (__pyx_t_12 != 0); if (__pyx_t_13) { /* … */ goto __pyx_L3; }
+211: current_cost = mbic_meanvar_exp
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar_exp;
+212: elif method == "mbic_meanvar_poisson":
__pyx_t_13 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar_poisson, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 212, __pyx_L1_error) __pyx_t_12 = (__pyx_t_13 != 0); if (__pyx_t_12) { /* … */ goto __pyx_L3; }
+213: current_cost = mbic_meanvar_poisson
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar_poisson;
214: else:
+215: current_cost = mll_meanvar
/*else*/ { __pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar; } __pyx_L3:;
216:
+217: for q in range(Q):
__pyx_t_14 = __pyx_v_Q; __pyx_t_15 = __pyx_t_14; for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_q = __pyx_t_16;
+218: lambda_= np.zeros(n)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_lambda_, 1); __pyx_v_lambda_ = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
+219: i = 1
__pyx_v_i = 1;
+220: st = tau_[0]+1
__pyx_t_17 = 0; __pyx_v_st = ((*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_tau_.diminfo[0].strides)) + 1);
+221: end = tau_[1]
__pyx_t_17 = 1; __pyx_v_end = (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_tau_.diminfo[0].strides));
+222: null = (-0.5)*current_cost(sumstat[end, 0]-sumstat[st-1, 0], sumstat[end, 1]-sumstat[st-1, 1], sumstat[end, 2]-sumstat[st-1, 2], end - st + 1)
__pyx_t_18 = __pyx_v_end; __pyx_t_17 = 0; __pyx_t_19 = (__pyx_v_st - 1); __pyx_t_20 = 0; __pyx_t_21 = __pyx_v_end; __pyx_t_22 = 1; __pyx_t_23 = (__pyx_v_st - 1); __pyx_t_24 = 1; __pyx_t_25 = __pyx_v_end; __pyx_t_26 = 2; __pyx_t_27 = (__pyx_v_st - 1); __pyx_t_28 = 2; __pyx_v_null = (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((__pyx_v_end - __pyx_v_st) + 1)));
+223: for j in range(2, n-2):
__pyx_t_27 = (__pyx_v_n - 2); __pyx_t_25 = __pyx_t_27; for (__pyx_t_23 = 2; __pyx_t_23 < __pyx_t_25; __pyx_t_23+=1) { __pyx_v_j = __pyx_t_23;
+224: if (j == end):
__pyx_t_12 = ((__pyx_v_j == __pyx_v_end) != 0); if (__pyx_t_12) { /* … */ goto __pyx_L8; }
+225: st = end+1
__pyx_v_st = (__pyx_v_end + 1);
+226: i = i+1
__pyx_v_i = (__pyx_v_i + 1);
+227: end = tau_[i]
__pyx_t_21 = __pyx_v_i; __pyx_v_end = (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_tau_.diminfo[0].strides));
+228: null = (-0.5)*current_cost(sumstat[end, 0]-sumstat[st-1, 0], sumstat[end, 1]-sumstat[st-1, 1], sumstat[end, 2]-sumstat[st-1, 2], end - st + 1)
__pyx_t_21 = __pyx_v_end; __pyx_t_28 = 0; __pyx_t_19 = (__pyx_v_st - 1); __pyx_t_26 = 0; __pyx_t_18 = __pyx_v_end; __pyx_t_24 = 1; __pyx_t_29 = (__pyx_v_st - 1); __pyx_t_22 = 1; __pyx_t_30 = __pyx_v_end; __pyx_t_20 = 2; __pyx_t_31 = (__pyx_v_st - 1); __pyx_t_17 = 2; __pyx_v_null = (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((__pyx_v_end - __pyx_v_st) + 1)));
229: else:
+230: if (j-st >= minseglen) & (end-j >= minseglen):
/*else*/ { __pyx_t_12 = ((((__pyx_v_j - __pyx_v_st) >= __pyx_v_minseglen) & ((__pyx_v_end - __pyx_v_j) >= __pyx_v_minseglen)) != 0); if (__pyx_t_12) { /* … */ } } __pyx_L8:; }
+231: lambda_[j] = ((-0.5)*current_cost(sumstat[j, 0]-sumstat[st-1, 0], sumstat[j, 1]-sumstat[st-1, 1], sumstat[j, 2]-sumstat[st-1, 2], j - st + 1)) + ((-0.5)*current_cost(sumstat[end, 0]-sumstat[j, 0], sumstat[end, 1]-sumstat[j, 1], sumstat[end, 2]-sumstat[j, 2], end - j)) - null
__pyx_t_31 = __pyx_v_j; __pyx_t_17 = 0; __pyx_t_30 = (__pyx_v_st - 1); __pyx_t_20 = 0; __pyx_t_29 = __pyx_v_j; __pyx_t_22 = 1; __pyx_t_18 = (__pyx_v_st - 1); __pyx_t_24 = 1; __pyx_t_19 = __pyx_v_j; __pyx_t_26 = 2; __pyx_t_21 = (__pyx_v_st - 1); __pyx_t_28 = 2; __pyx_t_32 = __pyx_v_end; __pyx_t_33 = 0; __pyx_t_34 = __pyx_v_j; __pyx_t_35 = 0; __pyx_t_36 = __pyx_v_end; __pyx_t_37 = 1; __pyx_t_38 = __pyx_v_j; __pyx_t_39 = 1; __pyx_t_40 = __pyx_v_end; __pyx_t_41 = 2; __pyx_t_42 = __pyx_v_j; __pyx_t_43 = 2; __pyx_t_44 = __pyx_v_j; *((double *) ( /* dim=0 */ (__pyx_v_lambda_.data + __pyx_t_44 * __pyx_v_lambda_.strides[0]) )) = (((-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((__pyx_v_j - __pyx_v_st) + 1))) + (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_41, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_43, __pyx_pybuffernd_sumstat.diminfo[1].strides))), (__pyx_v_end - __pyx_v_j)))) - __pyx_v_null);
+232: max_out = np.max(lambda_)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_lambda_, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_max_out, __pyx_t_2); __pyx_t_2 = 0;
+233: whichout = np.argmax(lambda_)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_argmax); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_lambda_, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_whichout, __pyx_t_2); __pyx_t_2 = 0;
234:
+235: cptsout[q] = whichout
__pyx_t_27 = __Pyx_PyInt_As_npy_int64(__pyx_v_whichout); if (unlikely((__pyx_t_27 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 235, __pyx_L1_error) __pyx_t_25 = __pyx_v_q; *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_cptsout.diminfo[0].strides) = __pyx_t_27;
+236: likeout[q] = min(oldmax, max_out)
__Pyx_INCREF(__pyx_v_max_out); __pyx_t_2 = __pyx_v_max_out; __pyx_t_11 = __pyx_v_oldmax; __pyx_t_5 = PyFloat_FromDouble(__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_12) { __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; } else { __pyx_t_1 = PyFloat_FromDouble(__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_27 = __pyx_v_q; *((double *) ( /* dim=0 */ (__pyx_v_likeout.data + __pyx_t_27 * __pyx_v_likeout.strides[0]) )) = __pyx_t_11;
+237: oldmax = likeout[q]
__pyx_t_23 = __pyx_v_q; __pyx_v_oldmax = (*((double *) ( /* dim=0 */ (__pyx_v_likeout.data + __pyx_t_23 * __pyx_v_likeout.strides[0]) )));
+238: tau_[q+2] = whichout
__pyx_t_23 = __Pyx_PyInt_As_npy_int64(__pyx_v_whichout); if (unlikely((__pyx_t_23 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 238, __pyx_L1_error) __pyx_t_42 = (__pyx_v_q + 2); *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_tau_.diminfo[0].strides) = __pyx_t_23;
239: #tau_ = order_vec(tau_, q+3)
+240: order_vec(tau_, q+3)
__pyx_t_3 = __pyx_f_14pychangepoints_5utils_order_vec(((PyArrayObject *)__pyx_v_tau_), (__pyx_v_q + 3)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; }
241:
+242: return np.array(cptsout)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_v_cptsout)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cptsout)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
243:
244:
245: @cython.wraparound(False)
246: @cython.boundscheck(False)
+247: def cseg_neigh(np.ndarray[DTYPE_t, ndim=2] sumstat, ITYPE_t Q, str method):
/* Python wrapper */ static PyObject *__pyx_pw_14pychangepoints_11cython_pelt_5cseg_neigh(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_14pychangepoints_11cython_pelt_5cseg_neigh = {"cseg_neigh", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14pychangepoints_11cython_pelt_5cseg_neigh, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_14pychangepoints_11cython_pelt_5cseg_neigh(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_sumstat = 0; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_Q; PyObject *__pyx_v_method = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cseg_neigh (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sumstat,&__pyx_n_s_Q,&__pyx_n_s_method,0}; PyObject* values[3] = {0,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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sumstat)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cseg_neigh", 1, 3, 3, 1); __PYX_ERR(0, 247, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cseg_neigh", 1, 3, 3, 2); __PYX_ERR(0, 247, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cseg_neigh") < 0)) __PYX_ERR(0, 247, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_sumstat = ((PyArrayObject *)values[0]); __pyx_v_Q = __Pyx_PyInt_As_npy_int64(values[1]); if (unlikely((__pyx_v_Q == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 247, __pyx_L3_error) __pyx_v_method = ((PyObject*)values[2]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cseg_neigh", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 247, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pychangepoints.cython_pelt.cseg_neigh", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sumstat), __pyx_ptype_5numpy_ndarray, 1, "sumstat", 0))) __PYX_ERR(0, 247, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_method), (&PyString_Type), 1, "method", 1))) __PYX_ERR(0, 247, __pyx_L1_error) __pyx_r = __pyx_pf_14pychangepoints_11cython_pelt_4cseg_neigh(__pyx_self, __pyx_v_sumstat, __pyx_v_Q, __pyx_v_method); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_14pychangepoints_11cython_pelt_4cseg_neigh(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sumstat, __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_Q, PyObject *__pyx_v_method) { __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_n; PyArrayObject *__pyx_v_all_seg = 0; int __pyx_v_i; int __pyx_v_j; int __pyx_v_q; __pyx_t_14pychangepoints_13cost_function_DTYPE_t (*__pyx_v_current_cost)(__pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_DTYPE_t, __pyx_t_14pychangepoints_13cost_function_ITYPE_t); PyArrayObject *__pyx_v_like_q = 0; PyArrayObject *__pyx_v_cp = 0; __pyx_t_14pychangepoints_11cython_pelt_DTYPE_t __pyx_v_max_out; __pyx_t_14pychangepoints_11cython_pelt_ITYPE_t __pyx_v_max_which; PyArrayObject *__pyx_v_like = 0; PyArrayObject *__pyx_v_cps_Q = 0; PyObject *__pyx_v_criterium = NULL; PyObject *__pyx_v_op_cps = NULL; PyObject *__pyx_v_cpts = NULL; __Pyx_LocalBuf_ND __pyx_pybuffernd_all_seg; __Pyx_Buffer __pyx_pybuffer_all_seg; __Pyx_LocalBuf_ND __pyx_pybuffernd_cp; __Pyx_Buffer __pyx_pybuffer_cp; __Pyx_LocalBuf_ND __pyx_pybuffernd_cps_Q; __Pyx_Buffer __pyx_pybuffer_cps_Q; __Pyx_LocalBuf_ND __pyx_pybuffernd_like; __Pyx_Buffer __pyx_pybuffer_like; __Pyx_LocalBuf_ND __pyx_pybuffernd_like_q; __Pyx_Buffer __pyx_pybuffer_like_q; __Pyx_LocalBuf_ND __pyx_pybuffernd_sumstat; __Pyx_Buffer __pyx_pybuffer_sumstat; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cseg_neigh", 0); __pyx_pybuffer_all_seg.pybuffer.buf = NULL; __pyx_pybuffer_all_seg.refcount = 0; __pyx_pybuffernd_all_seg.data = NULL; __pyx_pybuffernd_all_seg.rcbuffer = &__pyx_pybuffer_all_seg; __pyx_pybuffer_like_q.pybuffer.buf = NULL; __pyx_pybuffer_like_q.refcount = 0; __pyx_pybuffernd_like_q.data = NULL; __pyx_pybuffernd_like_q.rcbuffer = &__pyx_pybuffer_like_q; __pyx_pybuffer_cp.pybuffer.buf = NULL; __pyx_pybuffer_cp.refcount = 0; __pyx_pybuffernd_cp.data = NULL; __pyx_pybuffernd_cp.rcbuffer = &__pyx_pybuffer_cp; __pyx_pybuffer_like.pybuffer.buf = NULL; __pyx_pybuffer_like.refcount = 0; __pyx_pybuffernd_like.data = NULL; __pyx_pybuffernd_like.rcbuffer = &__pyx_pybuffer_like; __pyx_pybuffer_cps_Q.pybuffer.buf = NULL; __pyx_pybuffer_cps_Q.refcount = 0; __pyx_pybuffernd_cps_Q.data = NULL; __pyx_pybuffernd_cps_Q.rcbuffer = &__pyx_pybuffer_cps_Q; __pyx_pybuffer_sumstat.pybuffer.buf = NULL; __pyx_pybuffer_sumstat.refcount = 0; __pyx_pybuffernd_sumstat.data = NULL; __pyx_pybuffernd_sumstat.rcbuffer = &__pyx_pybuffer_sumstat; { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumstat, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 247, __pyx_L1_error) } __pyx_pybuffernd_sumstat.diminfo[0].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumstat.diminfo[0].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sumstat.diminfo[1].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sumstat.diminfo[1].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[1]; /* … */ /* function exit code */ __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); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_all_seg.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cp.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cps_Q.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like_q.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("pychangepoints.cython_pelt.cseg_neigh", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_all_seg.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cp.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cps_Q.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like_q.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_all_seg); __Pyx_XDECREF((PyObject *)__pyx_v_like_q); __Pyx_XDECREF((PyObject *)__pyx_v_cp); __Pyx_XDECREF((PyObject *)__pyx_v_like); __Pyx_XDECREF((PyObject *)__pyx_v_cps_Q); __Pyx_XDECREF(__pyx_v_criterium); __Pyx_XDECREF(__pyx_v_op_cps); __Pyx_XDECREF(__pyx_v_cpts); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__31 = PyTuple_Pack(19, __pyx_n_s_sumstat, __pyx_n_s_Q, __pyx_n_s_method, __pyx_n_s_n, __pyx_n_s_all_seg, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_q, __pyx_n_s_s, __pyx_n_s_current_cost, __pyx_n_s_like_q, __pyx_n_s_cp, __pyx_n_s_max_out, __pyx_n_s_max_which, __pyx_n_s_like, __pyx_n_s_cps_Q, __pyx_n_s_criterium, __pyx_n_s_op_cps, __pyx_n_s_cpts); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31); /* … */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14pychangepoints_11cython_pelt_5cseg_neigh, NULL, __pyx_n_s_pychangepoints_cython_pelt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_cseg_neigh, __pyx_t_1) < 0) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(3, 0, 19, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pychangepoints_pelt_cython_pyx, __pyx_n_s_cseg_neigh, 247, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 247, __pyx_L1_error)
+248: cdef ITYPE_t n = sumstat.shape[0]
__pyx_v_n = (__pyx_v_sumstat->dimensions[0]);
+249: cdef np.ndarray[DTYPE_t, ndim=2] all_seg = np.zeros((n, n))
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __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_5numpy_ndarray))))) __PYX_ERR(0, 249, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_all_seg.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_all_seg = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.buf = NULL; __PYX_ERR(0, 249, __pyx_L1_error) } else {__pyx_pybuffernd_all_seg.diminfo[0].strides = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_all_seg.diminfo[0].shape = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_all_seg.diminfo[1].strides = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_all_seg.diminfo[1].shape = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.shape[1]; } } __pyx_t_6 = 0; __pyx_v_all_seg = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0;
250: cdef int i, j, q
251: cdef DTYPE_t s
252:
+253: if method == "mll_mean":
__pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_mean, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 253, __pyx_L1_error) __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* … */ goto __pyx_L3; }
+254: current_cost = mll_mean
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_mean;
+255: elif method == "mll_var":
__pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_var, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 255, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 != 0); if (__pyx_t_7) { /* … */ goto __pyx_L3; }
+256: current_cost = mll_var
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_var;
+257: elif method == "mll_meanvar":
__pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 257, __pyx_L1_error) __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* … */ goto __pyx_L3; }
+258: current_cost = mll_meanvar
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar;
+259: elif method == "mll_meanvar_exp":
__pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar_exp, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 259, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 != 0); if (__pyx_t_7) { /* … */ goto __pyx_L3; }
+260: current_cost = mll_meanvar_exp
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar_exp;
+261: elif method == "mll_meanvar_poisson":
__pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_meanvar_poisson, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* … */ goto __pyx_L3; }
+262: current_cost = mll_meanvar_poisson
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar_poisson;
+263: elif method == "mbic_var":
__pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_var, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 263, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 != 0); if (__pyx_t_7) { /* … */ goto __pyx_L3; }
+264: current_cost = mbic_var
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_var;
+265: elif method == "mbic_meanvar":
__pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 265, __pyx_L1_error) __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* … */ goto __pyx_L3; }
+266: current_cost = mbic_meanvar
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar;
+267: elif method == "mbic_mean":
__pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_mean, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 267, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 != 0); if (__pyx_t_7) { /* … */ goto __pyx_L3; }
+268: current_cost = mbic_mean
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_mean;
+269: elif method == "mbic_meanvar_exp":
__pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar_exp, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 269, __pyx_L1_error) __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* … */ goto __pyx_L3; }
+270: current_cost = mbic_meanvar_exp
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar_exp;
+271: elif method == "mbic_meanvar_poisson":
__pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_meanvar_poisson, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 271, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 != 0); if (__pyx_t_7) { /* … */ goto __pyx_L3; }
+272: current_cost = mbic_meanvar_poisson
__pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mbic_meanvar_poisson;
273: else:
+274: current_cost = mll_meanvar
/*else*/ { __pyx_v_current_cost = __pyx_f_14pychangepoints_13cost_function_mll_meanvar; } __pyx_L3:;
+275: for i in range(0, n) :
__pyx_t_9 = __pyx_v_n; __pyx_t_10 = __pyx_t_9; for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_i = __pyx_t_11;
+276: for j in prange(i, n, nogil=True):
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { __pyx_t_12 = __pyx_v_i; __pyx_t_13 = __pyx_v_n; if ((1 == 0)) abort(); { #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) (x) #define unlikely(x) (x) #endif __pyx_t_15 = (__pyx_t_13 - __pyx_t_12 + 1 - 1/abs(1)) / 1; if (__pyx_t_15 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) #endif /* _OPENMP */ for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_15; __pyx_t_14++){ { __pyx_v_j = (int)(__pyx_t_12 + 1 * __pyx_t_14); /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L10; } __pyx_L10:; } } }
+277: all_seg[i, j] = -0.5*current_cost(sumstat[j, 0]-sumstat[i, 0], sumstat[j, 1]-sumstat[i, 1], sumstat[j, 2]-sumstat[i, 2], j-i+1)
__pyx_t_16 = __pyx_v_j; __pyx_t_17 = 0; __pyx_t_18 = __pyx_v_i; __pyx_t_19 = 0; __pyx_t_20 = __pyx_v_j; __pyx_t_21 = 1; __pyx_t_22 = __pyx_v_i; __pyx_t_23 = 1; __pyx_t_24 = __pyx_v_j; __pyx_t_25 = 2; __pyx_t_26 = __pyx_v_i; __pyx_t_27 = 2; __pyx_t_28 = __pyx_v_i; __pyx_t_29 = __pyx_v_j; *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_all_seg.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_all_seg.diminfo[1].strides) = (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[1].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_sumstat.diminfo[1].strides))), ((__pyx_v_j - __pyx_v_i) + 1))); } } } } } #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif }
+278: cdef np.ndarray[DTYPE_t, ndim=2] like_q = np.zeros((Q, n))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) __pyx_t_30 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_like_q.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_like_q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_like_q.rcbuffer->pybuffer.buf = NULL; __PYX_ERR(0, 278, __pyx_L1_error) } else {__pyx_pybuffernd_like_q.diminfo[0].strides = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_like_q.diminfo[0].shape = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_like_q.diminfo[1].strides = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_like_q.diminfo[1].shape = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.shape[1]; } } __pyx_t_30 = 0; __pyx_v_like_q = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0;
+279: like_q[0, :] = all_seg[0, :]
__pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); /* … */ __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_all_seg), __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_like_q), __pyx_tuple__2, __pyx_t_1) < 0)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_tuple__2 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2);
+280: cdef np.ndarray[ITYPE_t, ndim=2] cp = np.zeros((Q, n), dtype=np.int64)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 280, __pyx_L1_error) __pyx_t_31 = ((PyArrayObject *)__pyx_t_3); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cp.rcbuffer->pybuffer, (PyObject*)__pyx_t_31, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_cp = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf = NULL; __PYX_ERR(0, 280, __pyx_L1_error) } else {__pyx_pybuffernd_cp.diminfo[0].strides = __pyx_pybuffernd_cp.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cp.diminfo[0].shape = __pyx_pybuffernd_cp.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_cp.diminfo[1].strides = __pyx_pybuffernd_cp.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_cp.diminfo[1].shape = __pyx_pybuffernd_cp.rcbuffer->pybuffer.shape[1]; } } __pyx_t_31 = 0; __pyx_v_cp = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0;
+281: cdef DTYPE_t max_out = -np.inf
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_inf); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Negative(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_32 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_32 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_max_out = __pyx_t_32;
282: cdef ITYPE_t max_which
283: cdef np.ndarray[DTYPE_t, ndim=1] like
284:
+285: for q in range(1, Q):
__pyx_t_9 = __pyx_v_Q; __pyx_t_10 = __pyx_t_9; for (__pyx_t_11 = 1; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_q = __pyx_t_11;
+286: for j in range(q, n):
__pyx_t_15 = __pyx_v_n; __pyx_t_14 = __pyx_t_15; for (__pyx_t_12 = __pyx_v_q; __pyx_t_12 < __pyx_t_14; __pyx_t_12+=1) { __pyx_v_j = __pyx_t_12;
+287: like = like_q[q-1, (q-1):(j-1)]+all_seg[q:j, j]
__pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_q - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_q - 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_j - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PySlice_New(__pyx_t_4, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_like_q), __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_q); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySlice_New(__pyx_t_2, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_all_seg), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_t_33 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like.rcbuffer->pybuffer); __pyx_t_34 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_like.rcbuffer->pybuffer, (PyObject*)__pyx_t_33, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); if (unlikely(__pyx_t_34 < 0)) { PyErr_Fetch(&__pyx_t_35, &__pyx_t_36, &__pyx_t_37); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_like.rcbuffer->pybuffer, (PyObject*)__pyx_v_like, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_35); Py_XDECREF(__pyx_t_36); Py_XDECREF(__pyx_t_37); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_35, __pyx_t_36, __pyx_t_37); } __pyx_t_35 = __pyx_t_36 = __pyx_t_37 = 0; } __pyx_pybuffernd_like.diminfo[0].strides = __pyx_pybuffernd_like.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_like.diminfo[0].shape = __pyx_pybuffernd_like.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_34 < 0)) __PYX_ERR(0, 287, __pyx_L1_error) } __pyx_t_33 = 0; __Pyx_XDECREF_SET(__pyx_v_like, ((PyArrayObject *)__pyx_t_2)); __pyx_t_2 = 0;
+288: max_which = 0
__pyx_v_max_which = 0;
+289: max_out = -np.inf
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_inf); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Negative(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_32 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_32 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_max_out = __pyx_t_32;
+290: for i in range(0, j-q):
__pyx_t_34 = (__pyx_v_j - __pyx_v_q); __pyx_t_38 = __pyx_t_34; for (__pyx_t_39 = 0; __pyx_t_39 < __pyx_t_38; __pyx_t_39+=1) { __pyx_v_i = __pyx_t_39;
+291: if max_out <= like[i]:
__pyx_t_27 = __pyx_v_i; __pyx_t_7 = ((__pyx_v_max_out <= (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_like.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_like.diminfo[0].strides))) != 0); if (__pyx_t_7) { /* … */ } }
+292: max_out = like[i]
__pyx_t_27 = __pyx_v_i; __pyx_v_max_out = (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_like.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_like.diminfo[0].strides));
+293: max_which = i
__pyx_v_max_which = __pyx_v_i;
294: #print(max_out, max_which)
295:
+296: like_q[q, j] = max_out
__pyx_t_27 = __pyx_v_q; __pyx_t_26 = __pyx_v_j; *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_DTYPE_t *, __pyx_pybuffernd_like_q.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_like_q.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_like_q.diminfo[1].strides) = __pyx_v_max_out;
+297: cp[q, j] = max_which + q
__pyx_t_25 = __pyx_v_q; __pyx_t_24 = __pyx_v_j; *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_cp.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_cp.diminfo[1].strides) = (__pyx_v_max_which + __pyx_v_q); } }
+298: cdef np.ndarray[ITYPE_t, ndim=2] cps_Q = np.zeros((Q, Q), dtype=np.int64)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 298, __pyx_L1_error) __pyx_t_40 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cps_Q.rcbuffer->pybuffer, (PyObject*)__pyx_t_40, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_11cython_pelt_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_cps_Q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf = NULL; __PYX_ERR(0, 298, __pyx_L1_error) } else {__pyx_pybuffernd_cps_Q.diminfo[0].strides = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cps_Q.diminfo[0].shape = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_cps_Q.diminfo[1].strides = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_cps_Q.diminfo[1].shape = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.shape[1]; } } __pyx_t_40 = 0; __pyx_v_cps_Q = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0;
+299: for q in range(1, Q):
__pyx_t_9 = __pyx_v_Q; __pyx_t_10 = __pyx_t_9; for (__pyx_t_11 = 1; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_q = __pyx_t_11;
+300: cps_Q[q, 0] = cp[q, n-1]
__pyx_t_23 = __pyx_v_q; __pyx_t_15 = (__pyx_v_n - 1); __pyx_t_22 = __pyx_v_q; __pyx_t_21 = 0; *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_cps_Q.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_cps_Q.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_cp.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_cp.diminfo[1].strides));
+301: for i in range(0, q):
__pyx_t_12 = __pyx_v_q; __pyx_t_34 = __pyx_t_12; for (__pyx_t_38 = 0; __pyx_t_38 < __pyx_t_34; __pyx_t_38+=1) { __pyx_v_i = __pyx_t_38;
+302: cps_Q[q, i+1] = cp[q-i-1, cps_Q[q, i]]
__pyx_t_23 = __pyx_v_q; __pyx_t_20 = __pyx_v_i; __pyx_t_19 = ((__pyx_v_q - __pyx_v_i) - 1); __pyx_t_15 = (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_cps_Q.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_cps_Q.diminfo[1].strides)); __pyx_t_18 = __pyx_v_q; __pyx_t_17 = (__pyx_v_i + 1); *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_cps_Q.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_cps_Q.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_11cython_pelt_ITYPE_t *, __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_cp.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_cp.diminfo[1].strides)); } }
303:
+304: criterium = -2 * like_q[:, n-2]
__pyx_t_1 = __Pyx_PyInt_From_npy_int64((__pyx_v_n - 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice_); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_like_q), __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Multiply(__pyx_int_neg_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_criterium = __pyx_t_4; __pyx_t_4 = 0;
+305: op_cps = np.argmin(criterium)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_argmin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_v_criterium) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_criterium); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_op_cps = __pyx_t_4; __pyx_t_4 = 0;
+306: cpts = np.sort(cps_Q[op_cps, :][cps_Q[op_cps, :] > 0])
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_op_cps); __Pyx_GIVEREF(__pyx_v_op_cps); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_op_cps); __Pyx_INCREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice_); __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_cps_Q), __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_op_cps); __Pyx_GIVEREF(__pyx_v_op_cps); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_op_cps); __Pyx_INCREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice_); __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_cps_Q), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_cpts = __pyx_t_4; __pyx_t_4 = 0;
307:
+308: return cpts
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_cpts); __pyx_r = __pyx_v_cpts; goto __pyx_L0;
309: