diff --git a/.gitignore b/.gitignore index 450a5669cf2bc..3c5ceb0e2a87e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,6 @@ benchmarks/bench_covertype_data/ *.prefs .pydevproject +build/* +.project .idea diff --git a/doc/images/hinge.png b/doc/images/hinge.png new file mode 100644 index 0000000000000..8c420c45fce97 Binary files /dev/null and b/doc/images/hinge.png differ diff --git a/doc/images/piecewise_linear.png b/doc/images/piecewise_linear.png new file mode 100644 index 0000000000000..65f46a277449f Binary files /dev/null and b/doc/images/piecewise_linear.png differ diff --git a/doc/modules/classes.rst b/doc/modules/classes.rst index 59936abf64737..d257be0cae44f 100644 --- a/doc/modules/classes.rst +++ b/doc/modules/classes.rst @@ -1151,6 +1151,26 @@ Low-level methods tree.export_graphviz +.. _earth_ref: + +:mod:`sklearn.earth`: Earth +=========================== + +.. automodule:: sklearn.earth + :no-members: + :no-inherited-members: + +**User guide:** See the :ref:`earth` section for further details. + +.. currentmodule:: sklearn + +.. autosummary:: + :toctree: generated/ + :template: class.rst + + earth.Earth + + .. _utils_ref: :mod:`sklearn.utils`: Utilities diff --git a/doc/modules/earth.rst b/doc/modules/earth.rst new file mode 100644 index 0000000000000..1497cefd77255 --- /dev/null +++ b/doc/modules/earth.rst @@ -0,0 +1,84 @@ +.. _earth: + +======================================== +Multivariate Adaptive Regression Splines +======================================== + +.. currentmodule:: sklearn.earth + +Multivariate adaptive regression splines, implemented by the :class:`EarthRegressor` class, is a method for supervised +learning that is most commonly used for feature extraction and selection. ``EarthRegressor`` models can be thought of as linear models in a higher dimensional +basis space. ``EarthRegressor`` automatically searches for interactions and non-linear relationships. Each term in an ``EarthRegressor`` model is a +product of so called "hinge functions". A hinge function is a function that's equal to its argument where that argument +is greater than zero and is zero everywhere else. + +.. math:: + \text{h}\left(x-t\right)=\left[x-t\right]_{+}=\begin{cases} + x-t, & x>t\\ + 0, & x\leq t + \end{cases} + +.. image:: ../images/hinge.png + +An ``EarthRegressor`` model is a linear combination of basis functions, each of which is a product of one +or more of the following: + + 1. A constant + 2. Linear functions of input variables + 3. Hinge functions of input variables + +For example, a simple piecewise linear function in one variable can be expressed +as a linear combination of two hinge functions and a constant (see below). During fitting, the ``EarthRegressor`` class +automatically determines which variables and basis functions to use. +The algorithm has two stages. First, the +forward pass searches for terms that locally minimize squared error loss on the training set. Next, a pruning pass selects a subset of those +terms that produces a locally minimal generalized cross-validation (GCV) score. The GCV +score is not actually based on cross-validation, but rather is meant to approximate a true +cross-validation score by penalizing model complexity. The final result is a set of basis functions +that is nonlinear in the original feature space, may include interactions, and is likely to +generalize well. + + +.. math:: + y=1-2\text{h}\left(1-x\right)+\frac{1}{2}\text{h}\left(x-1\right) + + +.. image:: ../images/piecewise_linear.png + + +A Simple EarthRegressor Example +---------------------- + +.. literalinclude:: ../auto_examples/earth/plot_v_function.py + :lines: 13- + + +.. figure:: ../auto_examples/earth/images/plot_v_function_1.png + :target: ../auto_examples/earth/plot_v_function.html + :align: center + :scale: 75% + + +.. topic:: Bibliography: + + 1. Friedman, J. (1991). Multivariate adaptive regression splines. The annals of statistics, + 19(1), 1–67. http://www.jstor.org/stable/10.2307/2241837 + 2. Stephen Milborrow. Derived from mda:mars by Trevor Hastie and Rob Tibshirani. + (2012). earth: Multivariate Adaptive Regression Spline Models. R package + version 3.2-3. + 3. Friedman, J. (1993). Fast MARS. Stanford University Department of Statistics, Technical Report No 110. + http://statistics.stanford.edu/~ckirby/techreports/LCS/LCS%20110.pdf + 4. Friedman, J. (1991). Estimating functions of mixed ordinal and categorical variables using adaptive splines. + Stanford University Department of Statistics, Technical Report No 108. + http://statistics.stanford.edu/~ckirby/techreports/LCS/LCS%20108.pdf + 5. Stewart, G.W. Matrix Algorithms, Volume 1: Basic Decompositions. (1998). Society for Industrial and Applied + Mathematics. + 6. Bjorck, A. Numerical Methods for Least Squares Problems. (1996). Society for Industrial and Applied + Mathematics. + 7. Hastie, T., Tibshirani, R., & Friedman, J. The Elements of Statistical Learning (2nd Edition). (2009). + Springer Series in Statistics + 8. Golub, G., & Van Loan, C. Matrix Computations (3rd Edition). (1996). Johns Hopkins University Press. + + + References 7, 2, 1, 3, and 4 contain discussions likely to be useful to users. References 1, 2, 6, 5, + 8, 3, and 4 are useful in understanding the implementation. diff --git a/doc/modules/earth_bibliography.bib b/doc/modules/earth_bibliography.bib new file mode 100644 index 0000000000000..70da708722b66 --- /dev/null +++ b/doc/modules/earth_bibliography.bib @@ -0,0 +1,63 @@ +@book{Bjorck1996, +address = {Philadelphia}, +author = {Bjorck, Ake}, +isbn = {0898713609}, +publisher = {Society for Industrial and Applied Mathematics}, +title = {{Numerical Methods for Least Squares Problems}}, +year = {1996} +} +@techreport{Friedman1993, +author = {Friedman, Jerome H.}, +institution = {Stanford University Department of Statistics}, +title = {{Technical Report No. 110: Fast MARS.}}, +url = {http://scholar.google.com/scholar?hl=en\&btnG=Search\&q=intitle:Fast+MARS\#0}, +year = {1993} +} +@techreport{Friedman1991a, +author = {Friedman, JH}, +institution = {Stanford University Department of Statistics}, +publisher = {Stanford University Department of Statistics}, +title = {{Technical Report No. 108: Estimating functions of mixed ordinal and categorical variables using adaptive splines}}, +url = {http://scholar.google.com/scholar?hl=en\&btnG=Search\&q=intitle:Estimating+functions+of+mixed+ordinal+and+categorical+variables+using+adaptive+splines\#0}, +year = {1991} +} +@article{Friedman1991, +author = {Friedman, JH}, +journal = {The annals of statistics}, +number = {1}, +pages = {1--67}, +title = {{Multivariate adaptive regression splines}}, +url = {http://www.jstor.org/stable/10.2307/2241837}, +volume = {19}, +year = {1991} +} +@book{Golub1996, +author = {Golub, Gene and {Van Loan}, Charles}, +edition = {3}, +publisher = {Johns Hopkins University Press}, +title = {{Matrix Computations}}, +year = {1996} +} +@book{Hastie2009, +address = {New York}, +author = {Hastie, Trevor and Tibshirani, Robert and Friedman, Jerome}, +edition = {2}, +publisher = {Springer Science+Business Media}, +title = {{Elements of Statistical Learning: Data Mining, Inference, and Prediction}}, +year = {2009} +} +@book{Stewart1998, +address = {Philadelphia}, +author = {Stewart, G. W.}, +isbn = {0898714141}, +publisher = {Society for Industrial and Applied Mathematics}, +title = {{Matrix Algorithms Volume 1: Basic Decompositions}}, +year = {1998} +} +@misc{Millborrow2012, +author = {Millborrow, Stephen}, +publisher = {CRAN}, +title = {{earth: Multivariate Adaptive Regression Spline Models}}, +url = {http://cran.r-project.org/web/packages/earth/index.html}, +year = {2012} +} diff --git a/doc/supervised_learning.rst b/doc/supervised_learning.rst index 247bd0587a6ca..a3af4dfbbeab1 100644 --- a/doc/supervised_learning.rst +++ b/doc/supervised_learning.rst @@ -21,3 +21,4 @@ Supervised learning modules/label_propagation.rst modules/lda_qda.rst modules/isotonic.rst + modules/earth.rst diff --git a/examples/earth/README.txt b/examples/earth/README.txt new file mode 100644 index 0000000000000..6633b22fec6d5 --- /dev/null +++ b/examples/earth/README.txt @@ -0,0 +1,6 @@ +.. _earth_examples: + +Earth examples +---------------- + +Examples concerning the :mod:`sklearn.earth` package. diff --git a/examples/earth/plot_sine_wave.py b/examples/earth/plot_sine_wave.py new file mode 100644 index 0000000000000..c2e7d3c49c144 --- /dev/null +++ b/examples/earth/plot_sine_wave.py @@ -0,0 +1,39 @@ +''' +============================================== +Fitting an EarthRegressor model to a sine wave +============================================== + + +In this example, a simple sine model is used to generate an artificial data set. An :class:`EarthRegressor` model +is then fitted to that data set and the resulting predictions are plotted against the original data. + +''' +print(__doc__) + +import numpy as np +import pylab as pl +from sklearn.earth import EarthRegressor + +# Create some fake data +np.random.seed(2) +m = 10000 +n = 10 +X = 80 * np.random.uniform(size=(m, n)) - 40 +y = 100 * \ + np.abs(np.sin((X[:, 6]) / 10) - 4.0) + \ + 20 * np.random.normal(size=m) + +# Fit an EarthRegressor model +model = EarthRegressor(max_degree=3, minspan_alpha=.5) +model.fit(X, y) + +# Print the model +print(model.trace()) +print(model.summary()) + +# Plot the model +pl.figure() +y_hat = model.predict(X) +pl.plot(X[:, 6], y, 'r.') +pl.plot(X[:, 6], y_hat, 'b.') +pl.show() diff --git a/examples/earth/plot_v_function.py b/examples/earth/plot_v_function.py new file mode 100644 index 0000000000000..f040e59a376ce --- /dev/null +++ b/examples/earth/plot_v_function.py @@ -0,0 +1,37 @@ +''' +====================================================== +Fitting an EarthRegressor model to a v-shaped function +====================================================== + + +In this example, a simple piecewise linear model is used to generate an artificial data set. An :class:`Earth` model +is then fitted to that data set and the resulting predictions are plotted against the original data. + +''' +print(__doc__) + +import numpy as np +from sklearn.earth import EarthRegressor +import pylab as pl + +# Create some fake data +np.random.seed(2) +m = 1000 +n = 10 +X = 80 * np.random.uniform(size=(m, n)) - 40 +y = np.abs(X[:, 6] - 4.0) + 5 * np.random.normal(size=m) + +# Fit an EarthRegressor model +model = EarthRegressor(max_degree=1) +model.fit(X, y) + +# Print the model +print(model.trace()) +print(model.summary()) + +# Plot the model +y_hat = model.predict(X) +pl.figure() +pl.plot(X[:, 6], y, 'r.') +pl.plot(X[:, 6], y_hat, 'b.') +pl.show() diff --git a/examples/plot_classifier_comparison.py b/examples/plot_classifier_comparison.py index bc6ddcac0cc41..40ae265126506 100644 --- a/examples/plot_classifier_comparison.py +++ b/examples/plot_classifier_comparison.py @@ -26,6 +26,7 @@ # Code source: Gael Varoqueux # Andreas Mueller # Modified for Documentation merge by Jaques Grobler +# Modified to include EarthRegressor by Jason Rudy # License: BSD 3 clause import numpy as np @@ -41,11 +42,14 @@ from sklearn.naive_bayes import GaussianNB from sklearn.lda import LDA from sklearn.qda import QDA +from sklearn.earth import EarthRegressor +from sklearn.linear_model.logistic import LogisticRegression +from sklearn.pipeline import Pipeline h = .02 # step size in the mesh names = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Decision Tree", - "Random Forest", "AdaBoost", "Naive Bayes", "LDA", "QDA"] + "Random Forest", "AdaBoost", "Naive Bayes", "LDA", "QDA", "Earth"] classifiers = [ KNeighborsClassifier(3), SVC(kernel="linear", C=0.025), @@ -55,7 +59,9 @@ AdaBoostClassifier(), GaussianNB(), LDA(), - QDA()] + QDA(), + Pipeline([('earth', EarthRegressor(max_degree=3, penalty=1.5)), + ('logistic', LogisticRegression())])] X, y = make_classification(n_features=2, n_redundant=0, n_informative=2, random_state=1, n_clusters_per_class=1) @@ -104,10 +110,10 @@ # Plot the decision boundary. For that, we will assign a color to each # point in the mesh [x_min, m_max]x[y_min, y_max]. - if hasattr(clf, "decision_function"): - Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()]) - else: + try: Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1] + except NotImplementedError: + Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()]) # Put the result into a color plot Z = Z.reshape(xx.shape) diff --git a/sklearn/earth/__init__.py b/sklearn/earth/__init__.py new file mode 100644 index 0000000000000..c56eba674fd47 --- /dev/null +++ b/sklearn/earth/__init__.py @@ -0,0 +1,8 @@ +""" +The :mod:`sklearn.earth` module contains the the Earth class for multivariate +adaptive regression splines. +""" + +from .earth import EarthRegressor + +__all__ = ['EarthRegressor'] diff --git a/sklearn/earth/_basis.c b/sklearn/earth/_basis.c new file mode 100644 index 0000000000000..04d8ba4f41787 --- /dev/null +++ b/sklearn/earth/_basis.c @@ -0,0 +1,21024 @@ +/* Generated by Cython 0.19.2 on Sat Nov 30 16:32:13 2013 */ + +#define PY_SSIZE_T_CLEAN +#ifndef CYTHON_USE_PYLONG_INTERNALS +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 0 +#else +#include "pyconfig.h" +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 1 +#else +#define CYTHON_USE_PYLONG_INTERNALS 0 +#endif +#endif +#endif +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02040000 + #error Cython requires Python 2.4+. +#else +#include /* For offsetof */ +#ifndef offsetof +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION +#define CYTHON_COMPILING_IN_PYPY 1 +#define CYTHON_COMPILING_IN_CPYTHON 0 +#else +#define CYTHON_COMPILING_IN_PYPY 0 +#define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if PY_VERSION_HEX < 0x02050000 + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ + (PyErr_Format(PyExc_TypeError, \ + "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ + (PyObject*)0)) + #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ + !PyComplex_Check(o)) + #define PyIndex_Check __Pyx_PyIndex_Check + #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) + #define __PYX_BUILD_PY_SSIZE_T "i" +#else + #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" + #define __Pyx_PyIndex_Check PyIndex_Check +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) + #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) + #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + #define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + #define PyType_Modified(t) + typedef struct { + void *buf; + PyObject *obj; + Py_ssize_t len; + Py_ssize_t itemsize; + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; + } Py_buffer; + #define PyBUF_SIMPLE 0 + #define PyBUF_WRITABLE 0x0001 + #define PyBUF_FORMAT 0x0004 + #define PyBUF_ND 0x0008 + #define PyBUF_STRIDES (0x0010 | PyBUF_ND) + #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) + #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) + #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) + #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) + #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) + typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); + typedef void (*releasebufferproc)(PyObject *, Py_buffer *); +#endif +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif +#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 + #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") +#endif +#if PY_MAJOR_VERSION >= 3 + #define Py_TPFLAGS_CHECKTYPES 0 + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_TPFLAGS_HAVE_VERSION_TAG 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PyBytesObject PyStringObject + #define PyBytes_Type PyString_Type + #define PyBytes_Check PyString_Check + #define PyBytes_CheckExact PyString_CheckExact + #define PyBytes_FromString PyString_FromString + #define PyBytes_FromStringAndSize PyString_FromStringAndSize + #define PyBytes_FromFormat PyString_FromFormat + #define PyBytes_DecodeEscape PyString_DecodeEscape + #define PyBytes_AsString PyString_AsString + #define PyBytes_AsStringAndSize PyString_AsStringAndSize + #define PyBytes_Size PyString_Size + #define PyBytes_AS_STRING PyString_AS_STRING + #define PyBytes_GET_SIZE PyString_GET_SIZE + #define PyBytes_Repr PyString_Repr + #define PyBytes_Concat PyString_Concat + #define PyBytes_ConcatAndDel PyString_ConcatAndDel +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ + PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) + #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) + #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) + #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) +#else + #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) + #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) +#else + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_NAMESTR(n) ((char *)(n)) + #define __Pyx_DOCSTR(n) ((char *)(n)) +#else + #define __Pyx_NAMESTR(n) (n) + #define __Pyx_DOCSTR(n) (n) +#endif +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + a quiet NaN. */ + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif + + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) +#define _USE_MATH_DEFINES +#endif +#include +#define __PYX_HAVE__sklearn__earth___basis +#define __PYX_HAVE_API__sklearn__earth___basis +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#include "math.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) +#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) +#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return u_end - u - 1; +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + const char* default_encoding_c = PyBytes_AS_STRING(default_encoding); + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (ascii_chars_u == NULL) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + } + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + default_encoding_c = PyBytes_AS_STRING(default_encoding); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(sys); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +#ifdef __GNUC__ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ +#else /* __GNUC__ */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "_basis.pyx", + "_basis.pxd", + "numpy.pxd", + "type.pxd", +}; +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; /* for error messages only */ + struct __Pyx_StructField_* fields; + size_t size; /* sizeof(type) */ + size_t arraysize[8]; /* length of array in each dimension */ + int ndim; + char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */ + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "numpy.pxd":723 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "numpy.pxd":724 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "numpy.pxd":725 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "numpy.pxd":726 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "numpy.pxd":730 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "numpy.pxd":731 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "numpy.pxd":732 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "numpy.pxd":733 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "numpy.pxd":737 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "numpy.pxd":738 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "numpy.pxd":747 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "numpy.pxd":748 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "numpy.pxd":749 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "numpy.pxd":751 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "numpy.pxd":752 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "numpy.pxd":753 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "numpy.pxd":755 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "numpy.pxd":756 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "numpy.pxd":758 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "numpy.pxd":759 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "numpy.pxd":760 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "_util.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_5_util_FLOAT_t; + +/* "_util.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_5_util_INT_t; + +/* "_util.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_5_util_INDEX_t; + +/* "_util.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef FLOAT_t log2(FLOAT_t x) + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_5_util_BOOL_t; + +/* "sklearn/earth/_basis.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_6_basis_FLOAT_t; + +/* "sklearn/earth/_basis.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_6_basis_INT_t; + +/* "sklearn/earth/_basis.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_6_basis_INDEX_t; + +/* "sklearn/earth/_basis.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef class BasisFunction: + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_6_basis_BOOL_t; +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis; +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction; +struct __pyx_obj_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction; +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction; +struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter; +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction; +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction; + +/* "numpy.pxd":762 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "numpy.pxd":763 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "numpy.pxd":764 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "numpy.pxd":766 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply; + +/* "sklearn/earth/_basis.pxd":45 + * cpdef INDEX_t degree(BasisFunction self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace) + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "sklearn/earth/_basis.pxd":62 + * cpdef BasisFunction get_parent(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "sklearn/earth/_basis.pxd":86 + * cpdef INDEX_t get_knot_idx(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cdef class LinearBasisFunction(BasisFunction): + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "sklearn/earth/_basis.pxd":98 + * cpdef INDEX_t get_variable(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "sklearn/earth/_basis.pxd":101 + * + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A wrapper that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtab; + PyObject *order; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t num_variables; +}; + + +/* "sklearn/earth/_basis.pxd":7 + * ctypedef cnp.uint8_t BOOL_t + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + * + */ +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtab; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *parent; + PyObject *child_map; + PyObject *children; + int pruned; + int prunable; + int splittable; +}; + + +/* "sklearn/earth/_basis.pyx":282 + * return result + * + * cdef class PicklePlaceHolderBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * '''This is a place holder for unpickling the basis function tree.''' + * + */ +struct __pyx_obj_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; +}; + + +/* "sklearn/earth/_basis.pxd":50 + * + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(ConstantBasisFunction self) + */ +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; +}; + + +/* "sklearn/earth/_basis.pyx":513 + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + * def piter(Basis self): # <<<<<<<<<<<<<< + * for bf in self.order: + * if not bf.is_pruned(): + */ +struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter { + PyObject_HEAD + PyObject *__pyx_v_bf; + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self; + PyObject *__pyx_t_0; + Py_ssize_t __pyx_t_1; +}; + + +/* "sklearn/earth/_basis.pxd":65 + * + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef FLOAT_t knot + * cdef INDEX_t knot_idx + */ +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t knot; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t knot_idx; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + int reverse; + PyObject *label; +}; + + +/* "sklearn/earth/_basis.pxd":88 + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef str label + */ +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + PyObject *label; +}; + + + +/* "sklearn/earth/_basis.pyx":13 + * import numpy as np + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * + * def __cinit__(BasisFunction self): + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction { + int (*has_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_prunable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_pruned)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_unsplittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*get_children)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *); + PyObject *(*_set_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*_add_child)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*prune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*unprune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*degree)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*apply)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args); + PyArrayObject *(*valid_knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int, int, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + + +/* "sklearn/earth/_basis.pyx":431 + * b[i] *= tmp + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * #@DuplicatedSignature + * def __init__(self, BasisFunction parent, INDEX_t variable, label=None): + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction; + + +/* "sklearn/earth/_basis.pyx":331 + * return '(Intercept)' + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * #@DuplicatedSignature + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*get_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + int (*get_reverse)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_knot_idx)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction; + + +/* "sklearn/earth/_basis.pyx":287 + * pickle_place_holder = PicklePlaceHolderBasisFunction() + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * def __init__(self): # @DuplicatedSignature + * self.prunable = False + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction; + + +/* "sklearn/earth/_basis.pyx":484 + * b[i] *= X[i, self.variable] + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A container that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis { + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_root)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + PyObject *(*append)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*plen)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*weighted_transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtabptr_7sklearn_5earth_6_basis_Basis; + + +/* "sklearn/earth/_basis.pyx":282 + * return result + * + * cdef class PicklePlaceHolderBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * '''This is a place holder for unpickling the basis function tree.''' + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction; +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + +static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +static CYTHON_INLINE int __Pyx_PyDict_Contains(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) { + PyObject *method, *result = NULL; + if (unlikely(!args)) return NULL; + method = __Pyx_PyObject_GetAttrStr(obj, method_name); + if (unlikely(!method)) goto bad; + result = PyObject_Call(method, args, NULL); + Py_DECREF(method); +bad: + Py_DECREF(args); + return result; +} +#define __Pyx_PyObject_CallMethod3(obj, name, arg1, arg2, arg3) \ + __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(3, arg1, arg2, arg3)) +#define __Pyx_PyObject_CallMethod2(obj, name, arg1, arg2) \ + __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(2, arg1, arg2)) +#define __Pyx_PyObject_CallMethod1(obj, name, arg1) \ + __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(1, arg1)) +#define __Pyx_PyObject_CallMethod0(obj, name) \ + __Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF(__pyx_empty_tuple), __pyx_empty_tuple)) + +static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x); /*proto*/ + +#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +#define __Pyx_SetItemInt(o, i, v, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_SetItemInt_Fast(o, i, v, is_list, wraparound, boundscheck) : \ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v)) +static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck); + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ + +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/ + +static void __Pyx_RaiseBufferFallbackError(void); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ + +#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +#include + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong); + +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; +static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject *); + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); + +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); + +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); + +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); + +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); + +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); + +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); + +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +#define __Pyx_Generator_USED +#include +#include +typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *); +typedef struct { + PyObject_HEAD + __pyx_generator_body_t body; + PyObject *closure; + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; + PyObject *gi_weakreflist; + PyObject *classobj; + PyObject *yieldfrom; + int resume_label; + char is_running; // using T_BOOL for property below requires char value +} __pyx_GeneratorObject; +static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, + PyObject *closure); +static int __pyx_Generator_init(void); +static int __Pyx_Generator_clear(PyObject* self); +#if 1 || PY_VERSION_HEX < 0x030300B0 +static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); +#else +#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue) +#endif + +static int __Pyx_check_binary_version(void); + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/ + +typedef struct { + int code_line; + PyCodeObject* code_object; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'sklearn.earth._util' */ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t (*__pyx_f_7sklearn_5earth_5_util_log2)(__pyx_t_7sklearn_5earth_5_util_FLOAT_t); /*proto*/ +static PyObject *(*__pyx_f_7sklearn_5earth_5_util_apply_weights_2d)(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ + +/* Module declarations from 'libc.math' */ + +/* Module declarations from 'sklearn.earth._basis' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_Basis = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis___pyx_scope_struct__piter = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = 0; +static __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_7sklearn_5earth_6_basis_ZERO_TOL; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t = { "FLOAT_t", NULL, sizeof(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t), { 0 }, 0, 'R', 0, 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_INT_t = { "INT_t", NULL, sizeof(__pyx_t_7sklearn_5earth_6_basis_INT_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_7sklearn_5earth_6_basis_INT_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_7sklearn_5earth_6_basis_INT_t), 0 }; +#define __Pyx_MODULE_NAME "sklearn.earth._basis" +int __pyx_module_is_main_sklearn__earth___basis = 0; + +/* Implementation of 'sklearn.earth._basis' */ +static PyObject *__pyx_builtin_NotImplemented; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_NotImplementedError; +static PyObject *__pyx_builtin_super; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static int __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction___cinit__(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_4_get_root(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_6_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_8_get_parent_state(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_10_set_parent_state(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_12__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_14_eq(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyObject *__pyx_v_other); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_16__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_18has_knot(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_20is_prunable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_22is_pruned(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_24is_splittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_26make_splittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_28make_unsplittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_30_set_parent(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_32_add_child(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_child); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_34get_parent(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_36prune(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_38unprune(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_40knots(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_42degree(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_44apply(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_46valid_knots(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_variable, int __pyx_v_variable_idx, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_check_every, int __pyx_v_endspan, int __pyx_v_minspan, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_minspan_alpha, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n, PyArrayObject *__pyx_v_workspace); /* proto */ +static int __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction___init__(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_2_get_root(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_4_get_parent_state(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_6_set_parent_state(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_8degree(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_10translate(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_ConstantBasisFunctionself, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_v_recurse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_12scale(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_ConstantBasisFunctionself, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_14_set_parent(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_16get_parent(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_18apply(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_20__str__(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction___init__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_knot, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_knot_idx, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable, int __pyx_v_reverse, PyObject *__pyx_v_label); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_4_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_6__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_8has_knot(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_10translate(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_v_recurse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_12scale(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_14__str__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_16get_variable(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_18get_knot(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_20get_reverse(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_22get_knot_idx(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_24apply(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse); /* proto */ +static int __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction___init__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable, PyObject *__pyx_v_label); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_4_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_6__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_8translate(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_LinearBasisFunctionself, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_v_recurse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_10scale(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_12__str__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_14get_variable(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_16apply(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse); /* proto */ +static int __pyx_pf_7sklearn_5earth_6_basis_5Basis___init__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyObject *__pyx_v_num_variables); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_4_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_6__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_8__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_10_eq(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyObject *__pyx_v_other); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_12piter(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_15__str__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_17translate(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_19scale(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, PyArrayObject *__pyx_v_beta); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_21get_root(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_23append(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_basis_function); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_25__iter__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static Py_ssize_t __pyx_pf_7sklearn_5earth_6_basis_5Basis_27__len__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_29get(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_31__getitem__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_33plen(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_35transform(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_B); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_37weighted_transform(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_13num_variables___get__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_Basis(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_BasisFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_ConstantBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis___pyx_scope_struct__piter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_HingeBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_LinearBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static char __pyx_k_1[] = "(Intercept)"; +static char __pyx_k_2[] = ""; +static char __pyx_k_3[] = "h(%s-%G)"; +static char __pyx_k_4[] = "h(%s+%G)"; +static char __pyx_k_5[] = "h(%G-%s)"; +static char __pyx_k_6[] = "*%s"; +static char __pyx_k_7[] = "*"; +static char __pyx_k_8[] = "\n"; +static char __pyx_k_10[] = "ndarray is not C contiguous"; +static char __pyx_k_12[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_14[] = "Non-native byte order not supported"; +static char __pyx_k_16[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_17[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_20[] = "Format string allocated too short."; +static char __pyx_k__B[] = "B"; +static char __pyx_k__H[] = "H"; +static char __pyx_k__I[] = "I"; +static char __pyx_k__L[] = "L"; +static char __pyx_k__O[] = "O"; +static char __pyx_k__Q[] = "Q"; +static char __pyx_k__X[] = "X"; +static char __pyx_k__b[] = "b"; +static char __pyx_k__d[] = "d"; +static char __pyx_k__f[] = "f"; +static char __pyx_k__g[] = "g"; +static char __pyx_k__h[] = "h"; +static char __pyx_k__i[] = "i"; +static char __pyx_k__l[] = "l"; +static char __pyx_k__n[] = "n"; +static char __pyx_k__q[] = "q"; +static char __pyx_k__x[] = "x"; +static char __pyx_k__Zd[] = "Zd"; +static char __pyx_k__Zf[] = "Zf"; +static char __pyx_k__Zg[] = "Zg"; +static char __pyx_k__np[] = "np"; +static char __pyx_k___eq[] = "_eq"; +static char __pyx_k__get[] = "get"; +static char __pyx_k__args[] = "args"; +static char __pyx_k__beta[] = "beta"; +static char __pyx_k__knot[] = "knot"; +static char __pyx_k__plen[] = "plen"; +static char __pyx_k__root[] = "root"; +static char __pyx_k__send[] = "send"; +static char __pyx_k__apply[] = "apply"; +static char __pyx_k__close[] = "close"; +static char __pyx_k__dtype[] = "dtype"; +static char __pyx_k__empty[] = "empty"; +static char __pyx_k__knots[] = "knots"; +static char __pyx_k__label[] = "label"; +static char __pyx_k__numpy[] = "numpy"; +static char __pyx_k__order[] = "order"; +static char __pyx_k__prune[] = "prune"; +static char __pyx_k__range[] = "range"; +static char __pyx_k__scale[] = "scale"; +static char __pyx_k__shape[] = "shape"; +static char __pyx_k__super[] = "super"; +static char __pyx_k__throw[] = "throw"; +static char __pyx_k__append[] = "append"; +static char __pyx_k__degree[] = "degree"; +static char __pyx_k__parent[] = "parent"; +static char __pyx_k__pruned[] = "pruned"; +static char __pyx_k__slopes[] = "slopes"; +static char __pyx_k__update[] = "update"; +static char __pyx_k__values[] = "values"; +static char __pyx_k____len__[] = "__len__"; +static char __pyx_k__endspan[] = "endspan"; +static char __pyx_k__minspan[] = "minspan"; +static char __pyx_k__recurse[] = "recurse"; +static char __pyx_k__reverse[] = "reverse"; +static char __pyx_k__unprune[] = "unprune"; +static char __pyx_k__weights[] = "weights"; +static char __pyx_k____iter__[] = "__iter__"; +static char __pyx_k____main__[] = "__main__"; +static char __pyx_k____test__[] = "__test__"; +static char __pyx_k__children[] = "children"; +static char __pyx_k__get_knot[] = "get_knot"; +static char __pyx_k__get_root[] = "get_root"; +static char __pyx_k__has_knot[] = "has_knot"; +static char __pyx_k__knot_idx[] = "knot_idx"; +static char __pyx_k__prunable[] = "prunable"; +static char __pyx_k__variable[] = "variable"; +static char __pyx_k____class__[] = "__class__"; +static char __pyx_k___get_root[] = "_get_root"; +static char __pyx_k___getstate[] = "_getstate"; +static char __pyx_k__child_map[] = "child_map"; +static char __pyx_k__is_pruned[] = "is_pruned"; +static char __pyx_k__transform[] = "transform"; +static char __pyx_k__translate[] = "translate"; +static char __pyx_k__workspace[] = "workspace"; +static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k____import__[] = "__import__"; +static char __pyx_k___add_child[] = "_add_child"; +static char __pyx_k__get_parent[] = "get_parent"; +static char __pyx_k__intercepts[] = "intercepts"; +static char __pyx_k__splittable[] = "splittable"; +static char __pyx_k___set_parent[] = "_set_parent"; +static char __pyx_k__check_every[] = "check_every"; +static char __pyx_k__get_reverse[] = "get_reverse"; +static char __pyx_k__is_prunable[] = "is_prunable"; +static char __pyx_k__valid_knots[] = "valid_knots"; +static char __pyx_k__RuntimeError[] = "RuntimeError"; +static char __pyx_k____setstate__[] = "__setstate__"; +static char __pyx_k__get_knot_idx[] = "get_knot_idx"; +static char __pyx_k__get_variable[] = "get_variable"; +static char __pyx_k__variable_idx[] = "variable_idx"; +static char __pyx_k__is_splittable[] = "is_splittable"; +static char __pyx_k__minspan_alpha[] = "minspan_alpha"; +static char __pyx_k__num_variables[] = "num_variables"; +static char __pyx_k__NotImplemented[] = "NotImplemented"; +static char __pyx_k____pyx_vtable__[] = "__pyx_vtable__"; +static char __pyx_k____pyx_getbuffer[] = "__pyx_getbuffer"; +static char __pyx_k__make_splittable[] = "make_splittable"; +static char __pyx_k___get_parent_state[] = "_get_parent_state"; +static char __pyx_k___set_parent_state[] = "_set_parent_state"; +static char __pyx_k__make_unsplittable[] = "make_unsplittable"; +static char __pyx_k__weighted_transform[] = "weighted_transform"; +static char __pyx_k__NotImplementedError[] = "NotImplementedError"; +static char __pyx_k____pyx_releasebuffer[] = "__pyx_releasebuffer"; +static char __pyx_k__pickle_place_holder[] = "pickle_place_holder"; +static PyObject *__pyx_kp_s_1; +static PyObject *__pyx_kp_u_10; +static PyObject *__pyx_kp_u_12; +static PyObject *__pyx_kp_u_14; +static PyObject *__pyx_kp_u_16; +static PyObject *__pyx_kp_u_17; +static PyObject *__pyx_kp_s_2; +static PyObject *__pyx_kp_u_20; +static PyObject *__pyx_kp_s_3; +static PyObject *__pyx_kp_s_4; +static PyObject *__pyx_kp_s_5; +static PyObject *__pyx_kp_s_6; +static PyObject *__pyx_kp_s_7; +static PyObject *__pyx_kp_s_8; +static PyObject *__pyx_n_s__B; +static PyObject *__pyx_n_s__NotImplemented; +static PyObject *__pyx_n_s__NotImplementedError; +static PyObject *__pyx_n_s__RuntimeError; +static PyObject *__pyx_n_s__ValueError; +static PyObject *__pyx_n_s__X; +static PyObject *__pyx_n_s____class__; +static PyObject *__pyx_n_s____import__; +static PyObject *__pyx_n_s____iter__; +static PyObject *__pyx_n_s____len__; +static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____pyx_getbuffer; +static PyObject *__pyx_n_s____pyx_releasebuffer; +static PyObject *__pyx_n_s____pyx_vtable__; +static PyObject *__pyx_n_s____setstate__; +static PyObject *__pyx_n_s____test__; +static PyObject *__pyx_n_s___add_child; +static PyObject *__pyx_n_s___eq; +static PyObject *__pyx_n_s___get_parent_state; +static PyObject *__pyx_n_s___get_root; +static PyObject *__pyx_n_s___getstate; +static PyObject *__pyx_n_s___set_parent; +static PyObject *__pyx_n_s___set_parent_state; +static PyObject *__pyx_n_s__append; +static PyObject *__pyx_n_s__apply; +static PyObject *__pyx_n_s__args; +static PyObject *__pyx_n_s__b; +static PyObject *__pyx_n_s__beta; +static PyObject *__pyx_n_s__check_every; +static PyObject *__pyx_n_s__child_map; +static PyObject *__pyx_n_s__children; +static PyObject *__pyx_n_s__close; +static PyObject *__pyx_n_s__degree; +static PyObject *__pyx_n_s__dtype; +static PyObject *__pyx_n_s__empty; +static PyObject *__pyx_n_s__endspan; +static PyObject *__pyx_n_s__get; +static PyObject *__pyx_n_s__get_knot; +static PyObject *__pyx_n_s__get_knot_idx; +static PyObject *__pyx_n_s__get_parent; +static PyObject *__pyx_n_s__get_reverse; +static PyObject *__pyx_n_s__get_root; +static PyObject *__pyx_n_s__get_variable; +static PyObject *__pyx_n_s__has_knot; +static PyObject *__pyx_n_s__intercepts; +static PyObject *__pyx_n_s__is_prunable; +static PyObject *__pyx_n_s__is_pruned; +static PyObject *__pyx_n_s__is_splittable; +static PyObject *__pyx_n_s__knot; +static PyObject *__pyx_n_s__knot_idx; +static PyObject *__pyx_n_s__knots; +static PyObject *__pyx_n_s__label; +static PyObject *__pyx_n_s__make_splittable; +static PyObject *__pyx_n_s__make_unsplittable; +static PyObject *__pyx_n_s__minspan; +static PyObject *__pyx_n_s__minspan_alpha; +static PyObject *__pyx_n_s__n; +static PyObject *__pyx_n_s__np; +static PyObject *__pyx_n_s__num_variables; +static PyObject *__pyx_n_s__numpy; +static PyObject *__pyx_n_s__order; +static PyObject *__pyx_n_s__parent; +static PyObject *__pyx_n_s__pickle_place_holder; +static PyObject *__pyx_n_s__plen; +static PyObject *__pyx_n_s__prunable; +static PyObject *__pyx_n_s__prune; +static PyObject *__pyx_n_s__pruned; +static PyObject *__pyx_n_s__range; +static PyObject *__pyx_n_s__recurse; +static PyObject *__pyx_n_s__reverse; +static PyObject *__pyx_n_s__root; +static PyObject *__pyx_n_s__scale; +static PyObject *__pyx_n_s__send; +static PyObject *__pyx_n_s__shape; +static PyObject *__pyx_n_s__slopes; +static PyObject *__pyx_n_s__splittable; +static PyObject *__pyx_n_s__super; +static PyObject *__pyx_n_s__throw; +static PyObject *__pyx_n_s__transform; +static PyObject *__pyx_n_s__translate; +static PyObject *__pyx_n_s__unprune; +static PyObject *__pyx_n_s__update; +static PyObject *__pyx_n_s__valid_knots; +static PyObject *__pyx_n_s__values; +static PyObject *__pyx_n_s__variable; +static PyObject *__pyx_n_s__variable_idx; +static PyObject *__pyx_n_s__weighted_transform; +static PyObject *__pyx_n_s__weights; +static PyObject *__pyx_n_s__workspace; +static PyObject *__pyx_n_s__x; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_3; +static PyObject *__pyx_int_15; +static PyObject *__pyx_k_slice_9; +static PyObject *__pyx_k_tuple_11; +static PyObject *__pyx_k_tuple_13; +static PyObject *__pyx_k_tuple_15; +static PyObject *__pyx_k_tuple_18; +static PyObject *__pyx_k_tuple_19; +static PyObject *__pyx_k_tuple_21; + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction___cinit__(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":15 + * cdef class BasisFunction: + * + * def __cinit__(BasisFunction self): # <<<<<<<<<<<<<< + * self.pruned = False + * self.children = [] + */ + +static int __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction___cinit__(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "sklearn/earth/_basis.pyx":16 + * + * def __cinit__(BasisFunction self): + * self.pruned = False # <<<<<<<<<<<<<< + * self.children = [] + * self.prunable = True + */ + __pyx_v_self->pruned = 0; + + /* "sklearn/earth/_basis.pyx":17 + * def __cinit__(BasisFunction self): + * self.pruned = False + * self.children = [] # <<<<<<<<<<<<<< + * self.prunable = True + * self.child_map = {} + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __Pyx_GOTREF(__pyx_v_self->children); + __Pyx_DECREF(((PyObject *)__pyx_v_self->children)); + __pyx_v_self->children = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":18 + * self.pruned = False + * self.children = [] + * self.prunable = True # <<<<<<<<<<<<<< + * self.child_map = {} + * self.splittable = True + */ + __pyx_v_self->prunable = 1; + + /* "sklearn/earth/_basis.pyx":19 + * self.children = [] + * self.prunable = True + * self.child_map = {} # <<<<<<<<<<<<<< + * self.splittable = True + * + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __Pyx_GOTREF(__pyx_v_self->child_map); + __Pyx_DECREF(((PyObject *)__pyx_v_self->child_map)); + __pyx_v_self->child_map = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":20 + * self.prunable = True + * self.child_map = {} + * self.splittable = True # <<<<<<<<<<<<<< + * + * def __reduce__(self): + */ + __pyx_v_self->splittable = 1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_2__reduce__(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":22 + * self.splittable = True + * + * def __reduce__(self): # <<<<<<<<<<<<<< + * return (self.__class__, (), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_basis.pyx":23 + * + * def __reduce__(self): + * return (self.__class__, (), self._getstate()) # <<<<<<<<<<<<<< + * + * def _get_root(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_empty_tuple)); + __Pyx_GIVEREF(((PyObject *)__pyx_empty_tuple)); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_5_get_root(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_5_get_root(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_get_root (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_4_get_root(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":25 + * return (self.__class__, (), self._getstate()) + * + * def _get_root(self): # <<<<<<<<<<<<<< + * return self.parent._get_root() + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_4_get_root(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_root", 0); + + /* "sklearn/earth/_basis.pyx":26 + * + * def _get_root(self): + * return self.parent._get_root() # <<<<<<<<<<<<<< + * + * def _getstate(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->parent), __pyx_n_s___get_root); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._get_root", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_7_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_7_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_6_getstate(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":28 + * return self.parent._get_root() + * + * def _getstate(self): # <<<<<<<<<<<<<< + * result = {'pruned': self.pruned, + * 'children': self.children, + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_6_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_basis.pyx":29 + * + * def _getstate(self): + * result = {'pruned': self.pruned, # <<<<<<<<<<<<<< + * 'children': self.children, + * 'prunable': self.prunable, + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->pruned); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pruned), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":30 + * def _getstate(self): + * result = {'pruned': self.pruned, + * 'children': self.children, # <<<<<<<<<<<<<< + * 'prunable': self.prunable, + * 'child_map': self.child_map, + */ + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__children), ((PyObject *)__pyx_v_self->children)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":31 + * result = {'pruned': self.pruned, + * 'children': self.children, + * 'prunable': self.prunable, # <<<<<<<<<<<<<< + * 'child_map': self.child_map, + * 'splittable': self.splittable} + */ + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->prunable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prunable), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":32 + * 'children': self.children, + * 'prunable': self.prunable, + * 'child_map': self.child_map, # <<<<<<<<<<<<<< + * 'splittable': self.splittable} + * result.update(self._get_parent_state()) + */ + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__child_map), ((PyObject *)__pyx_v_self->child_map)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":33 + * 'prunable': self.prunable, + * 'child_map': self.child_map, + * 'splittable': self.splittable} # <<<<<<<<<<<<<< + * result.update(self._get_parent_state()) + * return result + */ + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->splittable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__splittable), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_result = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":34 + * 'child_map': self.child_map, + * 'splittable': self.splittable} + * result.update(self._get_parent_state()) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_result), __pyx_n_s__update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___get_parent_state); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":35 + * 'splittable': self.splittable} + * result.update(self._get_parent_state()) + * return result # <<<<<<<<<<<<<< + * + * def _get_parent_state(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_9_get_parent_state(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_9_get_parent_state(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_get_parent_state (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_8_get_parent_state(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":37 + * return result + * + * def _get_parent_state(self): # <<<<<<<<<<<<<< + * return {'parent': self.parent} + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_8_get_parent_state(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_parent_state", 0); + + /* "sklearn/earth/_basis.pyx":38 + * + * def _get_parent_state(self): + * return {'parent': self.parent} # <<<<<<<<<<<<<< + * + * def _set_parent_state(self, state): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__parent), ((PyObject *)__pyx_v_self->parent)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._get_parent_state", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_11_set_parent_state(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_11_set_parent_state(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_set_parent_state (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_10_set_parent_state(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((PyObject *)__pyx_v_state)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":40 + * return {'parent': self.parent} + * + * def _set_parent_state(self, state): # <<<<<<<<<<<<<< + * self.parent = state['parent'] + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_10_set_parent_state(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_set_parent_state", 0); + + /* "sklearn/earth/_basis.pyx":41 + * + * def _set_parent_state(self, state): + * self.parent = state['parent'] # <<<<<<<<<<<<<< + * + * def __setstate__(self, state): + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__parent)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->parent); + __Pyx_DECREF(((PyObject *)__pyx_v_self->parent)); + __pyx_v_self->parent = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_1); + __pyx_t_1 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._set_parent_state", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_13__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_13__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_12__setstate__(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((PyObject *)__pyx_v_state)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":43 + * self.parent = state['parent'] + * + * def __setstate__(self, state): # <<<<<<<<<<<<<< + * self.pruned = state['pruned'] + * self.children = state['children'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_12__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_basis.pyx":44 + * + * def __setstate__(self, state): + * self.pruned = state['pruned'] # <<<<<<<<<<<<<< + * self.children = state['children'] + * self.prunable = state['prunable'] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__pruned)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->pruned = __pyx_t_2; + + /* "sklearn/earth/_basis.pyx":45 + * def __setstate__(self, state): + * self.pruned = state['pruned'] + * self.children = state['children'] # <<<<<<<<<<<<<< + * self.prunable = state['prunable'] + * self.child_map = state['child_map'] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__children)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->children); + __Pyx_DECREF(((PyObject *)__pyx_v_self->children)); + __pyx_v_self->children = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":46 + * self.pruned = state['pruned'] + * self.children = state['children'] + * self.prunable = state['prunable'] # <<<<<<<<<<<<<< + * self.child_map = state['child_map'] + * self.splittable = state['splittable'] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__prunable)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->prunable = __pyx_t_2; + + /* "sklearn/earth/_basis.pyx":47 + * self.children = state['children'] + * self.prunable = state['prunable'] + * self.child_map = state['child_map'] # <<<<<<<<<<<<<< + * self.splittable = state['splittable'] + * self._set_parent_state(state) + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__child_map)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected dict, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->child_map); + __Pyx_DECREF(((PyObject *)__pyx_v_self->child_map)); + __pyx_v_self->child_map = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":48 + * self.prunable = state['prunable'] + * self.child_map = state['child_map'] + * self.splittable = state['splittable'] # <<<<<<<<<<<<<< + * self._set_parent_state(state) + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__splittable)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->splittable = __pyx_t_2; + + /* "sklearn/earth/_basis.pyx":49 + * self.child_map = state['child_map'] + * self.splittable = state['splittable'] + * self._set_parent_state(state) # <<<<<<<<<<<<<< + * + * def _eq(self, other): + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___set_parent_state); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_state); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_state); + __Pyx_GIVEREF(__pyx_v_state); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_15_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_15_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_eq (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_14_eq(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((PyObject *)__pyx_v_other)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":51 + * self._set_parent_state(state) + * + * def _eq(self, other): # <<<<<<<<<<<<<< + * if self.__class__ is not other.__class__: + * return False + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_14_eq(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_v_self_state = NULL; + PyObject *__pyx_v_other_state = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_eq", 0); + + /* "sklearn/earth/_basis.pyx":52 + * + * def _eq(self, other): + * if self.__class__ is not other.__class__: # <<<<<<<<<<<<<< + * return False + * self_state = self._getstate() + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s____class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = (__pyx_t_1 != __pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = (__pyx_t_3 != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_basis.pyx":53 + * def _eq(self, other): + * if self.__class__ is not other.__class__: + * return False # <<<<<<<<<<<<<< + * self_state = self._getstate() + * other_state = other._getstate() + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_basis.pyx":54 + * if self.__class__ is not other.__class__: + * return False + * self_state = self._getstate() # <<<<<<<<<<<<<< + * other_state = other._getstate() + * del self_state['children'] + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_self_state = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":55 + * return False + * self_state = self._getstate() + * other_state = other._getstate() # <<<<<<<<<<<<<< + * del self_state['children'] + * del self_state['child_map'] + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_other_state = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":56 + * self_state = self._getstate() + * other_state = other._getstate() + * del self_state['children'] # <<<<<<<<<<<<<< + * del self_state['child_map'] + * del other_state['children'] + */ + if (unlikely(!__pyx_v_self_state)) { __Pyx_RaiseUnboundLocalError("self_state"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (PyObject_DelItem(__pyx_v_self_state, ((PyObject *)__pyx_n_s__children)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":57 + * other_state = other._getstate() + * del self_state['children'] + * del self_state['child_map'] # <<<<<<<<<<<<<< + * del other_state['children'] + * del other_state['child_map'] + */ + if (unlikely(!__pyx_v_self_state)) { __Pyx_RaiseUnboundLocalError("self_state"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (PyObject_DelItem(__pyx_v_self_state, ((PyObject *)__pyx_n_s__child_map)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":58 + * del self_state['children'] + * del self_state['child_map'] + * del other_state['children'] # <<<<<<<<<<<<<< + * del other_state['child_map'] + * return self_state == other_state + */ + if (unlikely(!__pyx_v_other_state)) { __Pyx_RaiseUnboundLocalError("other_state"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (PyObject_DelItem(__pyx_v_other_state, ((PyObject *)__pyx_n_s__children)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":59 + * del self_state['child_map'] + * del other_state['children'] + * del other_state['child_map'] # <<<<<<<<<<<<<< + * return self_state == other_state + * + */ + if (unlikely(!__pyx_v_other_state)) { __Pyx_RaiseUnboundLocalError("other_state"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (PyObject_DelItem(__pyx_v_other_state, ((PyObject *)__pyx_n_s__child_map)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":60 + * del other_state['children'] + * del other_state['child_map'] + * return self_state == other_state # <<<<<<<<<<<<<< + * + * def __richcmp__(self, other, method): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyObject_RichCompare(__pyx_v_self_state, __pyx_v_other_state, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._eq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_self_state); + __Pyx_XDECREF(__pyx_v_other_state); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_17__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_17__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method) { + PyObject *__pyx_v_method = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); + __pyx_v_method = PyInt_FromLong(__pyx_arg_method); if (unlikely(!__pyx_v_method)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_GOTREF(__pyx_v_method); + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_16__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((PyObject *)__pyx_v_method)); + __Pyx_XDECREF(__pyx_v_method); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":62 + * return self_state == other_state + * + * def __richcmp__(self, other, method): # <<<<<<<<<<<<<< + * if method == 2: + * return self._eq(other) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_16__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__richcmp__", 0); + + /* "sklearn/earth/_basis.pyx":63 + * + * def __richcmp__(self, other, method): + * if method == 2: # <<<<<<<<<<<<<< + * return self._eq(other) + * elif method == 3: + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, __pyx_int_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_basis.pyx":64 + * def __richcmp__(self, other, method): + * if method == 2: + * return self._eq(other) # <<<<<<<<<<<<<< + * elif method == 3: + * return not self._eq(other) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + + /* "sklearn/earth/_basis.pyx":65 + * if method == 2: + * return self._eq(other) + * elif method == 3: # <<<<<<<<<<<<<< + * return not self._eq(other) + * else: + */ + __pyx_t_4 = PyObject_RichCompare(__pyx_v_method, __pyx_int_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_basis.pyx":66 + * return self._eq(other) + * elif method == 3: + * return not self._eq(other) # <<<<<<<<<<<<<< + * else: + * return NotImplemented + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":68 + * return not self._eq(other) + * else: + * return NotImplemented # <<<<<<<<<<<<<< + * + * cpdef bint has_knot(BasisFunction self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_builtin_NotImplemented); + __pyx_r = __pyx_builtin_NotImplemented; + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":70 + * return NotImplemented + * + * cpdef bint has_knot(BasisFunction self): # <<<<<<<<<<<<<< + * return False + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_19has_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_13BasisFunction_has_knot(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("has_knot", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__has_knot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_19has_knot)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":71 + * + * cpdef bint has_knot(BasisFunction self): + * return False # <<<<<<<<<<<<<< + * + * cpdef bint is_prunable(BasisFunction self): + */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.BasisFunction.has_knot", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_19has_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_19has_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("has_knot (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_18has_knot(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":70 + * return NotImplemented + * + * cpdef bint has_knot(BasisFunction self): # <<<<<<<<<<<<<< + * return False + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_18has_knot(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("has_knot", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->has_knot(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.has_knot", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":73 + * return False + * + * cpdef bint is_prunable(BasisFunction self): # <<<<<<<<<<<<<< + * return self.prunable + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_21is_prunable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_13BasisFunction_is_prunable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_prunable", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__is_prunable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_21is_prunable)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":74 + * + * cpdef bint is_prunable(BasisFunction self): + * return self.prunable # <<<<<<<<<<<<<< + * + * cpdef bint is_pruned(BasisFunction self): + */ + __pyx_r = __pyx_v_self->prunable; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.BasisFunction.is_prunable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_21is_prunable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_21is_prunable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_prunable (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_20is_prunable(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":73 + * return False + * + * cpdef bint is_prunable(BasisFunction self): # <<<<<<<<<<<<<< + * return self.prunable + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_20is_prunable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_prunable", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->is_prunable(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.is_prunable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":76 + * return self.prunable + * + * cpdef bint is_pruned(BasisFunction self): # <<<<<<<<<<<<<< + * return self.pruned + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_23is_pruned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_13BasisFunction_is_pruned(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_pruned", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__is_pruned); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_23is_pruned)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":77 + * + * cpdef bint is_pruned(BasisFunction self): + * return self.pruned # <<<<<<<<<<<<<< + * + * cpdef bint is_splittable(BasisFunction self): + */ + __pyx_r = __pyx_v_self->pruned; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.BasisFunction.is_pruned", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_23is_pruned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_23is_pruned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_pruned (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_22is_pruned(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":76 + * return self.prunable + * + * cpdef bint is_pruned(BasisFunction self): # <<<<<<<<<<<<<< + * return self.pruned + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_22is_pruned(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_pruned", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->is_pruned(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.is_pruned", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":79 + * return self.pruned + * + * cpdef bint is_splittable(BasisFunction self): # <<<<<<<<<<<<<< + * return self.splittable + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_25is_splittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_13BasisFunction_is_splittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_splittable", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__is_splittable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_25is_splittable)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":80 + * + * cpdef bint is_splittable(BasisFunction self): + * return self.splittable # <<<<<<<<<<<<<< + * + * cpdef bint make_splittable(BasisFunction self): + */ + __pyx_r = __pyx_v_self->splittable; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.BasisFunction.is_splittable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_25is_splittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_25is_splittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_splittable (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_24is_splittable(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":79 + * return self.pruned + * + * cpdef bint is_splittable(BasisFunction self): # <<<<<<<<<<<<<< + * return self.splittable + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_24is_splittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_splittable", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->is_splittable(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.is_splittable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":82 + * return self.splittable + * + * cpdef bint make_splittable(BasisFunction self): # <<<<<<<<<<<<<< + * self.splittable = True + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_27make_splittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_13BasisFunction_make_splittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("make_splittable", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__make_splittable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_27make_splittable)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":83 + * + * cpdef bint make_splittable(BasisFunction self): + * self.splittable = True # <<<<<<<<<<<<<< + * + * cpdef bint make_unsplittable(BasisFunction self): + */ + __pyx_v_self->splittable = 1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.BasisFunction.make_splittable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_27make_splittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_27make_splittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("make_splittable (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_26make_splittable(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":82 + * return self.splittable + * + * cpdef bint make_splittable(BasisFunction self): # <<<<<<<<<<<<<< + * self.splittable = True + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_26make_splittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("make_splittable", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->make_splittable(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.make_splittable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":85 + * self.splittable = True + * + * cpdef bint make_unsplittable(BasisFunction self): # <<<<<<<<<<<<<< + * self.splittable = False + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_29make_unsplittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_13BasisFunction_make_unsplittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("make_unsplittable", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__make_unsplittable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_29make_unsplittable)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":86 + * + * cpdef bint make_unsplittable(BasisFunction self): + * self.splittable = False # <<<<<<<<<<<<<< + * + * cdef list get_children(BasisFunction self): + */ + __pyx_v_self->splittable = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.BasisFunction.make_unsplittable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_29make_unsplittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_29make_unsplittable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("make_unsplittable (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_28make_unsplittable(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":85 + * self.splittable = True + * + * cpdef bint make_unsplittable(BasisFunction self): # <<<<<<<<<<<<<< + * self.splittable = False + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_28make_unsplittable(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("make_unsplittable", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->make_unsplittable(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.make_unsplittable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":88 + * self.splittable = False + * + * cdef list get_children(BasisFunction self): # <<<<<<<<<<<<<< + * return self.children + * + */ + +static PyObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_get_children(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_children", 0); + + /* "sklearn/earth/_basis.pyx":89 + * + * cdef list get_children(BasisFunction self): + * return self.children # <<<<<<<<<<<<<< + * + * cpdef _set_parent(self, BasisFunction parent): + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_self->children)); + __pyx_r = __pyx_v_self->children; + goto __pyx_L0; + + __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":91 + * return self.children + * + * cpdef _set_parent(self, BasisFunction parent): # <<<<<<<<<<<<<< + * '''Calls _add_child.''' + * self.parent = parent + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_31_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_v_parent); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction__set_parent(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_set_parent", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___set_parent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_31_set_parent)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_parent)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_parent)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_parent)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":93 + * cpdef _set_parent(self, BasisFunction parent): + * '''Calls _add_child.''' + * self.parent = parent # <<<<<<<<<<<<<< + * self.parent._add_child(self) + * + */ + __Pyx_INCREF(((PyObject *)__pyx_v_parent)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_parent)); + __Pyx_GOTREF(__pyx_v_self->parent); + __Pyx_DECREF(((PyObject *)__pyx_v_self->parent)); + __pyx_v_self->parent = __pyx_v_parent; + + /* "sklearn/earth/_basis.pyx":94 + * '''Calls _add_child.''' + * self.parent = parent + * self.parent._add_child(self) # <<<<<<<<<<<<<< + * + * cpdef _add_child(self, BasisFunction child): + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->parent->__pyx_vtab)->_add_child(__pyx_v_self->parent, __pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._set_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_31_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_v_parent); /*proto*/ +static char __pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_30_set_parent[] = "Calls _add_child."; +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_31_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_v_parent) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_set_parent (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction, 1, "parent", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_30_set_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_parent)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":91 + * return self.children + * + * cpdef _set_parent(self, BasisFunction parent): # <<<<<<<<<<<<<< + * '''Calls _add_child.''' + * self.parent = parent + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_30_set_parent(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_set_parent", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->_set_parent(__pyx_v_self, __pyx_v_parent, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._set_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":96 + * self.parent._add_child(self) + * + * cpdef _add_child(self, BasisFunction child): # <<<<<<<<<<<<<< + * '''Called by _set_parent.''' + * cdef INDEX_t n = len(self.children) + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_33_add_child(PyObject *__pyx_v_self, PyObject *__pyx_v_child); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction__add_child(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_child, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + int __pyx_v_var; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_add_child", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___add_child); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_33_add_child)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_child)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_child)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_child)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":98 + * cpdef _add_child(self, BasisFunction child): + * '''Called by _set_parent.''' + * cdef INDEX_t n = len(self.children) # <<<<<<<<<<<<<< + * self.children.append(child) + * cdef int var = child.get_variable() + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->children); + __Pyx_INCREF(__pyx_t_1); + if (unlikely(__pyx_t_1 == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_n = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":99 + * '''Called by _set_parent.''' + * cdef INDEX_t n = len(self.children) + * self.children.append(child) # <<<<<<<<<<<<<< + * cdef int var = child.get_variable() + * if var in self.child_map: + */ + if (unlikely(((PyObject *)__pyx_v_self->children) == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_self->children, ((PyObject *)__pyx_v_child)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":100 + * cdef INDEX_t n = len(self.children) + * self.children.append(child) + * cdef int var = child.get_variable() # <<<<<<<<<<<<<< + * if var in self.child_map: + * self.child_map[var].append(n) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_child), __pyx_n_s__get_variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_var = __pyx_t_6; + + /* "sklearn/earth/_basis.pyx":101 + * self.children.append(child) + * cdef int var = child.get_variable() + * if var in self.child_map: # <<<<<<<<<<<<<< + * self.child_map[var].append(n) + * else: + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_var); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(((PyObject *)__pyx_v_self->child_map) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_7 = (__Pyx_PyDict_Contains(__pyx_t_3, ((PyObject *)__pyx_v_self->child_map), Py_EQ)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = (__pyx_t_7 != 0); + if (__pyx_t_8) { + + /* "sklearn/earth/_basis.pyx":102 + * cdef int var = child.get_variable() + * if var in self.child_map: + * self.child_map[var].append(n) # <<<<<<<<<<<<<< + * else: + * self.child_map[var] = [n] + */ + if (unlikely(((PyObject *)__pyx_v_self->child_map) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->child_map), __pyx_v_var, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":104 + * self.child_map[var].append(n) + * else: + * self.child_map[var] = [n] # <<<<<<<<<<<<<< + * + * cpdef BasisFunction get_parent(self): + */ + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + if (unlikely(((PyObject *)__pyx_v_self->child_map) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (__Pyx_SetItemInt(((PyObject *)__pyx_v_self->child_map), __pyx_v_var, ((PyObject *)__pyx_t_1), sizeof(int), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._add_child", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_33_add_child(PyObject *__pyx_v_self, PyObject *__pyx_v_child); /*proto*/ +static char __pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_32_add_child[] = "Called by _set_parent."; +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_33_add_child(PyObject *__pyx_v_self, PyObject *__pyx_v_child) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_add_child (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction, 1, "child", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_32_add_child(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_child)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":96 + * self.parent._add_child(self) + * + * cpdef _add_child(self, BasisFunction child): # <<<<<<<<<<<<<< + * '''Called by _set_parent.''' + * cdef INDEX_t n = len(self.children) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_32_add_child(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_child) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_add_child", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->_add_child(__pyx_v_self, __pyx_v_child, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction._add_child", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":106 + * self.child_map[var] = [n] + * + * cpdef BasisFunction get_parent(self): # <<<<<<<<<<<<<< + * return self.parent + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_35get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_get_parent(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_parent", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_parent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_35get_parent)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":107 + * + * cpdef BasisFunction get_parent(self): + * return self.parent # <<<<<<<<<<<<<< + * + * cpdef prune(self): + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_self->parent)); + __pyx_r = __pyx_v_self->parent; + goto __pyx_L0; + + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.get_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_35get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_35get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_parent (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_34get_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":106 + * self.child_map[var] = [n] + * + * cpdef BasisFunction get_parent(self): # <<<<<<<<<<<<<< + * return self.parent + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_34get_parent(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_parent", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->get_parent(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.get_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":109 + * return self.parent + * + * cpdef prune(self): # <<<<<<<<<<<<<< + * self.pruned = True + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_37prune(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_prune(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("prune", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__prune); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_37prune)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":110 + * + * cpdef prune(self): + * self.pruned = True # <<<<<<<<<<<<<< + * + * cpdef unprune(self): + */ + __pyx_v_self->pruned = 1; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.prune", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_37prune(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_37prune(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("prune (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_36prune(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":109 + * return self.parent + * + * cpdef prune(self): # <<<<<<<<<<<<<< + * self.pruned = True + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_36prune(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("prune", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->prune(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.prune", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":112 + * self.pruned = True + * + * cpdef unprune(self): # <<<<<<<<<<<<<< + * self.pruned = False + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_39unprune(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_unprune(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("unprune", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__unprune); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_39unprune)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":113 + * + * cpdef unprune(self): + * self.pruned = False # <<<<<<<<<<<<<< + * + * cpdef knots(BasisFunction self, INDEX_t variable): + */ + __pyx_v_self->pruned = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.unprune", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_39unprune(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_39unprune(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("unprune (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_38unprune(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":112 + * self.pruned = True + * + * cpdef unprune(self): # <<<<<<<<<<<<<< + * self.pruned = False + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_38unprune(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("unprune", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->unprune(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.unprune", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":115 + * self.pruned = False + * + * cpdef knots(BasisFunction self, INDEX_t variable): # <<<<<<<<<<<<<< + * + * cdef list children + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_41knots(PyObject *__pyx_v_self, PyObject *__pyx_arg_variable); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_knots(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable, int __pyx_skip_dispatch) { + PyObject *__pyx_v_children = 0; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_child = 0; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + PyObject *__pyx_v_result = 0; + int __pyx_v_idx; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + Py_ssize_t __pyx_t_6; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_7; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("knots", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__knots); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_41knots)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":119 + * cdef list children + * cdef BasisFunction child + * if variable in self.child_map: # <<<<<<<<<<<<<< + * children = self.child_map[variable] + * else: + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(((PyObject *)__pyx_v_self->child_map) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = (__Pyx_PyDict_Contains(__pyx_t_1, ((PyObject *)__pyx_v_self->child_map), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_4 != 0); + if (__pyx_t_5) { + + /* "sklearn/earth/_basis.pyx":120 + * cdef BasisFunction child + * if variable in self.child_map: + * children = self.child_map[variable] # <<<<<<<<<<<<<< + * else: + * return [] + */ + if (unlikely(((PyObject *)__pyx_v_self->child_map) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->child_map), __pyx_v_variable, sizeof(__pyx_t_7sklearn_5earth_6_basis_INDEX_t)+1, __Pyx_PyInt_to_py_npy_ulonglong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_children = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":122 + * children = self.child_map[variable] + * else: + * return [] # <<<<<<<<<<<<<< + * cdef INDEX_t n = len(children) + * cdef INDEX_t i + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + } + __pyx_L3:; + + /* "sklearn/earth/_basis.pyx":123 + * else: + * return [] + * cdef INDEX_t n = len(children) # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef list result = [] + */ + if (unlikely(((PyObject *)__pyx_v_children) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_6 = PyList_GET_SIZE(((PyObject *)__pyx_v_children)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_n = __pyx_t_6; + + /* "sklearn/earth/_basis.pyx":125 + * cdef INDEX_t n = len(children) + * cdef INDEX_t i + * cdef list result = [] # <<<<<<<<<<<<<< + * cdef int idx + * for i in range(n): + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_result = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":127 + * cdef list result = [] + * cdef int idx + * for i in range(n): # <<<<<<<<<<<<<< + * idx = children[i] + * child = self.get_children()[idx] + */ + __pyx_t_7 = __pyx_v_n; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_i = __pyx_t_8; + + /* "sklearn/earth/_basis.pyx":128 + * cdef int idx + * for i in range(n): + * idx = children[i] # <<<<<<<<<<<<<< + * child = self.get_children()[idx] + * if child.has_knot(): + */ + if (unlikely(((PyObject *)__pyx_v_children) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_9 = __Pyx_PyInt_AsInt(PyList_GET_ITEM(__pyx_v_children, __pyx_v_i)); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_idx = __pyx_t_9; + + /* "sklearn/earth/_basis.pyx":129 + * for i in range(n): + * idx = children[i] + * child = self.get_children()[idx] # <<<<<<<<<<<<<< + * if child.has_knot(): + * result.append(child.get_knot_idx()) + */ + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->get_children(__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(__pyx_t_1 == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyList_GET_ITEM(__pyx_t_1, __pyx_v_idx)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_t_1, __pyx_v_idx), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_v_idx); + __Pyx_INCREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_child, ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_2)); + __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":130 + * idx = children[i] + * child = self.get_children()[idx] + * if child.has_knot(): # <<<<<<<<<<<<<< + * result.append(child.get_knot_idx()) + * return result + */ + __pyx_t_5 = (((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_child->__pyx_vtab)->has_knot(__pyx_v_child, 0) != 0); + if (__pyx_t_5) { + + /* "sklearn/earth/_basis.pyx":131 + * child = self.get_children()[idx] + * if child.has_knot(): + * result.append(child.get_knot_idx()) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_child), __pyx_n_s__get_knot_idx); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L6; + } + __pyx_L6:; + } + + /* "sklearn/earth/_basis.pyx":132 + * if child.has_knot(): + * result.append(child.get_knot_idx()) + * return result # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(BasisFunction self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.knots", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_children); + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_41knots(PyObject *__pyx_v_self, PyObject *__pyx_arg_variable); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_41knots(PyObject *__pyx_v_self, PyObject *__pyx_arg_variable) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("knots (wrapper)", 0); + assert(__pyx_arg_variable); { + __pyx_v_variable = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_variable); if (unlikely((__pyx_v_variable == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.knots", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_40knots(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_6_basis_INDEX_t)__pyx_v_variable)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":115 + * self.pruned = False + * + * cpdef knots(BasisFunction self, INDEX_t variable): # <<<<<<<<<<<<<< + * + * cdef list children + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_40knots(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("knots", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->knots(__pyx_v_self, __pyx_v_variable, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.knots", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":134 + * return result + * + * cpdef INDEX_t degree(BasisFunction self): # <<<<<<<<<<<<<< + * return self.parent.degree() + 1 + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_43degree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_f_7sklearn_5earth_6_basis_13BasisFunction_degree(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("degree", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__degree); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_43degree)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":135 + * + * cpdef INDEX_t degree(BasisFunction self): + * return self.parent.degree() + 1 # <<<<<<<<<<<<<< + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): + */ + __pyx_r = (((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->parent->__pyx_vtab)->degree(__pyx_v_self->parent, 0) + 1); + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.BasisFunction.degree", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_43degree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_43degree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("degree (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_42degree(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":134 + * return result + * + * cpdef INDEX_t degree(BasisFunction self): # <<<<<<<<<<<<<< + * return self.parent.degree() + 1 + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_42degree(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("degree", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->degree(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.degree", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":137 + * return self.parent.degree() + 1 + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_45apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_apply(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, CYTHON_UNUSED PyArrayObject *__pyx_v_X, CYTHON_UNUSED PyArrayObject *__pyx_v_b, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args) { + int __pyx_v_recurse = ((int)1); + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_recurse = __pyx_optional_args->recurse; + } + } + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__apply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_45apply)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_recurse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_INCREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_b)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":145 + * ''' + * + * cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace): # <<<<<<<<<<<<<< + * ''' + * values - The unsorted values of self in the data set + */ + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_45apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_44apply[] = "\n X - Data matrix\n b - parent vector\n recurse - If False, assume b already contains the result of the parent function. Otherwise, recurse to compute\n parent function.\n "; +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_45apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_b = 0; + int __pyx_v_recurse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("apply (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__b,&__pyx_n_s__recurse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__recurse); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_X = ((PyArrayObject *)values[0]); + __pyx_v_b = ((PyArrayObject *)values[1]); + if (values[2]) { + __pyx_v_recurse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_recurse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "sklearn/earth/_basis.pyx":137 + * return self.parent.degree() + 1 + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + __pyx_v_recurse = ((int)1); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_5numpy_ndarray, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_44apply(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), __pyx_v_X, __pyx_v_b, __pyx_v_recurse); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_44apply(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.recurse = __pyx_v_recurse; + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->apply(__pyx_v_self, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_b), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":145 + * ''' + * + * cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace): # <<<<<<<<<<<<<< + * ''' + * values - The unsorted values of self in the data set + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_47valid_knots(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyArrayObject *__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_valid_knots(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_variable, int __pyx_v_variable_idx, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_check_every, int __pyx_v_endspan, int __pyx_v_minspan, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_minspan_alpha, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n, PyArrayObject *__pyx_v_workspace, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_j; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_k; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_m; + __pyx_t_7sklearn_5earth_6_basis_INT_t __pyx_v_int_tmp; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_count; + int __pyx_v_minspan_; + PyArrayObject *__pyx_v_result = 0; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_num_used; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_prev; + int __pyx_v_idx; + int __pyx_v_last_idx; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_first_var_value; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_last_var_value; + PyObject *__pyx_v_used_knots = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_result; + __Pyx_Buffer __pyx_pybuffer_result; + __Pyx_LocalBuf_ND __pyx_pybuffernd_values; + __Pyx_Buffer __pyx_pybuffer_values; + __Pyx_LocalBuf_ND __pyx_pybuffernd_variable; + __Pyx_Buffer __pyx_pybuffer_variable; + __Pyx_LocalBuf_ND __pyx_pybuffernd_workspace; + __Pyx_Buffer __pyx_pybuffer_workspace; + PyArrayObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_9; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_10; + int __pyx_t_11; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_12; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_13; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_14; + int __pyx_t_15; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_16; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_17; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_18; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_19; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_20; + Py_ssize_t __pyx_t_21; + int __pyx_t_22; + int __pyx_t_23; + int __pyx_t_24; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_25; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_26; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_27; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_28; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_29; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_30; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_31; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_32; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_33; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_34; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_35; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_36; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_37; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_38; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_39; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_40; + PyArrayObject *__pyx_t_41 = NULL; + int __pyx_t_42; + PyObject *__pyx_t_43 = NULL; + PyObject *__pyx_t_44 = NULL; + PyObject *__pyx_t_45 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_46; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_47; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("valid_knots", 0); + __pyx_pybuffer_result.pybuffer.buf = NULL; + __pyx_pybuffer_result.refcount = 0; + __pyx_pybuffernd_result.data = NULL; + __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result; + __pyx_pybuffer_values.pybuffer.buf = NULL; + __pyx_pybuffer_values.refcount = 0; + __pyx_pybuffernd_values.data = NULL; + __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values; + __pyx_pybuffer_variable.pybuffer.buf = NULL; + __pyx_pybuffer_variable.refcount = 0; + __pyx_pybuffernd_variable.data = NULL; + __pyx_pybuffernd_variable.rcbuffer = &__pyx_pybuffer_variable; + __pyx_pybuffer_workspace.pybuffer.buf = NULL; + __pyx_pybuffer_workspace.refcount = 0; + __pyx_pybuffernd_workspace.data = NULL; + __pyx_pybuffernd_workspace.rcbuffer = &__pyx_pybuffer_workspace; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_variable.rcbuffer->pybuffer, (PyObject*)__pyx_v_variable, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_variable.diminfo[0].strides = __pyx_pybuffernd_variable.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_variable.diminfo[0].shape = __pyx_pybuffernd_variable.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_workspace.rcbuffer->pybuffer, (PyObject*)__pyx_v_workspace, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_INT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_workspace.diminfo[0].strides = __pyx_pybuffernd_workspace.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_workspace.diminfo[0].shape = __pyx_pybuffernd_workspace.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__valid_knots); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_47valid_knots)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = PyInt_FromLong(__pyx_v_variable_idx); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_check_every); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyInt_FromLong(__pyx_v_endspan); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyInt_FromLong(__pyx_v_minspan); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_minspan_alpha); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_n); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(((PyObject *)__pyx_v_values)); + PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_values)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_values)); + __Pyx_INCREF(((PyObject *)__pyx_v_variable)); + PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_v_variable)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_variable)); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __Pyx_INCREF(((PyObject *)__pyx_v_workspace)); + PyTuple_SET_ITEM(__pyx_t_8, 8, ((PyObject *)__pyx_v_workspace)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace)); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((PyArrayObject *)__pyx_t_7); + __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":155 + * cdef INDEX_t j + * cdef INDEX_t k + * cdef INDEX_t m = values.shape[0] # <<<<<<<<<<<<<< + * cdef FLOAT_t float_tmp + * cdef INT_t int_tmp + */ + __pyx_v_m = (__pyx_v_values->dimensions[0]); + + /* "sklearn/earth/_basis.pyx":166 + * cdef int idx + * cdef int last_idx + * cdef FLOAT_t first_var_value = variable[m - 1] # <<<<<<<<<<<<<< + * cdef FLOAT_t last_var_value = variable[m - 1] + * + */ + __pyx_t_9 = (__pyx_v_m - 1); + __pyx_v_first_var_value = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_variable.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_variable.diminfo[0].strides)); + + /* "sklearn/earth/_basis.pyx":167 + * cdef int last_idx + * cdef FLOAT_t first_var_value = variable[m - 1] + * cdef FLOAT_t last_var_value = variable[m - 1] # <<<<<<<<<<<<<< + * + * # Calculate the used knots + */ + __pyx_t_10 = (__pyx_v_m - 1); + __pyx_v_last_var_value = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_variable.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_variable.diminfo[0].strides)); + + /* "sklearn/earth/_basis.pyx":170 + * + * # Calculate the used knots + * cdef list used_knots = self.knots(variable_idx) # <<<<<<<<<<<<<< + * used_knots.sort() + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->knots(__pyx_v_self, __pyx_v_variable_idx, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_used_knots = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":171 + * # Calculate the used knots + * cdef list used_knots = self.knots(variable_idx) + * used_knots.sort() # <<<<<<<<<<<<<< + * + * # Initialize workspace to 1 where value is nonzero + */ + if (unlikely(((PyObject *)__pyx_v_used_knots) == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "sort"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_11 = PyList_Sort(((PyObject *)__pyx_v_used_knots)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":177 + * # where value is nonzero and last_var_value to the + * # minimum variable where value is nonzero + * count = 0 # <<<<<<<<<<<<<< + * for i in range(m): + * if abs(values[i]) > ZERO_TOL: + */ + __pyx_v_count = 0; + + /* "sklearn/earth/_basis.pyx":178 + * # minimum variable where value is nonzero + * count = 0 + * for i in range(m): # <<<<<<<<<<<<<< + * if abs(values[i]) > ZERO_TOL: + * workspace[i] = 1 + */ + __pyx_t_12 = __pyx_v_m; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_i = __pyx_t_13; + + /* "sklearn/earth/_basis.pyx":179 + * count = 0 + * for i in range(m): + * if abs(values[i]) > ZERO_TOL: # <<<<<<<<<<<<<< + * workspace[i] = 1 + * count += 1 + */ + __pyx_t_14 = __pyx_v_i; + __pyx_t_15 = ((fabs((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_values.diminfo[0].strides))) > __pyx_v_7sklearn_5earth_6_basis_ZERO_TOL) != 0); + if (__pyx_t_15) { + + /* "sklearn/earth/_basis.pyx":180 + * for i in range(m): + * if abs(values[i]) > ZERO_TOL: + * workspace[i] = 1 # <<<<<<<<<<<<<< + * count += 1 + * if variable[i] >= first_var_value: + */ + __pyx_t_16 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_workspace.diminfo[0].strides) = 1; + + /* "sklearn/earth/_basis.pyx":181 + * if abs(values[i]) > ZERO_TOL: + * workspace[i] = 1 + * count += 1 # <<<<<<<<<<<<<< + * if variable[i] >= first_var_value: + * first_var_value = variable[i] + */ + __pyx_v_count = (__pyx_v_count + 1); + + /* "sklearn/earth/_basis.pyx":182 + * workspace[i] = 1 + * count += 1 + * if variable[i] >= first_var_value: # <<<<<<<<<<<<<< + * first_var_value = variable[i] + * last_var_value = variable[i] + */ + __pyx_t_17 = __pyx_v_i; + __pyx_t_15 = (((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_variable.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_variable.diminfo[0].strides)) >= __pyx_v_first_var_value) != 0); + if (__pyx_t_15) { + + /* "sklearn/earth/_basis.pyx":183 + * count += 1 + * if variable[i] >= first_var_value: + * first_var_value = variable[i] # <<<<<<<<<<<<<< + * last_var_value = variable[i] + * else: + */ + __pyx_t_18 = __pyx_v_i; + __pyx_v_first_var_value = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_variable.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_variable.diminfo[0].strides)); + goto __pyx_L6; + } + __pyx_L6:; + + /* "sklearn/earth/_basis.pyx":184 + * if variable[i] >= first_var_value: + * first_var_value = variable[i] + * last_var_value = variable[i] # <<<<<<<<<<<<<< + * else: + * workspace[i] = 0 + */ + __pyx_t_19 = __pyx_v_i; + __pyx_v_last_var_value = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_variable.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_variable.diminfo[0].strides)); + goto __pyx_L5; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":186 + * last_var_value = variable[i] + * else: + * workspace[i] = 0 # <<<<<<<<<<<<<< + * + * # Calculate minspan + */ + __pyx_t_20 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + } + __pyx_L5:; + } + + /* "sklearn/earth/_basis.pyx":189 + * + * # Calculate minspan + * if minspan < 0: # <<<<<<<<<<<<<< + * minspan_ = (-log2(-(1.0 / (n * count)) * log(1.0 - minspan_alpha)) / 2.5) + * else: + */ + __pyx_t_15 = ((__pyx_v_minspan < 0) != 0); + if (__pyx_t_15) { + + /* "sklearn/earth/_basis.pyx":190 + * # Calculate minspan + * if minspan < 0: + * minspan_ = (-log2(-(1.0 / (n * count)) * log(1.0 - minspan_alpha)) / 2.5) # <<<<<<<<<<<<<< + * else: + * minspan_ = minspan + */ + __pyx_v_minspan_ = ((int)((-__pyx_f_7sklearn_5earth_5_util_log2(((-(1.0 / (__pyx_v_n * __pyx_v_count))) * log((1.0 - __pyx_v_minspan_alpha))))) / 2.5)); + goto __pyx_L7; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":192 + * minspan_ = (-log2(-(1.0 / (n * count)) * log(1.0 - minspan_alpha)) / 2.5) + * else: + * minspan_ = minspan # <<<<<<<<<<<<<< + * + * # Take out the used points and apply minspan + */ + __pyx_v_minspan_ = __pyx_v_minspan; + } + __pyx_L7:; + + /* "sklearn/earth/_basis.pyx":195 + * + * # Take out the used points and apply minspan + * num_used = len(used_knots) # <<<<<<<<<<<<<< + * prev = 0 + * last_idx = -1 + */ + if (unlikely(((PyObject *)__pyx_v_used_knots) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_21 = PyList_GET_SIZE(((PyObject *)__pyx_v_used_knots)); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_num_used = __pyx_t_21; + + /* "sklearn/earth/_basis.pyx":196 + * # Take out the used points and apply minspan + * num_used = len(used_knots) + * prev = 0 # <<<<<<<<<<<<<< + * last_idx = -1 + * for i in range(num_used): + */ + __pyx_v_prev = 0; + + /* "sklearn/earth/_basis.pyx":197 + * num_used = len(used_knots) + * prev = 0 + * last_idx = -1 # <<<<<<<<<<<<<< + * for i in range(num_used): + * idx = used_knots[i] + */ + __pyx_v_last_idx = -1; + + /* "sklearn/earth/_basis.pyx":198 + * prev = 0 + * last_idx = -1 + * for i in range(num_used): # <<<<<<<<<<<<<< + * idx = used_knots[i] + * if last_idx == idx: + */ + __pyx_t_12 = __pyx_v_num_used; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_i = __pyx_t_13; + + /* "sklearn/earth/_basis.pyx":199 + * last_idx = -1 + * for i in range(num_used): + * idx = used_knots[i] # <<<<<<<<<<<<<< + * if last_idx == idx: + * continue + */ + if (unlikely(((PyObject *)__pyx_v_used_knots) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_22 = __Pyx_PyInt_AsInt(PyList_GET_ITEM(__pyx_v_used_knots, __pyx_v_i)); if (unlikely((__pyx_t_22 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_idx = __pyx_t_22; + + /* "sklearn/earth/_basis.pyx":200 + * for i in range(num_used): + * idx = used_knots[i] + * if last_idx == idx: # <<<<<<<<<<<<<< + * continue + * workspace[idx] = 0 + */ + __pyx_t_15 = ((__pyx_v_last_idx == __pyx_v_idx) != 0); + if (__pyx_t_15) { + + /* "sklearn/earth/_basis.pyx":201 + * idx = used_knots[i] + * if last_idx == idx: + * continue # <<<<<<<<<<<<<< + * workspace[idx] = 0 + * j = idx + */ + goto __pyx_L8_continue; + goto __pyx_L10; + } + __pyx_L10:; + + /* "sklearn/earth/_basis.pyx":202 + * if last_idx == idx: + * continue + * workspace[idx] = 0 # <<<<<<<<<<<<<< + * j = idx + * k = 0 + */ + __pyx_t_22 = __pyx_v_idx; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + + /* "sklearn/earth/_basis.pyx":203 + * continue + * workspace[idx] = 0 + * j = idx # <<<<<<<<<<<<<< + * k = 0 + * while j > prev + 1 and k < minspan_: + */ + __pyx_v_j = __pyx_v_idx; + + /* "sklearn/earth/_basis.pyx":204 + * workspace[idx] = 0 + * j = idx + * k = 0 # <<<<<<<<<<<<<< + * while j > prev + 1 and k < minspan_: + * if workspace[j - 1]: + */ + __pyx_v_k = 0; + + /* "sklearn/earth/_basis.pyx":205 + * j = idx + * k = 0 + * while j > prev + 1 and k < minspan_: # <<<<<<<<<<<<<< + * if workspace[j - 1]: + * workspace[j - 1] = False + */ + while (1) { + __pyx_t_15 = ((__pyx_v_j > (__pyx_v_prev + 1)) != 0); + if (__pyx_t_15) { + __pyx_t_23 = ((__pyx_v_k < __pyx_v_minspan_) != 0); + __pyx_t_24 = __pyx_t_23; + } else { + __pyx_t_24 = __pyx_t_15; + } + if (!__pyx_t_24) break; + + /* "sklearn/earth/_basis.pyx":206 + * k = 0 + * while j > prev + 1 and k < minspan_: + * if workspace[j - 1]: # <<<<<<<<<<<<<< + * workspace[j - 1] = False + * k += 1 + */ + __pyx_t_25 = (__pyx_v_j - 1); + __pyx_t_24 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_24) { + + /* "sklearn/earth/_basis.pyx":207 + * while j > prev + 1 and k < minspan_: + * if workspace[j - 1]: + * workspace[j - 1] = False # <<<<<<<<<<<<<< + * k += 1 + * j -= 1 + */ + __pyx_t_26 = (__pyx_v_j - 1); + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + + /* "sklearn/earth/_basis.pyx":208 + * if workspace[j - 1]: + * workspace[j - 1] = False + * k += 1 # <<<<<<<<<<<<<< + * j -= 1 + * j = idx + 1 + */ + __pyx_v_k = (__pyx_v_k + 1); + goto __pyx_L13; + } + __pyx_L13:; + + /* "sklearn/earth/_basis.pyx":209 + * workspace[j - 1] = False + * k += 1 + * j -= 1 # <<<<<<<<<<<<<< + * j = idx + 1 + * k = 0 + */ + __pyx_v_j = (__pyx_v_j - 1); + } + + /* "sklearn/earth/_basis.pyx":210 + * k += 1 + * j -= 1 + * j = idx + 1 # <<<<<<<<<<<<<< + * k = 0 + * while j < m and k < minspan_: + */ + __pyx_v_j = (__pyx_v_idx + 1); + + /* "sklearn/earth/_basis.pyx":211 + * j -= 1 + * j = idx + 1 + * k = 0 # <<<<<<<<<<<<<< + * while j < m and k < minspan_: + * if workspace[j]: + */ + __pyx_v_k = 0; + + /* "sklearn/earth/_basis.pyx":212 + * j = idx + 1 + * k = 0 + * while j < m and k < minspan_: # <<<<<<<<<<<<<< + * if workspace[j]: + * workspace[j] = False + */ + while (1) { + __pyx_t_24 = ((__pyx_v_j < __pyx_v_m) != 0); + if (__pyx_t_24) { + __pyx_t_15 = ((__pyx_v_k < __pyx_v_minspan_) != 0); + __pyx_t_23 = __pyx_t_15; + } else { + __pyx_t_23 = __pyx_t_24; + } + if (!__pyx_t_23) break; + + /* "sklearn/earth/_basis.pyx":213 + * k = 0 + * while j < m and k < minspan_: + * if workspace[j]: # <<<<<<<<<<<<<< + * workspace[j] = False + * k += 1 + */ + __pyx_t_27 = __pyx_v_j; + __pyx_t_23 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":214 + * while j < m and k < minspan_: + * if workspace[j]: + * workspace[j] = False # <<<<<<<<<<<<<< + * k += 1 + * j += 1 + */ + __pyx_t_28 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + + /* "sklearn/earth/_basis.pyx":215 + * if workspace[j]: + * workspace[j] = False + * k += 1 # <<<<<<<<<<<<<< + * j += 1 + * prev = idx + */ + __pyx_v_k = (__pyx_v_k + 1); + goto __pyx_L16; + } + __pyx_L16:; + + /* "sklearn/earth/_basis.pyx":216 + * workspace[j] = False + * k += 1 + * j += 1 # <<<<<<<<<<<<<< + * prev = idx + * last_idx = idx + */ + __pyx_v_j = (__pyx_v_j + 1); + } + + /* "sklearn/earth/_basis.pyx":217 + * k += 1 + * j += 1 + * prev = idx # <<<<<<<<<<<<<< + * last_idx = idx + * + */ + __pyx_v_prev = __pyx_v_idx; + + /* "sklearn/earth/_basis.pyx":218 + * j += 1 + * prev = idx + * last_idx = idx # <<<<<<<<<<<<<< + * + * # Apply endspan + */ + __pyx_v_last_idx = __pyx_v_idx; + __pyx_L8_continue:; + } + + /* "sklearn/earth/_basis.pyx":221 + * + * # Apply endspan + * i = 0 # <<<<<<<<<<<<<< + * j = 0 + * while i < endspan: + */ + __pyx_v_i = 0; + + /* "sklearn/earth/_basis.pyx":222 + * # Apply endspan + * i = 0 + * j = 0 # <<<<<<<<<<<<<< + * while i < endspan: + * if workspace[j]: + */ + __pyx_v_j = 0; + + /* "sklearn/earth/_basis.pyx":223 + * i = 0 + * j = 0 + * while i < endspan: # <<<<<<<<<<<<<< + * if workspace[j]: + * workspace[j] = 0 + */ + while (1) { + __pyx_t_23 = ((__pyx_v_i < __pyx_v_endspan) != 0); + if (!__pyx_t_23) break; + + /* "sklearn/earth/_basis.pyx":224 + * j = 0 + * while i < endspan: + * if workspace[j]: # <<<<<<<<<<<<<< + * workspace[j] = 0 + * i += 1 + */ + __pyx_t_12 = __pyx_v_j; + __pyx_t_23 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":225 + * while i < endspan: + * if workspace[j]: + * workspace[j] = 0 # <<<<<<<<<<<<<< + * i += 1 + * j += 1 + */ + __pyx_t_13 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + + /* "sklearn/earth/_basis.pyx":226 + * if workspace[j]: + * workspace[j] = 0 + * i += 1 # <<<<<<<<<<<<<< + * j += 1 + * if j == m: + */ + __pyx_v_i = (__pyx_v_i + 1); + goto __pyx_L19; + } + __pyx_L19:; + + /* "sklearn/earth/_basis.pyx":227 + * workspace[j] = 0 + * i += 1 + * j += 1 # <<<<<<<<<<<<<< + * if j == m: + * break + */ + __pyx_v_j = (__pyx_v_j + 1); + + /* "sklearn/earth/_basis.pyx":228 + * i += 1 + * j += 1 + * if j == m: # <<<<<<<<<<<<<< + * break + * i = 0 + */ + __pyx_t_23 = ((__pyx_v_j == __pyx_v_m) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":229 + * j += 1 + * if j == m: + * break # <<<<<<<<<<<<<< + * i = 0 + * j = m - 1 + */ + goto __pyx_L18_break; + goto __pyx_L20; + } + __pyx_L20:; + } + __pyx_L18_break:; + + /* "sklearn/earth/_basis.pyx":230 + * if j == m: + * break + * i = 0 # <<<<<<<<<<<<<< + * j = m - 1 + * while i < endspan: + */ + __pyx_v_i = 0; + + /* "sklearn/earth/_basis.pyx":231 + * break + * i = 0 + * j = m - 1 # <<<<<<<<<<<<<< + * while i < endspan: + * if workspace[j]: + */ + __pyx_v_j = (__pyx_v_m - 1); + + /* "sklearn/earth/_basis.pyx":232 + * i = 0 + * j = m - 1 + * while i < endspan: # <<<<<<<<<<<<<< + * if workspace[j]: + * workspace[j] = 0 + */ + while (1) { + __pyx_t_23 = ((__pyx_v_i < __pyx_v_endspan) != 0); + if (!__pyx_t_23) break; + + /* "sklearn/earth/_basis.pyx":233 + * j = m - 1 + * while i < endspan: + * if workspace[j]: # <<<<<<<<<<<<<< + * workspace[j] = 0 + * i += 1 + */ + __pyx_t_29 = __pyx_v_j; + __pyx_t_23 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":234 + * while i < endspan: + * if workspace[j]: + * workspace[j] = 0 # <<<<<<<<<<<<<< + * i += 1 + * if j == 0: + */ + __pyx_t_30 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + + /* "sklearn/earth/_basis.pyx":235 + * if workspace[j]: + * workspace[j] = 0 + * i += 1 # <<<<<<<<<<<<<< + * if j == 0: + * break + */ + __pyx_v_i = (__pyx_v_i + 1); + goto __pyx_L23; + } + __pyx_L23:; + + /* "sklearn/earth/_basis.pyx":236 + * workspace[j] = 0 + * i += 1 + * if j == 0: # <<<<<<<<<<<<<< + * break + * j -= 1 + */ + __pyx_t_23 = ((__pyx_v_j == 0) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":237 + * i += 1 + * if j == 0: + * break # <<<<<<<<<<<<<< + * j -= 1 + * + */ + goto __pyx_L22_break; + goto __pyx_L24; + } + __pyx_L24:; + + /* "sklearn/earth/_basis.pyx":238 + * if j == 0: + * break + * j -= 1 # <<<<<<<<<<<<<< + * + * # Implement check_every + */ + __pyx_v_j = (__pyx_v_j - 1); + } + __pyx_L22_break:; + + /* "sklearn/earth/_basis.pyx":241 + * + * # Implement check_every + * int_tmp = 0 # <<<<<<<<<<<<<< + * count = 0 + * for i in range(m): + */ + __pyx_v_int_tmp = 0; + + /* "sklearn/earth/_basis.pyx":242 + * # Implement check_every + * int_tmp = 0 + * count = 0 # <<<<<<<<<<<<<< + * for i in range(m): + * if workspace[i]: + */ + __pyx_v_count = 0; + + /* "sklearn/earth/_basis.pyx":243 + * int_tmp = 0 + * count = 0 + * for i in range(m): # <<<<<<<<<<<<<< + * if workspace[i]: + * if (int_tmp % check_every) != 0: + */ + __pyx_t_31 = __pyx_v_m; + for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) { + __pyx_v_i = __pyx_t_32; + + /* "sklearn/earth/_basis.pyx":244 + * count = 0 + * for i in range(m): + * if workspace[i]: # <<<<<<<<<<<<<< + * if (int_tmp % check_every) != 0: + * workspace[i] = 0 + */ + __pyx_t_33 = __pyx_v_i; + __pyx_t_23 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":245 + * for i in range(m): + * if workspace[i]: + * if (int_tmp % check_every) != 0: # <<<<<<<<<<<<<< + * workspace[i] = 0 + * else: + */ + __pyx_t_23 = (((__pyx_v_int_tmp % __pyx_v_check_every) != 0) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":246 + * if workspace[i]: + * if (int_tmp % check_every) != 0: + * workspace[i] = 0 # <<<<<<<<<<<<<< + * else: + * count += 1 + */ + __pyx_t_34 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + goto __pyx_L28; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":248 + * workspace[i] = 0 + * else: + * count += 1 # <<<<<<<<<<<<<< + * int_tmp += 1 + * else: + */ + __pyx_v_count = (__pyx_v_count + 1); + } + __pyx_L28:; + + /* "sklearn/earth/_basis.pyx":249 + * else: + * count += 1 + * int_tmp += 1 # <<<<<<<<<<<<<< + * else: + * int_tmp = 0 + */ + __pyx_v_int_tmp = (__pyx_v_int_tmp + 1); + goto __pyx_L27; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":251 + * int_tmp += 1 + * else: + * int_tmp = 0 # <<<<<<<<<<<<<< + * + * # Make sure the greatest value is not a candidate (this can happen if + */ + __pyx_v_int_tmp = 0; + } + __pyx_L27:; + } + + /* "sklearn/earth/_basis.pyx":255 + * # Make sure the greatest value is not a candidate (this can happen if + * # the first endspan+1 values are the same) + * for i in range(m): # <<<<<<<<<<<<<< + * if workspace[i]: + * if variable[i] == first_var_value: + */ + __pyx_t_31 = __pyx_v_m; + for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) { + __pyx_v_i = __pyx_t_32; + + /* "sklearn/earth/_basis.pyx":256 + * # the first endspan+1 values are the same) + * for i in range(m): + * if workspace[i]: # <<<<<<<<<<<<<< + * if variable[i] == first_var_value: + * workspace[i] = 0 + */ + __pyx_t_35 = __pyx_v_i; + __pyx_t_23 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":257 + * for i in range(m): + * if workspace[i]: + * if variable[i] == first_var_value: # <<<<<<<<<<<<<< + * workspace[i] = 0 + * count -= 1 + */ + __pyx_t_36 = __pyx_v_i; + __pyx_t_23 = (((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_variable.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_variable.diminfo[0].strides)) == __pyx_v_first_var_value) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":258 + * if workspace[i]: + * if variable[i] == first_var_value: + * workspace[i] = 0 # <<<<<<<<<<<<<< + * count -= 1 + * else: + */ + __pyx_t_37 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + + /* "sklearn/earth/_basis.pyx":259 + * if variable[i] == first_var_value: + * workspace[i] = 0 + * count -= 1 # <<<<<<<<<<<<<< + * else: + * break + */ + __pyx_v_count = (__pyx_v_count - 1); + goto __pyx_L32; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":261 + * count -= 1 + * else: + * break # <<<<<<<<<<<<<< + * + * # Also make sure the least value is not a candidate + */ + goto __pyx_L30_break; + } + __pyx_L32:; + goto __pyx_L31; + } + __pyx_L31:; + } + __pyx_L30_break:; + + /* "sklearn/earth/_basis.pyx":264 + * + * # Also make sure the least value is not a candidate + * for i in range(m): # <<<<<<<<<<<<<< + * if workspace[m - i - 1]: + * if variable[m - i - 1] == last_var_value: + */ + __pyx_t_31 = __pyx_v_m; + for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) { + __pyx_v_i = __pyx_t_32; + + /* "sklearn/earth/_basis.pyx":265 + * # Also make sure the least value is not a candidate + * for i in range(m): + * if workspace[m - i - 1]: # <<<<<<<<<<<<<< + * if variable[m - i - 1] == last_var_value: + * workspace[m - i - 1] = 0 + */ + __pyx_t_38 = ((__pyx_v_m - __pyx_v_i) - 1); + __pyx_t_23 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":266 + * for i in range(m): + * if workspace[m - i - 1]: + * if variable[m - i - 1] == last_var_value: # <<<<<<<<<<<<<< + * workspace[m - i - 1] = 0 + * count -= 1 + */ + __pyx_t_39 = ((__pyx_v_m - __pyx_v_i) - 1); + __pyx_t_23 = (((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_variable.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_variable.diminfo[0].strides)) == __pyx_v_last_var_value) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":267 + * if workspace[m - i - 1]: + * if variable[m - i - 1] == last_var_value: + * workspace[m - i - 1] = 0 # <<<<<<<<<<<<<< + * count -= 1 + * else: + */ + __pyx_t_40 = ((__pyx_v_m - __pyx_v_i) - 1); + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_workspace.diminfo[0].strides) = 0; + + /* "sklearn/earth/_basis.pyx":268 + * if variable[m - i - 1] == last_var_value: + * workspace[m - i - 1] = 0 + * count -= 1 # <<<<<<<<<<<<<< + * else: + * break + */ + __pyx_v_count = (__pyx_v_count - 1); + goto __pyx_L36; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":270 + * count -= 1 + * else: + * break # <<<<<<<<<<<<<< + * + * # Create result array and return + */ + goto __pyx_L34_break; + } + __pyx_L36:; + goto __pyx_L35; + } + __pyx_L35:; + } + __pyx_L34_break:; + + /* "sklearn/earth/_basis.pyx":273 + * + * # Create result array and return + * result = np.empty(shape=count, dtype=int) # <<<<<<<<<<<<<< + * j = 0 + * for i in range(m): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_8 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_count); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__shape), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)((PyObject*)(&PyInt_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_41 = ((PyArrayObject *)__pyx_t_8); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); + __pyx_t_42 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_41, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_INT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_42 < 0)) { + PyErr_Fetch(&__pyx_t_43, &__pyx_t_44, &__pyx_t_45); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_INT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_43); Py_XDECREF(__pyx_t_44); Py_XDECREF(__pyx_t_45); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_43, __pyx_t_44, __pyx_t_45); + } + } + __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_42 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_41 = 0; + __pyx_v_result = ((PyArrayObject *)__pyx_t_8); + __pyx_t_8 = 0; + + /* "sklearn/earth/_basis.pyx":274 + * # Create result array and return + * result = np.empty(shape=count, dtype=int) + * j = 0 # <<<<<<<<<<<<<< + * for i in range(m): + * if workspace[i]: + */ + __pyx_v_j = 0; + + /* "sklearn/earth/_basis.pyx":275 + * result = np.empty(shape=count, dtype=int) + * j = 0 + * for i in range(m): # <<<<<<<<<<<<<< + * if workspace[i]: + * result[j] = i + */ + __pyx_t_31 = __pyx_v_m; + for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) { + __pyx_v_i = __pyx_t_32; + + /* "sklearn/earth/_basis.pyx":276 + * j = 0 + * for i in range(m): + * if workspace[i]: # <<<<<<<<<<<<<< + * result[j] = i + * j += 1 + */ + __pyx_t_46 = __pyx_v_i; + __pyx_t_23 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_workspace.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_workspace.diminfo[0].strides)) != 0); + if (__pyx_t_23) { + + /* "sklearn/earth/_basis.pyx":277 + * for i in range(m): + * if workspace[i]: + * result[j] = i # <<<<<<<<<<<<<< + * j += 1 + * + */ + __pyx_t_47 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_INT_t *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_47, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_v_i; + + /* "sklearn/earth/_basis.pyx":278 + * if workspace[i]: + * result[j] = i + * j += 1 # <<<<<<<<<<<<<< + * + * return result + */ + __pyx_v_j = (__pyx_v_j + 1); + goto __pyx_L39; + } + __pyx_L39:; + } + + /* "sklearn/earth/_basis.pyx":280 + * j += 1 + * + * return result # <<<<<<<<<<<<<< + * + * cdef class PicklePlaceHolderBasisFunction(BasisFunction): + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyArrayObject *)__pyx_v_result); + goto __pyx_L0; + + __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_variable.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_workspace.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.valid_knots", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_variable.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_workspace.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XDECREF(__pyx_v_used_knots); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_47valid_knots(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_46valid_knots[] = "\n values - The unsorted values of self in the data set\n variable - The sorted values of variable in the data set\n variable_idx - The index of the variable in the data set\n workspace - An m-vector (where m is the number of samples) used internally\n "; +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_47valid_knots(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_values = 0; + PyArrayObject *__pyx_v_variable = 0; + int __pyx_v_variable_idx; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_check_every; + int __pyx_v_endspan; + int __pyx_v_minspan; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_minspan_alpha; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + PyArrayObject *__pyx_v_workspace = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("valid_knots (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__values,&__pyx_n_s__variable,&__pyx_n_s__variable_idx,&__pyx_n_s__check_every,&__pyx_n_s__endspan,&__pyx_n_s__minspan,&__pyx_n_s__minspan_alpha,&__pyx_n_s__n,&__pyx_n_s__workspace,0}; + PyObject* values[9] = {0,0,0,0,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 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__values)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__variable)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__variable_idx)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__check_every)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__endspan)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__minspan)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 6: + if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__minspan_alpha)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 7: + if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 8: + if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "valid_knots") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { + 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); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + } + __pyx_v_values = ((PyArrayObject *)values[0]); + __pyx_v_variable = ((PyArrayObject *)values[1]); + __pyx_v_variable_idx = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_variable_idx == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_check_every = __Pyx_PyInt_from_py_npy_ulonglong(values[3]); if (unlikely((__pyx_v_check_every == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_endspan = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_endspan == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_minspan = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_minspan == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_minspan_alpha = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_minspan_alpha == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n = __Pyx_PyInt_from_py_npy_ulonglong(values[7]); if (unlikely((__pyx_v_n == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_workspace = ((PyArrayObject *)values[8]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("valid_knots", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.valid_knots", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable), __pyx_ptype_5numpy_ndarray, 1, "variable", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_5numpy_ndarray, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_46valid_knots(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), __pyx_v_values, __pyx_v_variable, __pyx_v_variable_idx, __pyx_v_check_every, __pyx_v_endspan, __pyx_v_minspan, __pyx_v_minspan_alpha, __pyx_v_n, __pyx_v_workspace); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":145 + * ''' + * + * cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace): # <<<<<<<<<<<<<< + * ''' + * values - The unsorted values of self in the data set + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_13BasisFunction_46valid_knots(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_variable, int __pyx_v_variable_idx, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_check_every, int __pyx_v_endspan, int __pyx_v_minspan, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_minspan_alpha, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n, PyArrayObject *__pyx_v_workspace) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_values; + __Pyx_Buffer __pyx_pybuffer_values; + __Pyx_LocalBuf_ND __pyx_pybuffernd_variable; + __Pyx_Buffer __pyx_pybuffer_variable; + __Pyx_LocalBuf_ND __pyx_pybuffernd_workspace; + __Pyx_Buffer __pyx_pybuffer_workspace; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("valid_knots", 0); + __pyx_pybuffer_values.pybuffer.buf = NULL; + __pyx_pybuffer_values.refcount = 0; + __pyx_pybuffernd_values.data = NULL; + __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values; + __pyx_pybuffer_variable.pybuffer.buf = NULL; + __pyx_pybuffer_variable.refcount = 0; + __pyx_pybuffernd_variable.data = NULL; + __pyx_pybuffernd_variable.rcbuffer = &__pyx_pybuffer_variable; + __pyx_pybuffer_workspace.pybuffer.buf = NULL; + __pyx_pybuffer_workspace.refcount = 0; + __pyx_pybuffernd_workspace.data = NULL; + __pyx_pybuffernd_workspace.rcbuffer = &__pyx_pybuffer_workspace; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_variable.rcbuffer->pybuffer, (PyObject*)__pyx_v_variable, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_variable.diminfo[0].strides = __pyx_pybuffernd_variable.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_variable.diminfo[0].shape = __pyx_pybuffernd_variable.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_workspace.rcbuffer->pybuffer, (PyObject*)__pyx_v_workspace, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_workspace.diminfo[0].strides = __pyx_pybuffernd_workspace.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_workspace.diminfo[0].shape = __pyx_pybuffernd_workspace.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_vtab)->valid_knots(__pyx_v_self, ((PyArrayObject *)__pyx_v_values), ((PyArrayObject *)__pyx_v_variable), __pyx_v_variable_idx, __pyx_v_check_every, __pyx_v_endspan, __pyx_v_minspan, __pyx_v_minspan_alpha, __pyx_v_n, ((PyArrayObject *)__pyx_v_workspace), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_variable.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_workspace.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.BasisFunction.valid_knots", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_variable.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_workspace.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction___init__(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":288 + * + * cdef class ConstantBasisFunction(BasisFunction): + * def __init__(self): # @DuplicatedSignature # <<<<<<<<<<<<<< + * self.prunable = False + * + */ + +static int __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction___init__(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_basis.pyx":289 + * cdef class ConstantBasisFunction(BasisFunction): + * def __init__(self): # @DuplicatedSignature + * self.prunable = False # <<<<<<<<<<<<<< + * + * def _get_root(self): + */ + __pyx_v_self->__pyx_base.prunable = 0; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_3_get_root(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_3_get_root(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_get_root (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_2_get_root(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":291 + * self.prunable = False + * + * def _get_root(self): # <<<<<<<<<<<<<< + * return self + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_2_get_root(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_get_root", 0); + + /* "sklearn/earth/_basis.pyx":292 + * + * def _get_root(self): + * return self # <<<<<<<<<<<<<< + * + * def _get_parent_state(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_5_get_parent_state(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_5_get_parent_state(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_get_parent_state (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_4_get_parent_state(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":294 + * return self + * + * def _get_parent_state(self): # <<<<<<<<<<<<<< + * return {} + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_4_get_parent_state(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_get_parent_state", 0); + + /* "sklearn/earth/_basis.pyx":295 + * + * def _get_parent_state(self): + * return {} # <<<<<<<<<<<<<< + * + * def _set_parent_state(self, state): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction._get_parent_state", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_7_set_parent_state(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_7_set_parent_state(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_set_parent_state (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_6_set_parent_state(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self), ((PyObject *)__pyx_v_state)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":297 + * return {} + * + * def _set_parent_state(self, state): # <<<<<<<<<<<<<< + * pass + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_6_set_parent_state(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_set_parent_state", 0); + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":300 + * pass + * + * cpdef INDEX_t degree(ConstantBasisFunction self): # <<<<<<<<<<<<<< + * return 0 + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_9degree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_degree(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("degree", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__degree); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_9degree)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":301 + * + * cpdef INDEX_t degree(ConstantBasisFunction self): + * return 0 # <<<<<<<<<<<<<< + * + * cpdef translate(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.ConstantBasisFunction.degree", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_9degree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_9degree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("degree (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_8degree(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":300 + * pass + * + * cpdef INDEX_t degree(ConstantBasisFunction self): # <<<<<<<<<<<<<< + * return 0 + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_8degree(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("degree", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.degree(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.degree", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":303 + * return 0 + * + * cpdef translate(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): # <<<<<<<<<<<<<< + * pass + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_11translate(PyObject *__pyx_v_ConstantBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_translate(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_ConstantBasisFunctionself, CYTHON_UNUSED PyArrayObject *__pyx_v_slopes, CYTHON_UNUSED PyArrayObject *__pyx_v_intercepts, CYTHON_UNUSED int __pyx_v_recurse, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_ConstantBasisFunctionself))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ConstantBasisFunctionself), __pyx_n_s__translate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_11translate)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_recurse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":304 + * + * cpdef translate(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + * pass # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t scale(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + */ + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_11translate(PyObject *__pyx_v_ConstantBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_11translate(PyObject *__pyx_v_ConstantBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + int __pyx_v_recurse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("translate (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,&__pyx_n_s__recurse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__recurse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __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_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + __pyx_v_recurse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_recurse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_10translate(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_ConstantBasisFunctionself), __pyx_v_slopes, __pyx_v_intercepts, __pyx_v_recurse); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":303 + * return 0 + * + * cpdef translate(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): # <<<<<<<<<<<<<< + * pass + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_10translate(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_ConstantBasisFunctionself, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_v_recurse) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_ConstantBasisFunctionself->__pyx_base.__pyx_vtab)->translate(__pyx_v_ConstantBasisFunctionself, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), __pyx_v_recurse, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":306 + * pass + * + * cpdef FLOAT_t scale(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * return < FLOAT_t > 1.0 + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_13scale(PyObject *__pyx_v_ConstantBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_scale(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_ConstantBasisFunctionself, CYTHON_UNUSED PyArrayObject *__pyx_v_slopes, CYTHON_UNUSED PyArrayObject *__pyx_v_intercepts, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_ConstantBasisFunctionself))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ConstantBasisFunctionself), __pyx_n_s__scale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_13scale)) { + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":307 + * + * cpdef FLOAT_t scale(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + * return < FLOAT_t > 1.0 # <<<<<<<<<<<<<< + * + * cpdef _set_parent(self, BasisFunction parent): + */ + __pyx_r = ((__pyx_t_7sklearn_5earth_6_basis_FLOAT_t)1.0); + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_WriteUnraisable("sklearn.earth._basis.ConstantBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_13scale(PyObject *__pyx_v_ConstantBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_13scale(PyObject *__pyx_v_ConstantBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("scale (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("scale", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scale") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("scale", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_12scale(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_ConstantBasisFunctionself), __pyx_v_slopes, __pyx_v_intercepts); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":306 + * pass + * + * cpdef FLOAT_t scale(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * return < FLOAT_t > 1.0 + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_12scale(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_ConstantBasisFunctionself, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_ConstantBasisFunctionself->__pyx_base.__pyx_vtab)->scale(__pyx_v_ConstantBasisFunctionself, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":309 + * return < FLOAT_t > 1.0 + * + * cpdef _set_parent(self, BasisFunction parent): # <<<<<<<<<<<<<< + * raise NotImplementedError + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_15_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_v_parent); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction__set_parent(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_set_parent", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___set_parent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_15_set_parent)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_parent)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_parent)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_parent)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":310 + * + * cpdef _set_parent(self, BasisFunction parent): + * raise NotImplementedError # <<<<<<<<<<<<<< + * + * cpdef BasisFunction get_parent(self): + */ + __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction._set_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_15_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_v_parent); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_15_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_v_parent) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_set_parent (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction, 1, "parent", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_14_set_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self), ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_parent)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":309 + * return < FLOAT_t > 1.0 + * + * cpdef _set_parent(self, BasisFunction parent): # <<<<<<<<<<<<<< + * raise NotImplementedError + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_14_set_parent(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_set_parent", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), __pyx_v_parent, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction._set_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":312 + * raise NotImplementedError + * + * cpdef BasisFunction get_parent(self): # <<<<<<<<<<<<<< + * raise NotImplementedError + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_17get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_get_parent(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_parent", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_parent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_17get_parent)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":313 + * + * cpdef BasisFunction get_parent(self): + * raise NotImplementedError # <<<<<<<<<<<<<< + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=False): + */ + __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.get_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_17get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_17get_parent(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_parent (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_16get_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":312 + * raise NotImplementedError + * + * cpdef BasisFunction get_parent(self): # <<<<<<<<<<<<<< + * raise NotImplementedError + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_16get_parent(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_parent", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.get_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.get_parent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":315 + * raise NotImplementedError + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=False): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_19apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, CYTHON_UNUSED PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply *__pyx_optional_args) { + int __pyx_v_recurse = ((int)0); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_m; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_6; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_recurse = __pyx_optional_args->recurse; + } + } + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__apply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_19apply)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_recurse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_INCREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_b)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":324 + * ''' + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t m = len(b) # <<<<<<<<<<<<<< + * for i in range(m): + * b[i] = 1.0 + */ + __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_b)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_m = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":325 + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t m = len(b) + * for i in range(m): # <<<<<<<<<<<<<< + * b[i] = 1.0 + * + */ + __pyx_t_5 = __pyx_v_m; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "sklearn/earth/_basis.pyx":326 + * cdef INDEX_t m = len(b) + * for i in range(m): + * b[i] = 1.0 # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + __pyx_t_7 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_b.diminfo[0].strides) = ((__pyx_t_7sklearn_5earth_6_basis_FLOAT_t)1.0); + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_19apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_5earth_6_basis_21ConstantBasisFunction_18apply[] = "\n X - Data matrix\n b - parent vector\n recurse - The ConstantBasisFunction is the parent of all BasisFunctions and never has a parent.\n Therefore the recurse argument is ignored. This spares child BasisFunctions from\n having to know whether their parents have parents.\n "; +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_19apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_b = 0; + int __pyx_v_recurse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("apply (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__b,&__pyx_n_s__recurse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__recurse); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_X = ((PyArrayObject *)values[0]); + __pyx_v_b = ((PyArrayObject *)values[1]); + if (values[2]) { + __pyx_v_recurse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_recurse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "sklearn/earth/_basis.pyx":315 + * raise NotImplementedError + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=False): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + __pyx_v_recurse = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_5numpy_ndarray, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_18apply(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self), __pyx_v_X, __pyx_v_b, __pyx_v_recurse); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_18apply(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.recurse = __pyx_v_recurse; + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.apply(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_b), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.ConstantBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_21__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_21__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_20__str__(((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":328 + * b[i] = 1.0 + * + * def __str__(self): # <<<<<<<<<<<<<< + * return '(Intercept)' + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_21ConstantBasisFunction_20__str__(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_basis.pyx":329 + * + * def __str__(self): + * return '(Intercept)' # <<<<<<<<<<<<<< + * + * cdef class HingeBasisFunction(BasisFunction): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); + __pyx_r = ((PyObject *)__pyx_kp_s_1); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent = 0; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_knot; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_knot_idx; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable; + int __pyx_v_reverse; + PyObject *__pyx_v_label = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__parent,&__pyx_n_s__knot,&__pyx_n_s__knot_idx,&__pyx_n_s__variable,&__pyx_n_s__reverse,&__pyx_n_s__label,0}; + PyObject* values[6] = {0,0,0,0,0,0}; + + /* "sklearn/earth/_basis.pyx":334 + * + * #@DuplicatedSignature + * def __init__(self, BasisFunction parent, FLOAT_t knot, INDEX_t knot_idx, INDEX_t variable, bint reverse, label=None): # <<<<<<<<<<<<<< + * self.knot = knot + * self.knot_idx = knot_idx + */ + values[5] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__knot)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__knot_idx)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__variable)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reverse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__label); + if (value) { values[5] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_parent = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)values[0]); + __pyx_v_knot = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_knot == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_knot_idx = __Pyx_PyInt_from_py_npy_ulonglong(values[2]); if (unlikely((__pyx_v_knot_idx == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_variable = __Pyx_PyInt_from_py_npy_ulonglong(values[3]); if (unlikely((__pyx_v_variable == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_reverse = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_reverse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_label = values[5]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction, 1, "parent", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction___init__(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self), __pyx_v_parent, __pyx_v_knot, __pyx_v_knot_idx, __pyx_v_variable, __pyx_v_reverse, __pyx_v_label); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction___init__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_knot, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_knot_idx, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable, int __pyx_v_reverse, PyObject *__pyx_v_label) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_basis.pyx":335 + * #@DuplicatedSignature + * def __init__(self, BasisFunction parent, FLOAT_t knot, INDEX_t knot_idx, INDEX_t variable, bint reverse, label=None): + * self.knot = knot # <<<<<<<<<<<<<< + * self.knot_idx = knot_idx + * self.variable = variable + */ + __pyx_v_self->knot = __pyx_v_knot; + + /* "sklearn/earth/_basis.pyx":336 + * def __init__(self, BasisFunction parent, FLOAT_t knot, INDEX_t knot_idx, INDEX_t variable, bint reverse, label=None): + * self.knot = knot + * self.knot_idx = knot_idx # <<<<<<<<<<<<<< + * self.variable = variable + * self.reverse = reverse + */ + __pyx_v_self->knot_idx = __pyx_v_knot_idx; + + /* "sklearn/earth/_basis.pyx":337 + * self.knot = knot + * self.knot_idx = knot_idx + * self.variable = variable # <<<<<<<<<<<<<< + * self.reverse = reverse + * self.label = label if label is not None else 'x' + str(variable) + */ + __pyx_v_self->variable = __pyx_v_variable; + + /* "sklearn/earth/_basis.pyx":338 + * self.knot_idx = knot_idx + * self.variable = variable + * self.reverse = reverse # <<<<<<<<<<<<<< + * self.label = label if label is not None else 'x' + str(variable) + * self._set_parent(parent) + */ + __pyx_v_self->reverse = __pyx_v_reverse; + + /* "sklearn/earth/_basis.pyx":339 + * self.variable = variable + * self.reverse = reverse + * self.label = label if label is not None else 'x' + str(variable) # <<<<<<<<<<<<<< + * self._set_parent(parent) + * + */ + __pyx_t_2 = (__pyx_v_label != Py_None); + if ((__pyx_t_2 != 0)) { + __Pyx_INCREF(__pyx_v_label); + __pyx_t_1 = __pyx_v_label; + } else { + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_n_s__x), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = __pyx_t_4; + __pyx_t_4 = 0; + } + if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->label); + __Pyx_DECREF(((PyObject *)__pyx_v_self->label)); + __pyx_v_self->label = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":340 + * self.reverse = reverse + * self.label = label if label is not None else 'x' + str(variable) + * self._set_parent(parent) # <<<<<<<<<<<<<< + * + * def __reduce__(self): + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), __pyx_v_parent, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_2__reduce__(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":342 + * self._set_parent(parent) + * + * def __reduce__(self): # <<<<<<<<<<<<<< + * return (self.__class__, (pickle_place_holder, 1.0, 1, 1, True, ''), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_basis.pyx":343 + * + * def __reduce__(self): + * return (self.__class__, (pickle_place_holder, 1.0, 1, 1, True, ''), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__pickle_place_holder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + PyTuple_SET_ITEM(__pyx_t_5, 5, ((PyObject *)__pyx_kp_s_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2)); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_5 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_4_getstate(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":345 + * return (self.__class__, (pickle_place_holder, 1.0, 1, 1, True, ''), self._getstate()) + * + * def _getstate(self): # <<<<<<<<<<<<<< + * result = super(HingeBasisFunction, self)._getstate() + * result.update({'knot': self.knot, + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_4_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_basis.pyx":346 + * + * def _getstate(self): + * result = super(HingeBasisFunction, self)._getstate() # <<<<<<<<<<<<<< + * result.update({'knot': self.knot, + * 'knot_idx': self.knot_idx, + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction))); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_2 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":347 + * def _getstate(self): + * result = super(HingeBasisFunction, self)._getstate() + * result.update({'knot': self.knot, # <<<<<<<<<<<<<< + * 'knot_idx': self.knot_idx, + * 'variable': self.variable, + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s__update); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->knot); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__knot), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":348 + * result = super(HingeBasisFunction, self)._getstate() + * result.update({'knot': self.knot, + * 'knot_idx': self.knot_idx, # <<<<<<<<<<<<<< + * 'variable': self.variable, + * 'reverse': self.reverse, + */ + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->knot_idx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__knot_idx), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":349 + * result.update({'knot': self.knot, + * 'knot_idx': self.knot_idx, + * 'variable': self.variable, # <<<<<<<<<<<<<< + * 'reverse': self.reverse, + * 'label': self.label}) + */ + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->variable); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__variable), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":350 + * 'knot_idx': self.knot_idx, + * 'variable': self.variable, + * 'reverse': self.reverse, # <<<<<<<<<<<<<< + * 'label': self.label}) + * return result + */ + __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->reverse); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__reverse), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":351 + * 'variable': self.variable, + * 'reverse': self.reverse, + * 'label': self.label}) # <<<<<<<<<<<<<< + * return result + * + */ + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__label), ((PyObject *)__pyx_v_self->label)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":352 + * 'reverse': self.reverse, + * 'label': self.label}) + * return result # <<<<<<<<<<<<<< + * + * def __setstate__(self, state): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_6__setstate__(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self), ((PyObject *)__pyx_v_state)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":354 + * return result + * + * def __setstate__(self, state): # <<<<<<<<<<<<<< + * self.knot = state['knot'] + * self.knot_idx = state['knot_idx'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_6__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_t_2; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_basis.pyx":355 + * + * def __setstate__(self, state): + * self.knot = state['knot'] # <<<<<<<<<<<<<< + * self.knot_idx = state['knot_idx'] + * self.variable = state['variable'] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__knot)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->knot = __pyx_t_2; + + /* "sklearn/earth/_basis.pyx":356 + * def __setstate__(self, state): + * self.knot = state['knot'] + * self.knot_idx = state['knot_idx'] # <<<<<<<<<<<<<< + * self.variable = state['variable'] + * self.reverse = state['reverse'] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__knot_idx)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->knot_idx = __pyx_t_3; + + /* "sklearn/earth/_basis.pyx":357 + * self.knot = state['knot'] + * self.knot_idx = state['knot_idx'] + * self.variable = state['variable'] # <<<<<<<<<<<<<< + * self.reverse = state['reverse'] + * self.label = state['label'] + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__variable)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->variable = __pyx_t_3; + + /* "sklearn/earth/_basis.pyx":358 + * self.knot_idx = state['knot_idx'] + * self.variable = state['variable'] + * self.reverse = state['reverse'] # <<<<<<<<<<<<<< + * self.label = state['label'] + * super(HingeBasisFunction, self).__setstate__(state) + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__reverse)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->reverse = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":359 + * self.variable = state['variable'] + * self.reverse = state['reverse'] + * self.label = state['label'] # <<<<<<<<<<<<<< + * super(HingeBasisFunction, self).__setstate__(state) + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__label)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->label); + __Pyx_DECREF(((PyObject *)__pyx_v_self->label)); + __pyx_v_self->label = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":360 + * self.reverse = state['reverse'] + * self.label = state['label'] + * super(HingeBasisFunction, self).__setstate__(state) # <<<<<<<<<<<<<< + * + * cpdef bint has_knot(HingeBasisFunction self): + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction))); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_5 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s____setstate__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_state); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_state); + __Pyx_GIVEREF(__pyx_v_state); + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":362 + * super(HingeBasisFunction, self).__setstate__(state) + * + * cpdef bint has_knot(HingeBasisFunction self): # <<<<<<<<<<<<<< + * return True + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_9has_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_has_knot(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("has_knot", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__has_knot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_9has_knot)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":363 + * + * cpdef bint has_knot(HingeBasisFunction self): + * return True # <<<<<<<<<<<<<< + * + * cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + */ + __pyx_r = 1; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.HingeBasisFunction.has_knot", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_9has_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_9has_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("has_knot (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_8has_knot(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":362 + * super(HingeBasisFunction, self).__setstate__(state) + * + * cpdef bint has_knot(HingeBasisFunction self): # <<<<<<<<<<<<<< + * return True + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_8has_knot(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("has_knot", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.has_knot(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.has_knot", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":365 + * return True + * + * cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): # <<<<<<<<<<<<<< + * self.knot = slopes[self.variable] * \ + * self.knot + intercepts[self.variable] + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_11translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_translate(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_v_recurse, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_6; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__translate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_11translate)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_recurse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":366 + * + * cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + * self.knot = slopes[self.variable] * \ # <<<<<<<<<<<<<< + * self.knot + intercepts[self.variable] + * if slopes[self.variable] < 0: + */ + __pyx_t_4 = __pyx_v_self->variable; + + /* "sklearn/earth/_basis.pyx":367 + * cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + * self.knot = slopes[self.variable] * \ + * self.knot + intercepts[self.variable] # <<<<<<<<<<<<<< + * if slopes[self.variable] < 0: + * self.reverse = not self.reverse + */ + __pyx_t_5 = __pyx_v_self->variable; + + /* "sklearn/earth/_basis.pyx":366 + * + * cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + * self.knot = slopes[self.variable] * \ # <<<<<<<<<<<<<< + * self.knot + intercepts[self.variable] + * if slopes[self.variable] < 0: + */ + __pyx_v_self->knot = (((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_slopes.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_slopes.diminfo[0].strides)) * __pyx_v_self->knot) + (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_intercepts.diminfo[0].strides))); + + /* "sklearn/earth/_basis.pyx":368 + * self.knot = slopes[self.variable] * \ + * self.knot + intercepts[self.variable] + * if slopes[self.variable] < 0: # <<<<<<<<<<<<<< + * self.reverse = not self.reverse + * if recurse: + */ + __pyx_t_6 = __pyx_v_self->variable; + __pyx_t_7 = (((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_slopes.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_slopes.diminfo[0].strides)) < 0.0) != 0); + if (__pyx_t_7) { + + /* "sklearn/earth/_basis.pyx":369 + * self.knot + intercepts[self.variable] + * if slopes[self.variable] < 0: + * self.reverse = not self.reverse # <<<<<<<<<<<<<< + * if recurse: + * self.parent.translate(slopes, intercepts) + */ + __pyx_v_self->reverse = (!(__pyx_v_self->reverse != 0)); + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_basis.pyx":370 + * if slopes[self.variable] < 0: + * self.reverse = not self.reverse + * if recurse: # <<<<<<<<<<<<<< + * self.parent.translate(slopes, intercepts) + * + */ + __pyx_t_7 = (__pyx_v_recurse != 0); + if (__pyx_t_7) { + + /* "sklearn/earth/_basis.pyx":371 + * self.reverse = not self.reverse + * if recurse: + * self.parent.translate(slopes, intercepts) # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t scale(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.parent), __pyx_n_s__translate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L4; + } + __pyx_L4:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_11translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_11translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + int __pyx_v_recurse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("translate (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,&__pyx_n_s__recurse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__recurse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __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_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + __pyx_v_recurse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_recurse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_10translate(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self), __pyx_v_slopes, __pyx_v_intercepts, __pyx_v_recurse); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":365 + * return True + * + * cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): # <<<<<<<<<<<<<< + * self.knot = slopes[self.variable] * \ + * self.knot + intercepts[self.variable] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_10translate(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_v_recurse) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->translate(__pyx_v_self, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), __pyx_v_recurse, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":373 + * self.parent.translate(slopes, intercepts) + * + * cpdef FLOAT_t scale(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_13scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_scale(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_skip_dispatch) { + PyObject *__pyx_v_result = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__scale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_13scale)) { + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":374 + * + * cpdef FLOAT_t scale(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + * result = self.parent.scale(slopes, intercepts) # <<<<<<<<<<<<<< + * result /= slopes[self.variable] + * return result + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.parent), __pyx_n_s__scale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":375 + * cpdef FLOAT_t scale(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_5 = __pyx_v_self->variable; + __pyx_t_2 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_slopes.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_slopes.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3); + __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":376 + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] + * return result # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_result); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_t_4; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_WriteUnraisable("sklearn.earth._basis.HingeBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_13scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_13scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("scale (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("scale", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scale") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("scale", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_12scale(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self), __pyx_v_slopes, __pyx_v_intercepts); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":373 + * self.parent.translate(slopes, intercepts) + * + * cpdef FLOAT_t scale(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_12scale(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->scale(__pyx_v_self, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_15__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_15__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_14__str__(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":378 + * return result + * + * def __str__(self): # <<<<<<<<<<<<<< + * result = '' + * if self.variable is not None: + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_14__str__(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_parent = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_basis.pyx":379 + * + * def __str__(self): + * result = '' # <<<<<<<<<<<<<< + * if self.variable is not None: + * if not self.reverse: + */ + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + __pyx_v_result = ((PyObject *)__pyx_kp_s_2); + + /* "sklearn/earth/_basis.pyx":380 + * def __str__(self): + * result = '' + * if self.variable is not None: # <<<<<<<<<<<<<< + * if not self.reverse: + * if self.knot >= 0: + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = (__pyx_t_1 != Py_None); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "sklearn/earth/_basis.pyx":381 + * result = '' + * if self.variable is not None: + * if not self.reverse: # <<<<<<<<<<<<<< + * if self.knot >= 0: + * result = 'h(%s-%G)' % (self.label, self.knot) + */ + __pyx_t_3 = ((!(__pyx_v_self->reverse != 0)) != 0); + if (__pyx_t_3) { + + /* "sklearn/earth/_basis.pyx":382 + * if self.variable is not None: + * if not self.reverse: + * if self.knot >= 0: # <<<<<<<<<<<<<< + * result = 'h(%s-%G)' % (self.label, self.knot) + * else: + */ + __pyx_t_3 = ((__pyx_v_self->knot >= 0.0) != 0); + if (__pyx_t_3) { + + /* "sklearn/earth/_basis.pyx":383 + * if not self.reverse: + * if self.knot >= 0: + * result = 'h(%s-%G)' % (self.label, self.knot) # <<<<<<<<<<<<<< + * else: + * result = 'h(%s+%G)' % (self.label, -self.knot) + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->knot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_self->label)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->label)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->label)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + goto __pyx_L5; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":385 + * result = 'h(%s-%G)' % (self.label, self.knot) + * else: + * result = 'h(%s+%G)' % (self.label, -self.knot) # <<<<<<<<<<<<<< + * else: + * result = 'h(%G-%s)' % (self.knot, self.label) + */ + __pyx_t_1 = PyFloat_FromDouble((-__pyx_v_self->knot)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_self->label)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->label)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->label)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + } + __pyx_L5:; + goto __pyx_L4; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":387 + * result = 'h(%s+%G)' % (self.label, -self.knot) + * else: + * result = 'h(%G-%s)' % (self.knot, self.label) # <<<<<<<<<<<<<< + * parent = str( + * self.parent) if not self.parent.__class__ is ConstantBasisFunction else '' + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->knot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self->label)); + PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self->label)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->label)); + __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + } + __pyx_L4:; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_basis.pyx":389 + * result = 'h(%G-%s)' % (self.knot, self.label) + * parent = str( + * self.parent) if not self.parent.__class__ is ConstantBasisFunction else '' # <<<<<<<<<<<<<< + * if parent != '': + * result += '*%s' % (str(self.parent),) + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.parent), __pyx_n_s____class__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = (__pyx_t_4 == ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction))); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (((!(__pyx_t_3 != 0)) != 0)) { + + /* "sklearn/earth/_basis.pyx":388 + * else: + * result = 'h(%G-%s)' % (self.knot, self.label) + * parent = str( # <<<<<<<<<<<<<< + * self.parent) if not self.parent.__class__ is ConstantBasisFunction else '' + * if parent != '': + */ + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.parent)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->__pyx_base.parent)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.parent)); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_1 = __pyx_t_5; + __pyx_t_5 = 0; + } else { + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + __pyx_t_1 = ((PyObject *)__pyx_kp_s_2); + } + __pyx_v_parent = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":390 + * parent = str( + * self.parent) if not self.parent.__class__ is ConstantBasisFunction else '' + * if parent != '': # <<<<<<<<<<<<<< + * result += '*%s' % (str(self.parent),) + * return result + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_parent, ((PyObject *)__pyx_kp_s_2), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_3) { + + /* "sklearn/earth/_basis.pyx":391 + * self.parent) if not self.parent.__class__ is ConstantBasisFunction else '' + * if parent != '': + * result += '*%s' % (str(self.parent),) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.parent)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->__pyx_base.parent)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.parent)); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L6; + } + __pyx_L6:; + + /* "sklearn/earth/_basis.pyx":392 + * if parent != '': + * result += '*%s' % (str(self.parent),) + * return result # <<<<<<<<<<<<<< + * + * cpdef INDEX_t get_variable(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_parent); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":394 + * return result + * + * cpdef INDEX_t get_variable(self): # <<<<<<<<<<<<<< + * return self.variable + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_17get_variable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_variable(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_variable", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_17get_variable)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":395 + * + * cpdef INDEX_t get_variable(self): + * return self.variable # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t get_knot(self): + */ + __pyx_r = __pyx_v_self->variable; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.HingeBasisFunction.get_variable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_17get_variable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_17get_variable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_variable (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_16get_variable(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":394 + * return result + * + * cpdef INDEX_t get_variable(self): # <<<<<<<<<<<<<< + * return self.variable + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_16get_variable(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_variable", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->get_variable(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.get_variable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":397 + * return self.variable + * + * cpdef FLOAT_t get_knot(self): # <<<<<<<<<<<<<< + * return self.knot + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_19get_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_knot(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_knot", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_knot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_19get_knot)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":398 + * + * cpdef FLOAT_t get_knot(self): + * return self.knot # <<<<<<<<<<<<<< + * + * cpdef bint get_reverse(self): + */ + __pyx_r = __pyx_v_self->knot; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.HingeBasisFunction.get_knot", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_19get_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_19get_knot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_knot (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_18get_knot(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":397 + * return self.variable + * + * cpdef FLOAT_t get_knot(self): # <<<<<<<<<<<<<< + * return self.knot + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_18get_knot(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_knot", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->get_knot(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.get_knot", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":400 + * return self.knot + * + * cpdef bint get_reverse(self): # <<<<<<<<<<<<<< + * return self.reverse + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_21get_reverse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_reverse(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_reverse", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_reverse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_21get_reverse)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":401 + * + * cpdef bint get_reverse(self): + * return self.reverse # <<<<<<<<<<<<<< + * + * cpdef INDEX_t get_knot_idx(self): + */ + __pyx_r = __pyx_v_self->reverse; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.HingeBasisFunction.get_reverse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_21get_reverse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_21get_reverse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_reverse (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_20get_reverse(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":400 + * return self.knot + * + * cpdef bint get_reverse(self): # <<<<<<<<<<<<<< + * return self.reverse + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_20get_reverse(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_reverse", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->get_reverse(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.get_reverse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":403 + * return self.reverse + * + * cpdef INDEX_t get_knot_idx(self): # <<<<<<<<<<<<<< + * return self.knot_idx + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_23get_knot_idx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_knot_idx(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_knot_idx", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_knot_idx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_23get_knot_idx)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":404 + * + * cpdef INDEX_t get_knot_idx(self): + * return self.knot_idx # <<<<<<<<<<<<<< + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): + */ + __pyx_r = __pyx_v_self->knot_idx; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.HingeBasisFunction.get_knot_idx", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_23get_knot_idx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_23get_knot_idx(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_knot_idx (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_22get_knot_idx(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":403 + * return self.reverse + * + * cpdef INDEX_t get_knot_idx(self): # <<<<<<<<<<<<<< + * return self.knot_idx + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_22get_knot_idx(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_knot_idx", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->get_knot_idx(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.get_knot_idx", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":406 + * return self.knot_idx + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_25apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_apply(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply *__pyx_optional_args) { + int __pyx_v_recurse = ((int)1); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_m; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_v_tmp; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply __pyx_t_5; + Py_ssize_t __pyx_t_6; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_7; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_8; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_9; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_10; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_11; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_12; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_13; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_14; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_recurse = __pyx_optional_args->recurse; + } + } + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__apply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_25apply)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_recurse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_INCREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_b)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":413 + * parent function. + * ''' + * if recurse: # <<<<<<<<<<<<<< + * self.parent.apply(X, b, recurse=True) + * cdef INDEX_t i # @DuplicatedSignature + */ + __pyx_t_4 = (__pyx_v_recurse != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_basis.pyx":414 + * ''' + * if recurse: + * self.parent.apply(X, b, recurse=True) # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t m = len(b) # @DuplicatedSignature + */ + __pyx_t_5.__pyx_n = 1; + __pyx_t_5.recurse = 1; + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_base.parent->__pyx_vtab)->apply(__pyx_v_self->__pyx_base.parent, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_b), 0, &__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_basis.pyx":416 + * self.parent.apply(X, b, recurse=True) + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t m = len(b) # @DuplicatedSignature # <<<<<<<<<<<<<< + * cdef FLOAT_t tmp + * if self.reverse: + */ + __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_b)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_m = __pyx_t_6; + + /* "sklearn/earth/_basis.pyx":418 + * cdef INDEX_t m = len(b) # @DuplicatedSignature + * cdef FLOAT_t tmp + * if self.reverse: # <<<<<<<<<<<<<< + * for i in range(m): + * tmp = self.knot - X[i, self.variable] + */ + __pyx_t_4 = (__pyx_v_self->reverse != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_basis.pyx":419 + * cdef FLOAT_t tmp + * if self.reverse: + * for i in range(m): # <<<<<<<<<<<<<< + * tmp = self.knot - X[i, self.variable] + * if tmp < 0: + */ + __pyx_t_7 = __pyx_v_m; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_i = __pyx_t_8; + + /* "sklearn/earth/_basis.pyx":420 + * if self.reverse: + * for i in range(m): + * tmp = self.knot - X[i, self.variable] # <<<<<<<<<<<<<< + * if tmp < 0: + * tmp = 0.0 + */ + __pyx_t_9 = __pyx_v_i; + __pyx_t_10 = __pyx_v_self->variable; + __pyx_v_tmp = (__pyx_v_self->knot - (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_10, __pyx_pybuffernd_X.diminfo[1].strides))); + + /* "sklearn/earth/_basis.pyx":421 + * for i in range(m): + * tmp = self.knot - X[i, self.variable] + * if tmp < 0: # <<<<<<<<<<<<<< + * tmp = 0.0 + * b[i] *= tmp + */ + __pyx_t_4 = ((__pyx_v_tmp < 0.0) != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_basis.pyx":422 + * tmp = self.knot - X[i, self.variable] + * if tmp < 0: + * tmp = 0.0 # <<<<<<<<<<<<<< + * b[i] *= tmp + * else: + */ + __pyx_v_tmp = ((__pyx_t_7sklearn_5earth_6_basis_FLOAT_t)0.0); + goto __pyx_L7; + } + __pyx_L7:; + + /* "sklearn/earth/_basis.pyx":423 + * if tmp < 0: + * tmp = 0.0 + * b[i] *= tmp # <<<<<<<<<<<<<< + * else: + * for i in range(m): + */ + __pyx_t_11 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_b.diminfo[0].strides) *= __pyx_v_tmp; + } + goto __pyx_L4; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":425 + * b[i] *= tmp + * else: + * for i in range(m): # <<<<<<<<<<<<<< + * tmp = X[i, self.variable] - self.knot + * if tmp < 0: + */ + __pyx_t_7 = __pyx_v_m; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_i = __pyx_t_8; + + /* "sklearn/earth/_basis.pyx":426 + * else: + * for i in range(m): + * tmp = X[i, self.variable] - self.knot # <<<<<<<<<<<<<< + * if tmp < 0: + * tmp = 0.0 + */ + __pyx_t_12 = __pyx_v_i; + __pyx_t_13 = __pyx_v_self->variable; + __pyx_v_tmp = ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_X.diminfo[1].strides)) - __pyx_v_self->knot); + + /* "sklearn/earth/_basis.pyx":427 + * for i in range(m): + * tmp = X[i, self.variable] - self.knot + * if tmp < 0: # <<<<<<<<<<<<<< + * tmp = 0.0 + * b[i] *= tmp + */ + __pyx_t_4 = ((__pyx_v_tmp < 0.0) != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_basis.pyx":428 + * tmp = X[i, self.variable] - self.knot + * if tmp < 0: + * tmp = 0.0 # <<<<<<<<<<<<<< + * b[i] *= tmp + * + */ + __pyx_v_tmp = ((__pyx_t_7sklearn_5earth_6_basis_FLOAT_t)0.0); + goto __pyx_L10; + } + __pyx_L10:; + + /* "sklearn/earth/_basis.pyx":429 + * if tmp < 0: + * tmp = 0.0 + * b[i] *= tmp # <<<<<<<<<<<<<< + * + * cdef class LinearBasisFunction(BasisFunction): + */ + __pyx_t_14 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_b.diminfo[0].strides) *= __pyx_v_tmp; + } + } + __pyx_L4:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_25apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_5earth_6_basis_18HingeBasisFunction_24apply[] = "\n X - Data matrix\n b - parent vector\n recurse - If False, assume b already contains the result of the parent function. Otherwise, recurse to compute\n parent function.\n "; +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_25apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_b = 0; + int __pyx_v_recurse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("apply (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__b,&__pyx_n_s__recurse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__recurse); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_X = ((PyArrayObject *)values[0]); + __pyx_v_b = ((PyArrayObject *)values[1]); + if (values[2]) { + __pyx_v_recurse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_recurse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "sklearn/earth/_basis.pyx":406 + * return self.knot_idx + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + __pyx_v_recurse = ((int)1); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_5numpy_ndarray, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_24apply(((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self), __pyx_v_X, __pyx_v_b, __pyx_v_recurse); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_18HingeBasisFunction_24apply(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.recurse = __pyx_v_recurse; + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.apply(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_b), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.HingeBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent = 0; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable; + PyObject *__pyx_v_label = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__parent,&__pyx_n_s__variable,&__pyx_n_s__label,0}; + PyObject* values[3] = {0,0,0}; + + /* "sklearn/earth/_basis.pyx":433 + * cdef class LinearBasisFunction(BasisFunction): + * #@DuplicatedSignature + * def __init__(self, BasisFunction parent, INDEX_t variable, label=None): # <<<<<<<<<<<<<< + * self.variable = variable + * self.label = label if label is not None else 'x' + str(variable) + */ + values[2] = ((PyObject *)Py_None); + 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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__variable)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__label); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_parent = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)values[0]); + __pyx_v_variable = __Pyx_PyInt_from_py_npy_ulonglong(values[1]); if (unlikely((__pyx_v_variable == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_label = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction, 1, "parent", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction___init__(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self), __pyx_v_parent, __pyx_v_variable, __pyx_v_label); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction___init__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_variable, PyObject *__pyx_v_label) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_basis.pyx":434 + * #@DuplicatedSignature + * def __init__(self, BasisFunction parent, INDEX_t variable, label=None): + * self.variable = variable # <<<<<<<<<<<<<< + * self.label = label if label is not None else 'x' + str(variable) + * self._set_parent(parent) + */ + __pyx_v_self->variable = __pyx_v_variable; + + /* "sklearn/earth/_basis.pyx":435 + * def __init__(self, BasisFunction parent, INDEX_t variable, label=None): + * self.variable = variable + * self.label = label if label is not None else 'x' + str(variable) # <<<<<<<<<<<<<< + * self._set_parent(parent) + * + */ + __pyx_t_2 = (__pyx_v_label != Py_None); + if ((__pyx_t_2 != 0)) { + __Pyx_INCREF(__pyx_v_label); + __pyx_t_1 = __pyx_v_label; + } else { + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_n_s__x), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = __pyx_t_4; + __pyx_t_4 = 0; + } + if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->label); + __Pyx_DECREF(((PyObject *)__pyx_v_self->label)); + __pyx_v_self->label = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":436 + * self.variable = variable + * self.label = label if label is not None else 'x' + str(variable) + * self._set_parent(parent) # <<<<<<<<<<<<<< + * + * def __reduce__(self): + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_parent(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), __pyx_v_parent, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_2__reduce__(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":438 + * self._set_parent(parent) + * + * def __reduce__(self): # <<<<<<<<<<<<<< + * return (self.__class__, (pickle_place_holder, 1, ''), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_basis.pyx":439 + * + * def __reduce__(self): + * return (self.__class__, (pickle_place_holder, 1, ''), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__pickle_place_holder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_kp_s_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2)); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_r = ((PyObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_4_getstate(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":441 + * return (self.__class__, (pickle_place_holder, 1, ''), self._getstate()) + * + * def _getstate(self): # <<<<<<<<<<<<<< + * result = super(LinearBasisFunction, self)._getstate() + * result.update({'variable': self.variable, + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_4_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_basis.pyx":442 + * + * def _getstate(self): + * result = super(LinearBasisFunction, self)._getstate() # <<<<<<<<<<<<<< + * result.update({'variable': self.variable, + * 'label': self.label}) + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction))); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_2 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":443 + * def _getstate(self): + * result = super(LinearBasisFunction, self)._getstate() + * result.update({'variable': self.variable, # <<<<<<<<<<<<<< + * 'label': self.label}) + * return result + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s__update); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->variable); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__variable), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":444 + * result = super(LinearBasisFunction, self)._getstate() + * result.update({'variable': self.variable, + * 'label': self.label}) # <<<<<<<<<<<<<< + * return result + * + */ + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__label), ((PyObject *)__pyx_v_self->label)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":445 + * result.update({'variable': self.variable, + * 'label': self.label}) + * return result # <<<<<<<<<<<<<< + * + * def __setstate__(self, state): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_6__setstate__(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self), ((PyObject *)__pyx_v_state)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":447 + * return result + * + * def __setstate__(self, state): # <<<<<<<<<<<<<< + * self.variable = state['variable'] + * self.label = state['label'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_6__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_basis.pyx":448 + * + * def __setstate__(self, state): + * self.variable = state['variable'] # <<<<<<<<<<<<<< + * self.label = state['label'] + * super(LinearBasisFunction, self).__setstate__(state) + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__variable)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->variable = __pyx_t_2; + + /* "sklearn/earth/_basis.pyx":449 + * def __setstate__(self, state): + * self.variable = state['variable'] + * self.label = state['label'] # <<<<<<<<<<<<<< + * super(LinearBasisFunction, self).__setstate__(state) + * + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__label)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->label); + __Pyx_DECREF(((PyObject *)__pyx_v_self->label)); + __pyx_v_self->label = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":450 + * self.variable = state['variable'] + * self.label = state['label'] + * super(LinearBasisFunction, self).__setstate__(state) # <<<<<<<<<<<<<< + * + * cpdef translate(LinearBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction))); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_3 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s____setstate__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_state); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_state); + __Pyx_GIVEREF(__pyx_v_state); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":452 + * super(LinearBasisFunction, self).__setstate__(state) + * + * cpdef translate(LinearBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): # <<<<<<<<<<<<<< + * pass + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_9translate(PyObject *__pyx_v_LinearBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_translate(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_LinearBasisFunctionself, CYTHON_UNUSED PyArrayObject *__pyx_v_slopes, CYTHON_UNUSED PyArrayObject *__pyx_v_intercepts, CYTHON_UNUSED int __pyx_v_recurse, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_LinearBasisFunctionself))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_LinearBasisFunctionself), __pyx_n_s__translate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_9translate)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_recurse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":453 + * + * cpdef translate(LinearBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + * pass # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t scale(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + */ + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_9translate(PyObject *__pyx_v_LinearBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_9translate(PyObject *__pyx_v_LinearBasisFunctionself, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + int __pyx_v_recurse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("translate (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,&__pyx_n_s__recurse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__recurse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __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_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + __pyx_v_recurse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_recurse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_8translate(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_LinearBasisFunctionself), __pyx_v_slopes, __pyx_v_intercepts, __pyx_v_recurse); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":452 + * super(LinearBasisFunction, self).__setstate__(state) + * + * cpdef translate(LinearBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): # <<<<<<<<<<<<<< + * pass + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_8translate(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_LinearBasisFunctionself, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_v_recurse) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_LinearBasisFunctionself->__pyx_base.__pyx_vtab)->translate(__pyx_v_LinearBasisFunctionself, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), __pyx_v_recurse, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":455 + * pass + * + * cpdef FLOAT_t scale(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_11scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_scale(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_skip_dispatch) { + PyObject *__pyx_v_result = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__scale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_11scale)) { + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":456 + * + * cpdef FLOAT_t scale(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + * result = self.parent.scale(slopes, intercepts) # <<<<<<<<<<<<<< + * result /= slopes[self.variable] + * return result + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.parent), __pyx_n_s__scale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":457 + * cpdef FLOAT_t scale(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_5 = __pyx_v_self->variable; + __pyx_t_2 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_slopes.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_slopes.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3); + __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":458 + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] + * return result # <<<<<<<<<<<<<< + * + * def __str__(LinearBasisFunction self): + */ + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_result); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_t_4; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_WriteUnraisable("sklearn.earth._basis.LinearBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_11scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_11scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("scale (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("scale", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scale") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("scale", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_10scale(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self), __pyx_v_slopes, __pyx_v_intercepts); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":455 + * pass + * + * cpdef FLOAT_t scale(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * result = self.parent.scale(slopes, intercepts) + * result /= slopes[self.variable] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_10scale(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->scale(__pyx_v_self, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_13__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_13__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_12__str__(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":460 + * return result + * + * def __str__(LinearBasisFunction self): # <<<<<<<<<<<<<< + * result = self.label + * if not self.parent.__class__ is ConstantBasisFunction: + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_12__str__(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_parent = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_basis.pyx":461 + * + * def __str__(LinearBasisFunction self): + * result = self.label # <<<<<<<<<<<<<< + * if not self.parent.__class__ is ConstantBasisFunction: + * parent = str(self.parent) + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->label); + __Pyx_INCREF(__pyx_t_1); + __pyx_v_result = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":462 + * def __str__(LinearBasisFunction self): + * result = self.label + * if not self.parent.__class__ is ConstantBasisFunction: # <<<<<<<<<<<<<< + * parent = str(self.parent) + * result += '*' + parent + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.parent), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = (__pyx_t_1 == ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction))); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0); + if (__pyx_t_3) { + + /* "sklearn/earth/_basis.pyx":463 + * result = self.label + * if not self.parent.__class__ is ConstantBasisFunction: + * parent = str(self.parent) # <<<<<<<<<<<<<< + * result += '*' + parent + * return result + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.parent)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->__pyx_base.parent)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.parent)); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_parent = __pyx_t_4; + __pyx_t_4 = 0; + + /* "sklearn/earth/_basis.pyx":464 + * if not self.parent.__class__ is ConstantBasisFunction: + * parent = str(self.parent) + * result += '*' + parent # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_kp_s_7), __pyx_v_parent); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_basis.pyx":465 + * parent = str(self.parent) + * result += '*' + parent + * return result # <<<<<<<<<<<<<< + * + * cpdef INDEX_t get_variable(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_parent); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":467 + * return result + * + * cpdef INDEX_t get_variable(self): # <<<<<<<<<<<<<< + * return self.variable + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_15get_variable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_get_variable(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_variable", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_15get_variable)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":468 + * + * cpdef INDEX_t get_variable(self): + * return self.variable # <<<<<<<<<<<<<< + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): + */ + __pyx_r = __pyx_v_self->variable; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.LinearBasisFunction.get_variable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_15get_variable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_15get_variable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_variable (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_14get_variable(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":467 + * return result + * + * cpdef INDEX_t get_variable(self): # <<<<<<<<<<<<<< + * return self.variable + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_14get_variable(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_variable", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->get_variable(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.get_variable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":470 + * return self.variable + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_17apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_apply(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply *__pyx_optional_args) { + int __pyx_v_recurse = ((int)1); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_m; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply __pyx_t_5; + Py_ssize_t __pyx_t_6; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_7; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_8; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_9; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_10; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_recurse = __pyx_optional_args->recurse; + } + } + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__apply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_17apply)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_recurse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_INCREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_b)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":477 + * parent function. + * ''' + * if recurse: # <<<<<<<<<<<<<< + * self.parent.apply(X, b, recurse=True) + * cdef INDEX_t i # @DuplicatedSignature + */ + __pyx_t_4 = (__pyx_v_recurse != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_basis.pyx":478 + * ''' + * if recurse: + * self.parent.apply(X, b, recurse=True) # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t m = len(b) # @DuplicatedSignature + */ + __pyx_t_5.__pyx_n = 1; + __pyx_t_5.recurse = 1; + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self->__pyx_base.parent->__pyx_vtab)->apply(__pyx_v_self->__pyx_base.parent, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_b), 0, &__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_basis.pyx":480 + * self.parent.apply(X, b, recurse=True) + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t m = len(b) # @DuplicatedSignature # <<<<<<<<<<<<<< + * for i in range(m): + * b[i] *= X[i, self.variable] + */ + __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_b)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_m = __pyx_t_6; + + /* "sklearn/earth/_basis.pyx":481 + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t m = len(b) # @DuplicatedSignature + * for i in range(m): # <<<<<<<<<<<<<< + * b[i] *= X[i, self.variable] + * + */ + __pyx_t_7 = __pyx_v_m; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_i = __pyx_t_8; + + /* "sklearn/earth/_basis.pyx":482 + * cdef INDEX_t m = len(b) # @DuplicatedSignature + * for i in range(m): + * b[i] *= X[i, self.variable] # <<<<<<<<<<<<<< + * + * cdef class Basis: + */ + __pyx_t_9 = __pyx_v_i; + __pyx_t_10 = __pyx_v_self->variable; + __pyx_t_11 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_b.diminfo[0].strides) *= (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_10, __pyx_pybuffernd_X.diminfo[1].strides)); + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_17apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_5earth_6_basis_19LinearBasisFunction_16apply[] = "\n X - Data matrix\n b - parent vector\n recurse - If False, assume b already contains the result of the parent function. Otherwise, recurse to compute\n parent function.\n "; +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_17apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_b = 0; + int __pyx_v_recurse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("apply (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__b,&__pyx_n_s__recurse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__recurse); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_X = ((PyArrayObject *)values[0]); + __pyx_v_b = ((PyArrayObject *)values[1]); + if (values[2]) { + __pyx_v_recurse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_recurse == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "sklearn/earth/_basis.pyx":470 + * return self.variable + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): # <<<<<<<<<<<<<< + * ''' + * X - Data matrix + */ + __pyx_v_recurse = ((int)1); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("apply", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_5numpy_ndarray, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_16apply(((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self), __pyx_v_X, __pyx_v_b, __pyx_v_recurse); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_19LinearBasisFunction_16apply(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_b, int __pyx_v_recurse) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)__pyx_v_b, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.recurse = __pyx_v_recurse; + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.apply(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_self), ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_b), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.LinearBasisFunction.apply", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_6_basis_5Basis_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_6_basis_5Basis_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_num_variables = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__num_variables,0}; + PyObject* values[1] = {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 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__num_variables)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_num_variables = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis___init__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), __pyx_v_num_variables); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":489 + * added.''' + * + * def __init__(Basis self, num_variables): # @DuplicatedSignature # <<<<<<<<<<<<<< + * self.order = [] + * self.num_variables = num_variables + */ + +static int __pyx_pf_7sklearn_5earth_6_basis_5Basis___init__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyObject *__pyx_v_num_variables) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_basis.pyx":490 + * + * def __init__(Basis self, num_variables): # @DuplicatedSignature + * self.order = [] # <<<<<<<<<<<<<< + * self.num_variables = num_variables + * + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __Pyx_GOTREF(__pyx_v_self->order); + __Pyx_DECREF(((PyObject *)__pyx_v_self->order)); + __pyx_v_self->order = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":491 + * def __init__(Basis self, num_variables): # @DuplicatedSignature + * self.order = [] + * self.num_variables = num_variables # <<<<<<<<<<<<<< + * + * def __reduce__(self): + */ + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_num_variables); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->num_variables = __pyx_t_2; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_2__reduce__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":493 + * self.num_variables = num_variables + * + * def __reduce__(self): # <<<<<<<<<<<<<< + * return (self.__class__, (self.num_variables,), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_2__reduce__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_basis.pyx":494 + * + * def __reduce__(self): + * return (self.__class__, (self.num_variables,), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->num_variables); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_r = ((PyObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_4_getstate(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":496 + * return (self.__class__, (self.num_variables,), self._getstate()) + * + * def _getstate(self): # <<<<<<<<<<<<<< + * return {'order': self.order} + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_4_getstate(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_basis.pyx":497 + * + * def _getstate(self): + * return {'order': self.order} # <<<<<<<<<<<<<< + * + * def __setstate__(self, state): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_v_self->order)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_6__setstate__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), ((PyObject *)__pyx_v_state)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":499 + * return {'order': self.order} + * + * def __setstate__(self, state): # <<<<<<<<<<<<<< + * self.order = state['order'] + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_6__setstate__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_basis.pyx":500 + * + * def __setstate__(self, state): + * self.order = state['order'] # <<<<<<<<<<<<<< + * + * def __richcmp__(self, other, method): + */ + __pyx_t_1 = PyObject_GetItem(__pyx_v_state, ((PyObject *)__pyx_n_s__order)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->order); + __Pyx_DECREF(((PyObject *)__pyx_v_self->order)); + __pyx_v_self->order = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method) { + PyObject *__pyx_v_method = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); + __pyx_v_method = PyInt_FromLong(__pyx_arg_method); if (unlikely(!__pyx_v_method)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_GOTREF(__pyx_v_method); + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_8__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((PyObject *)__pyx_v_method)); + __Pyx_XDECREF(__pyx_v_method); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":502 + * self.order = state['order'] + * + * def __richcmp__(self, other, method): # <<<<<<<<<<<<<< + * if method == 2: + * return self._eq(other) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_8__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__richcmp__", 0); + + /* "sklearn/earth/_basis.pyx":503 + * + * def __richcmp__(self, other, method): + * if method == 2: # <<<<<<<<<<<<<< + * return self._eq(other) + * elif method == 3: + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, __pyx_int_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_basis.pyx":504 + * def __richcmp__(self, other, method): + * if method == 2: + * return self._eq(other) # <<<<<<<<<<<<<< + * elif method == 3: + * return not self._eq(other) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + + /* "sklearn/earth/_basis.pyx":505 + * if method == 2: + * return self._eq(other) + * elif method == 3: # <<<<<<<<<<<<<< + * return not self._eq(other) + * else: + */ + __pyx_t_4 = PyObject_RichCompare(__pyx_v_method, __pyx_int_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_basis.pyx":506 + * return self._eq(other) + * elif method == 3: + * return not self._eq(other) # <<<<<<<<<<<<<< + * else: + * return NotImplemented + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_basis.pyx":508 + * return not self._eq(other) + * else: + * return NotImplemented # <<<<<<<<<<<<<< + * + * def _eq(self, other): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_builtin_NotImplemented); + __pyx_r = __pyx_builtin_NotImplemented; + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_11_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_11_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_eq (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_10_eq(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), ((PyObject *)__pyx_v_other)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":510 + * return NotImplemented + * + * def _eq(self, other): # <<<<<<<<<<<<<< + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_10_eq(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_eq", 0); + + /* "sklearn/earth/_basis.pyx":511 + * + * def _eq(self, other): + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() # <<<<<<<<<<<<<< + * + * def piter(Basis self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s____class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = (__pyx_t_1 == __pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_3) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_5 = __pyx_t_2; + __pyx_t_2 = 0; + } + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._basis.Basis._eq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_7sklearn_5earth_6_basis_5Basis_14generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_13piter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_13piter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("piter (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_12piter(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":513 + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + * def piter(Basis self): # <<<<<<<<<<<<<< + * for bf in self.order: + * if not bf.is_pruned(): + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_12piter(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("piter", 0); + __pyx_cur_scope = (struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *)__pyx_tp_new_7sklearn_5earth_6_basis___pyx_scope_struct__piter(__pyx_ptype_7sklearn_5earth_6_basis___pyx_scope_struct__piter, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_7sklearn_5earth_6_basis_5Basis_14generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.piter", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_7sklearn_5earth_6_basis_5Basis_14generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *__pyx_cur_scope = ((struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L7_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_basis.pyx":514 + * + * def piter(Basis self): + * for bf in self.order: # <<<<<<<<<<<<<< + * if not bf.is_pruned(): + * yield bf + */ + if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_self->order) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->order); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_bf); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_bf, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":515 + * def piter(Basis self): + * for bf in self.order: + * if not bf.is_pruned(): # <<<<<<<<<<<<<< + * yield bf + * + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_bf, __pyx_n_s__is_pruned); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = ((!__pyx_t_5) != 0); + if (__pyx_t_6) { + + /* "sklearn/earth/_basis.pyx":516 + * for bf in self.order: + * if not bf.is_pruned(): + * yield bf # <<<<<<<<<<<<<< + * + * def __str__(Basis self): + */ + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_bf); + __pyx_r = __pyx_cur_scope->__pyx_v_bf; + __Pyx_XGIVEREF(__pyx_t_1); + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L7_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_cur_scope->__pyx_t_0 = 0; + __Pyx_XGOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("piter", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); + __pyx_generator->resume_label = -1; + __Pyx_Generator_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return NULL; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_16__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_16__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_15__str__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":518 + * yield bf + * + * def __str__(Basis self): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t n = len(self) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_15__str__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_2; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_basis.pyx":520 + * def __str__(Basis self): + * cdef INDEX_t i + * cdef INDEX_t n = len(self) # <<<<<<<<<<<<<< + * result = '' + * for i in range(n): + */ + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_n = __pyx_t_1; + + /* "sklearn/earth/_basis.pyx":521 + * cdef INDEX_t i + * cdef INDEX_t n = len(self) + * result = '' # <<<<<<<<<<<<<< + * for i in range(n): + * result += str(self[i]) + */ + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + __pyx_v_result = ((PyObject *)__pyx_kp_s_2); + + /* "sklearn/earth/_basis.pyx":522 + * cdef INDEX_t n = len(self) + * result = '' + * for i in range(n): # <<<<<<<<<<<<<< + * result += str(self[i]) + * result += '\n' + */ + __pyx_t_2 = __pyx_v_n; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "sklearn/earth/_basis.pyx":523 + * result = '' + * for i in range(n): + * result += str(self[i]) # <<<<<<<<<<<<<< + * result += '\n' + * return result + */ + __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self), __pyx_v_i, sizeof(__pyx_t_7sklearn_5earth_6_basis_INDEX_t)+1, __Pyx_PyInt_to_py_npy_ulonglong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_5); + __pyx_t_5 = 0; + + /* "sklearn/earth/_basis.pyx":524 + * for i in range(n): + * result += str(self[i]) + * result += '\n' # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_kp_s_8)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_5); + __pyx_t_5 = 0; + } + + /* "sklearn/earth/_basis.pyx":525 + * result += str(self[i]) + * result += '\n' + * return result # <<<<<<<<<<<<<< + * + * cpdef translate(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":527 + * return result + * + * cpdef translate(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * cdef INDEX_t n = len(self) + * cdef INDEX_t i # @DuplicatedSignature + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_18translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_5Basis_translate(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__translate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_18translate)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":528 + * + * cpdef translate(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + * cdef INDEX_t n = len(self) # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * for i in range(n): + */ + __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_n = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":530 + * cdef INDEX_t n = len(self) + * cdef INDEX_t i # @DuplicatedSignature + * for i in range(n): # <<<<<<<<<<<<<< + * self.order[i].translate(slopes, intercepts, False) + * + */ + __pyx_t_5 = __pyx_v_n; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "sklearn/earth/_basis.pyx":531 + * cdef INDEX_t i # @DuplicatedSignature + * for i in range(n): + * self.order[i].translate(slopes, intercepts, False) # <<<<<<<<<<<<<< + * + * cpdef scale(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, cnp.ndarray[FLOAT_t, ndim=1] beta): + */ + if (unlikely(((PyObject *)__pyx_v_self->order) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i), __pyx_n_s__translate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_18translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_18translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("translate (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("translate", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("translate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_17translate(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), __pyx_v_slopes, __pyx_v_intercepts); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":527 + * return result + * + * cpdef translate(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): # <<<<<<<<<<<<<< + * cdef INDEX_t n = len(self) + * cdef INDEX_t i # @DuplicatedSignature + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_17translate(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("translate", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->translate(__pyx_v_self, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":533 + * self.order[i].translate(slopes, intercepts, False) + * + * cpdef scale(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, cnp.ndarray[FLOAT_t, ndim=1] beta): # <<<<<<<<<<<<<< + * cdef INDEX_t n = len(self) # @DuplicatedSignature + * cdef INDEX_t i # @DuplicatedSignature + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_20scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_5Basis_scale(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, PyArrayObject *__pyx_v_beta, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_j; + __Pyx_LocalBuf_ND __pyx_pybuffernd_beta; + __Pyx_Buffer __pyx_pybuffer_beta; + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_6; + int __pyx_t_7; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t __pyx_t_8; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + __pyx_pybuffer_beta.pybuffer.buf = NULL; + __pyx_pybuffer_beta.refcount = 0; + __pyx_pybuffernd_beta.data = NULL; + __pyx_pybuffernd_beta.rcbuffer = &__pyx_pybuffer_beta; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_beta.rcbuffer->pybuffer, (PyObject*)__pyx_v_beta, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_beta.diminfo[0].strides = __pyx_pybuffernd_beta.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_beta.diminfo[0].shape = __pyx_pybuffernd_beta.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__scale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_20scale)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __Pyx_INCREF(((PyObject *)__pyx_v_beta)); + PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_beta)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_beta)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":534 + * + * cpdef scale(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, cnp.ndarray[FLOAT_t, ndim=1] beta): + * cdef INDEX_t n = len(self) # @DuplicatedSignature # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t j = 0 + */ + __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_n = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":536 + * cdef INDEX_t n = len(self) # @DuplicatedSignature + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t j = 0 # <<<<<<<<<<<<<< + * for i in range(n): + * if self.order[i].is_pruned(): + */ + __pyx_v_j = 0; + + /* "sklearn/earth/_basis.pyx":537 + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t j = 0 + * for i in range(n): # <<<<<<<<<<<<<< + * if self.order[i].is_pruned(): + * continue + */ + __pyx_t_5 = __pyx_v_n; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "sklearn/earth/_basis.pyx":538 + * cdef INDEX_t j = 0 + * for i in range(n): + * if self.order[i].is_pruned(): # <<<<<<<<<<<<<< + * continue + * beta[j] *= self.order[i].scale(slopes, intercepts) + */ + if (unlikely(((PyObject *)__pyx_v_self->order) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i), __pyx_n_s__is_pruned); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + + /* "sklearn/earth/_basis.pyx":539 + * for i in range(n): + * if self.order[i].is_pruned(): + * continue # <<<<<<<<<<<<<< + * beta[j] *= self.order[i].scale(slopes, intercepts) + * j += 1 + */ + goto __pyx_L3_continue; + goto __pyx_L5; + } + __pyx_L5:; + + /* "sklearn/earth/_basis.pyx":540 + * if self.order[i].is_pruned(): + * continue + * beta[j] *= self.order[i].scale(slopes, intercepts) # <<<<<<<<<<<<<< + * j += 1 + * + */ + if (unlikely(((PyObject *)__pyx_v_self->order) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i), __pyx_n_s__scale); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_slopes)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_slopes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_slopes)); + __Pyx_INCREF(((PyObject *)__pyx_v_intercepts)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_intercepts)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_intercepts)); + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_9 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_6_basis_FLOAT_t *, __pyx_pybuffernd_beta.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_beta.diminfo[0].strides) *= __pyx_t_8; + + /* "sklearn/earth/_basis.pyx":541 + * continue + * beta[j] *= self.order[i].scale(slopes, intercepts) + * j += 1 # <<<<<<<<<<<<<< + * + * cpdef BasisFunction get_root(Basis self): + */ + __pyx_v_j = (__pyx_v_j + 1); + __pyx_L3_continue:; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_beta.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_beta.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_20scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_20scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_slopes = 0; + PyArrayObject *__pyx_v_intercepts = 0; + PyArrayObject *__pyx_v_beta = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("scale (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__slopes,&__pyx_n_s__intercepts,&__pyx_n_s__beta,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slopes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intercepts)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("scale", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__beta)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("scale", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scale") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __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_slopes = ((PyArrayObject *)values[0]); + __pyx_v_intercepts = ((PyArrayObject *)values[1]); + __pyx_v_beta = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("scale", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slopes), __pyx_ptype_5numpy_ndarray, 1, "slopes", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intercepts), __pyx_ptype_5numpy_ndarray, 1, "intercepts", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_beta), __pyx_ptype_5numpy_ndarray, 1, "beta", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_19scale(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), __pyx_v_slopes, __pyx_v_intercepts, __pyx_v_beta); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":533 + * self.order[i].translate(slopes, intercepts, False) + * + * cpdef scale(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, cnp.ndarray[FLOAT_t, ndim=1] beta): # <<<<<<<<<<<<<< + * cdef INDEX_t n = len(self) # @DuplicatedSignature + * cdef INDEX_t i # @DuplicatedSignature + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_19scale(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_slopes, PyArrayObject *__pyx_v_intercepts, PyArrayObject *__pyx_v_beta) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_beta; + __Pyx_Buffer __pyx_pybuffer_beta; + __Pyx_LocalBuf_ND __pyx_pybuffernd_intercepts; + __Pyx_Buffer __pyx_pybuffer_intercepts; + __Pyx_LocalBuf_ND __pyx_pybuffernd_slopes; + __Pyx_Buffer __pyx_pybuffer_slopes; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("scale", 0); + __pyx_pybuffer_slopes.pybuffer.buf = NULL; + __pyx_pybuffer_slopes.refcount = 0; + __pyx_pybuffernd_slopes.data = NULL; + __pyx_pybuffernd_slopes.rcbuffer = &__pyx_pybuffer_slopes; + __pyx_pybuffer_intercepts.pybuffer.buf = NULL; + __pyx_pybuffer_intercepts.refcount = 0; + __pyx_pybuffernd_intercepts.data = NULL; + __pyx_pybuffernd_intercepts.rcbuffer = &__pyx_pybuffer_intercepts; + __pyx_pybuffer_beta.pybuffer.buf = NULL; + __pyx_pybuffer_beta.refcount = 0; + __pyx_pybuffernd_beta.data = NULL; + __pyx_pybuffernd_beta.rcbuffer = &__pyx_pybuffer_beta; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer, (PyObject*)__pyx_v_slopes, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_slopes.diminfo[0].strides = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_slopes.diminfo[0].shape = __pyx_pybuffernd_slopes.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer, (PyObject*)__pyx_v_intercepts, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_intercepts.diminfo[0].strides = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_intercepts.diminfo[0].shape = __pyx_pybuffernd_intercepts.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_beta.rcbuffer->pybuffer, (PyObject*)__pyx_v_beta, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_beta.diminfo[0].strides = __pyx_pybuffernd_beta.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_beta.diminfo[0].shape = __pyx_pybuffernd_beta.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->scale(__pyx_v_self, ((PyArrayObject *)__pyx_v_slopes), ((PyArrayObject *)__pyx_v_intercepts), ((PyArrayObject *)__pyx_v_beta), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_beta.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.scale", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_beta.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_intercepts.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_slopes.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":543 + * j += 1 + * + * cpdef BasisFunction get_root(Basis self): # <<<<<<<<<<<<<< + * return self.root + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_22get_root(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_f_7sklearn_5earth_6_basis_5Basis_get_root(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_root", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_root); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_22get_root)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":544 + * + * cpdef BasisFunction get_root(Basis self): + * return self.root # <<<<<<<<<<<<<< + * + * cpdef append(Basis self, BasisFunction basis_function): + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__root); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.get_root", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_22get_root(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_22get_root(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_root (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_21get_root(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":543 + * j += 1 + * + * cpdef BasisFunction get_root(Basis self): # <<<<<<<<<<<<<< + * return self.root + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_21get_root(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_root", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->get_root(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.get_root", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":546 + * return self.root + * + * cpdef append(Basis self, BasisFunction basis_function): # <<<<<<<<<<<<<< + * self.order.append(basis_function) + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_24append(PyObject *__pyx_v_self, PyObject *__pyx_v_basis_function); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_5Basis_append(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_basis_function, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("append", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__append); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_24append)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_basis_function)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_basis_function)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_basis_function)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":547 + * + * cpdef append(Basis self, BasisFunction basis_function): + * self.order.append(basis_function) # <<<<<<<<<<<<<< + * + * def __iter__(Basis self): + */ + if (unlikely(((PyObject *)__pyx_v_self->order) == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->order, ((PyObject *)__pyx_v_basis_function)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.append", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_24append(PyObject *__pyx_v_self, PyObject *__pyx_v_basis_function); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_24append(PyObject *__pyx_v_self, PyObject *__pyx_v_basis_function) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("append (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_basis_function), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction, 1, "basis_function", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_23append(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_basis_function)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":546 + * return self.root + * + * cpdef append(Basis self, BasisFunction basis_function): # <<<<<<<<<<<<<< + * self.order.append(basis_function) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_23append(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_basis_function) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("append", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->append(__pyx_v_self, __pyx_v_basis_function, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.append", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_26__iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_26__iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_25__iter__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":549 + * self.order.append(basis_function) + * + * def __iter__(Basis self): # <<<<<<<<<<<<<< + * return self.order.__iter__() + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_25__iter__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__iter__", 0); + + /* "sklearn/earth/_basis.pyx":550 + * + * def __iter__(Basis self): + * return self.order.__iter__() # <<<<<<<<<<<<<< + * + * def __len__(Basis self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->order), __pyx_n_s____iter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static Py_ssize_t __pyx_pw_7sklearn_5earth_6_basis_5Basis_28__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_7sklearn_5earth_6_basis_5Basis_28__len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_27__len__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":552 + * return self.order.__iter__() + * + * def __len__(Basis self): # <<<<<<<<<<<<<< + * return self.order.__len__() + * + */ + +static Py_ssize_t __pyx_pf_7sklearn_5earth_6_basis_5Basis_27__len__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__len__", 0); + + /* "sklearn/earth/_basis.pyx":553 + * + * def __len__(Basis self): + * return self.order.__len__() # <<<<<<<<<<<<<< + * + * cpdef BasisFunction get(Basis self, INDEX_t i): + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->order), __pyx_n_s____len__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":555 + * return self.order.__len__() + * + * cpdef BasisFunction get(Basis self, INDEX_t i): # <<<<<<<<<<<<<< + * return self.order[i] + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_30get(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/ +static struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_f_7sklearn_5earth_6_basis_5Basis_get(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_30get)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":556 + * + * cpdef BasisFunction get(Basis self, INDEX_t i): + * return self.order[i] # <<<<<<<<<<<<<< + * + * def __getitem__(Basis self, INDEX_t i): + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + if (unlikely(((PyObject *)__pyx_v_self->order) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i)); + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i)); + goto __pyx_L0; + + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.get", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_30get(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_30get(PyObject *__pyx_v_self, PyObject *__pyx_arg_i) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get (wrapper)", 0); + assert(__pyx_arg_i); { + __pyx_v_i = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_i); if (unlikely((__pyx_v_i == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.get", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_29get(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_6_basis_INDEX_t)__pyx_v_i)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":555 + * return self.order.__len__() + * + * cpdef BasisFunction get(Basis self, INDEX_t i): # <<<<<<<<<<<<<< + * return self.order[i] + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_29get(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, __pyx_v_i, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.get", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_32__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_32__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_i) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_i); { + __pyx_v_i = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_i); if (unlikely((__pyx_v_i == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_31__getitem__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_6_basis_INDEX_t)__pyx_v_i)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":558 + * return self.order[i] + * + * def __getitem__(Basis self, INDEX_t i): # <<<<<<<<<<<<<< + * return self.get(i) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_31__getitem__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "sklearn/earth/_basis.pyx":559 + * + * def __getitem__(Basis self, INDEX_t i): + * return self.get(i) # <<<<<<<<<<<<<< + * + * cpdef INDEX_t plen(Basis self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->get(__pyx_v_self, __pyx_v_i, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":561 + * return self.get(i) + * + * cpdef INDEX_t plen(Basis self): # <<<<<<<<<<<<<< + * cdef INDEX_t length = 0 + * cdef INDEX_t i + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_34plen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_f_7sklearn_5earth_6_basis_5Basis_plen(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_length; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_3; + Py_ssize_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("plen", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__plen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_34plen)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":562 + * + * cpdef INDEX_t plen(Basis self): + * cdef INDEX_t length = 0 # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t n = len(self.order) + */ + __pyx_v_length = 0; + + /* "sklearn/earth/_basis.pyx":564 + * cdef INDEX_t length = 0 + * cdef INDEX_t i + * cdef INDEX_t n = len(self.order) # <<<<<<<<<<<<<< + * for i in range(n): + * if not self.order[i].is_pruned(): + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->order); + __Pyx_INCREF(__pyx_t_1); + if (unlikely(__pyx_t_1 == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_n = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":565 + * cdef INDEX_t i + * cdef INDEX_t n = len(self.order) + * for i in range(n): # <<<<<<<<<<<<<< + * if not self.order[i].is_pruned(): + * length += 1 + */ + __pyx_t_3 = __pyx_v_n; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "sklearn/earth/_basis.pyx":566 + * cdef INDEX_t n = len(self.order) + * for i in range(n): + * if not self.order[i].is_pruned(): # <<<<<<<<<<<<<< + * length += 1 + * return length + */ + if (unlikely(((PyObject *)__pyx_v_self->order) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i), __pyx_n_s__is_pruned); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_7 = ((!__pyx_t_6) != 0); + if (__pyx_t_7) { + + /* "sklearn/earth/_basis.pyx":567 + * for i in range(n): + * if not self.order[i].is_pruned(): + * length += 1 # <<<<<<<<<<<<<< + * return length + * + */ + __pyx_v_length = (__pyx_v_length + 1); + goto __pyx_L5; + } + __pyx_L5:; + } + + /* "sklearn/earth/_basis.pyx":568 + * if not self.order[i].is_pruned(): + * length += 1 + * return length # <<<<<<<<<<<<<< + * + * cpdef transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B): + */ + __pyx_r = __pyx_v_length; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._basis.Basis.plen", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_34plen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_34plen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("plen (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_33plen(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":561 + * return self.get(i) + * + * cpdef INDEX_t plen(Basis self): # <<<<<<<<<<<<<< + * cdef INDEX_t length = 0 + * cdef INDEX_t i + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_33plen(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("plen", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->plen(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.plen", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":570 + * return length + * + * cpdef transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B): # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t n = self.__len__() + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_36transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_5Basis_transform(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_B, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_bf = 0; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_col; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_4; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_5; + int __pyx_t_6; + struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("transform", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_36transform)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_INCREF(((PyObject *)__pyx_v_B)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_B)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_B)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":572 + * cpdef transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B): + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t n = self.__len__() # <<<<<<<<<<<<<< + * cdef BasisFunction bf + * cdef INDEX_t col = 0 + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____len__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_n = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":574 + * cdef INDEX_t n = self.__len__() + * cdef BasisFunction bf + * cdef INDEX_t col = 0 # <<<<<<<<<<<<<< + * for i in range(n): + * bf = self.order[i] + */ + __pyx_v_col = 0; + + /* "sklearn/earth/_basis.pyx":575 + * cdef BasisFunction bf + * cdef INDEX_t col = 0 + * for i in range(n): # <<<<<<<<<<<<<< + * bf = self.order[i] + * if bf.is_pruned(): + */ + __pyx_t_4 = __pyx_v_n; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "sklearn/earth/_basis.pyx":576 + * cdef INDEX_t col = 0 + * for i in range(n): + * bf = self.order[i] # <<<<<<<<<<<<<< + * if bf.is_pruned(): + * continue + */ + if (unlikely(((PyObject *)__pyx_v_self->order) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i), __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_v_self->order, __pyx_v_i); + __Pyx_INCREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_bf, ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":577 + * for i in range(n): + * bf = self.order[i] + * if bf.is_pruned(): # <<<<<<<<<<<<<< + * continue + * bf.apply(X, B[:, col], recurse=True) + */ + __pyx_t_6 = (((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf->__pyx_vtab)->is_pruned(__pyx_v_bf, 0) != 0); + if (__pyx_t_6) { + + /* "sklearn/earth/_basis.pyx":578 + * bf = self.order[i] + * if bf.is_pruned(): + * continue # <<<<<<<<<<<<<< + * bf.apply(X, B[:, col], recurse=True) + * col += 1 + */ + goto __pyx_L3_continue; + goto __pyx_L5; + } + __pyx_L5:; + + /* "sklearn/earth/_basis.pyx":579 + * if bf.is_pruned(): + * continue + * bf.apply(X, B[:, col], recurse=True) # <<<<<<<<<<<<<< + * col += 1 + * + */ + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_col); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_k_slice_9); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_k_slice_9); + __Pyx_GIVEREF(__pyx_k_slice_9); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_1)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7.__pyx_n = 1; + __pyx_t_7.recurse = 1; + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf->__pyx_vtab)->apply(__pyx_v_bf, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_t_3), 0, &__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_basis.pyx":580 + * continue + * bf.apply(X, B[:, col], recurse=True) + * col += 1 # <<<<<<<<<<<<<< + * + * cpdef weighted_transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): + */ + __pyx_v_col = (__pyx_v_col + 1); + __pyx_L3_continue:; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.transform", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_bf); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_36transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_36transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_B = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("transform (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__B,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__B)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("transform", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "transform") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_X = ((PyArrayObject *)values[0]); + __pyx_v_B = ((PyArrayObject *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("transform", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.transform", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_B), __pyx_ptype_5numpy_ndarray, 1, "B", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_35transform(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), __pyx_v_X, __pyx_v_B); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":570 + * return length + * + * cpdef transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B): # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t n = self.__len__() + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_35transform(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_B) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("transform", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->transform(__pyx_v_self, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_B), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.transform", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":582 + * col += 1 + * + * cpdef weighted_transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t n = self.__len__() + */ + +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_38weighted_transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_6_basis_5Basis_weighted_transform(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights, int __pyx_skip_dispatch) { + CYTHON_UNUSED __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_v_n; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("weighted_transform", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__weighted_transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_38weighted_transform)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_INCREF(((PyObject *)__pyx_v_B)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_B)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_B)); + __Pyx_INCREF(((PyObject *)__pyx_v_weights)); + PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_weights)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_weights)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_basis.pyx":584 + * cpdef weighted_transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t n = self.__len__() # <<<<<<<<<<<<<< + * + * self.transform(X, B) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____len__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_n = __pyx_t_4; + + /* "sklearn/earth/_basis.pyx":586 + * cdef INDEX_t n = self.__len__() + * + * self.transform(X, B) # <<<<<<<<<<<<<< + * apply_weights_2d(B, weights) + */ + __pyx_t_3 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->transform(__pyx_v_self, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_B), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_basis.pyx":587 + * + * self.transform(X, B) + * apply_weights_2d(B, weights) # <<<<<<<<<<<<<< + */ + __pyx_t_3 = __pyx_f_7sklearn_5earth_5_util_apply_weights_2d(((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_weights), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.weighted_transform", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_38weighted_transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_38weighted_transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_B = 0; + PyArrayObject *__pyx_v_weights = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("weighted_transform (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__B,&__pyx_n_s__weights,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__B)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("weighted_transform", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weights)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("weighted_transform", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "weighted_transform") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __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_X = ((PyArrayObject *)values[0]); + __pyx_v_B = ((PyArrayObject *)values[1]); + __pyx_v_weights = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("weighted_transform", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._basis.Basis.weighted_transform", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_B), __pyx_ptype_5numpy_ndarray, 1, "B", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weights), __pyx_ptype_5numpy_ndarray, 1, "weights", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_37weighted_transform(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self), __pyx_v_X, __pyx_v_B, __pyx_v_weights); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pyx":582 + * col += 1 + * + * cpdef weighted_transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): # <<<<<<<<<<<<<< + * cdef INDEX_t i # @DuplicatedSignature + * cdef INDEX_t n = self.__len__() + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_37weighted_transform(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("weighted_transform", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_6_basis_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->__pyx_vtab)->weighted_transform(__pyx_v_self, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_weights), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._basis.Basis.weighted_transform", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_13num_variables_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_6_basis_5Basis_13num_variables_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_6_basis_5Basis_13num_variables___get__(((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_basis.pxd":107 + * + * cdef list order + * cdef readonly INDEX_t num_variables # <<<<<<<<<<<<<< + * + * cpdef translate(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_6_basis_5Basis_13num_variables___get__(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->num_variables); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._basis.Basis.num_variables.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":194 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "numpy.pxd":200 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":203 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":204 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":206 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "numpy.pxd":208 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":209 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + goto __pyx_L4; + } + /*else*/ { + + /* "numpy.pxd":211 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "numpy.pxd":213 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":214 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "numpy.pxd":217 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_3) { + + /* "numpy.pxd":218 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = __pyx_t_1; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (__pyx_t_2) { + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "numpy.pxd":221 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "numpy.pxd":222 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "numpy.pxd":223 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_2 = (__pyx_v_copy_shape != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":226 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "numpy.pxd":227 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "numpy.pxd":228 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "numpy.pxd":229 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "numpy.pxd":230 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + goto __pyx_L7; + } + /*else*/ { + + /* "numpy.pxd":232 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "numpy.pxd":233 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L7:; + + /* "numpy.pxd":234 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "numpy.pxd":235 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "numpy.pxd":236 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "numpy.pxd":239 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef list stack + */ + __pyx_v_f = NULL; + + /* "numpy.pxd":240 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef list stack + * cdef int offset + */ + __pyx_t_4 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_4); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":244 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "numpy.pxd":246 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_3; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":248 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + goto __pyx_L10; + } + /*else*/ { + + /* "numpy.pxd":251 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L10:; + + /* "numpy.pxd":253 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":254 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_5 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_5; + + /* "numpy.pxd":255 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_2 = __pyx_t_1; + } + if (!__pyx_t_2) { + + /* "numpy.pxd":256 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_1) { + __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_7 = __pyx_t_3; + } else { + __pyx_t_7 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_7; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + switch (__pyx_v_t) { + + /* "numpy.pxd":258 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + case NPY_BYTE: + __pyx_v_f = __pyx_k__b; + break; + + /* "numpy.pxd":259 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = __pyx_k__B; + break; + + /* "numpy.pxd":260 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = __pyx_k__h; + break; + + /* "numpy.pxd":261 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = __pyx_k__H; + break; + + /* "numpy.pxd":262 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = __pyx_k__i; + break; + + /* "numpy.pxd":263 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = __pyx_k__I; + break; + + /* "numpy.pxd":264 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = __pyx_k__l; + break; + + /* "numpy.pxd":265 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = __pyx_k__L; + break; + + /* "numpy.pxd":266 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = __pyx_k__q; + break; + + /* "numpy.pxd":267 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = __pyx_k__Q; + break; + + /* "numpy.pxd":268 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = __pyx_k__f; + break; + + /* "numpy.pxd":269 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = __pyx_k__d; + break; + + /* "numpy.pxd":270 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = __pyx_k__g; + break; + + /* "numpy.pxd":271 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = __pyx_k__Zf; + break; + + /* "numpy.pxd":272 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = __pyx_k__Zd; + break; + + /* "numpy.pxd":273 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = __pyx_k__Zg; + break; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = __pyx_k__O; + break; + default: + + /* "numpy.pxd":276 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_16), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + + /* "numpy.pxd":277 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "numpy.pxd":278 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":280 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + __pyx_v_info->format = ((char *)malloc(255)); + + /* "numpy.pxd":281 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "numpy.pxd":282 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "numpy.pxd":285 + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + * &offset) # <<<<<<<<<<<<<< + * f[0] = c'\0' # Terminate format string + * + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_9; + + /* "numpy.pxd":286 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + __pyx_L11:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":288 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "numpy.pxd":289 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":290 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":291 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":292 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + goto __pyx_L4; + } + __pyx_L4:; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":768 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "numpy.pxd":769 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":771 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "numpy.pxd":772 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":774 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "numpy.pxd":775 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":777 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "numpy.pxd":778 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":780 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "numpy.pxd":781 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":783 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + char *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "numpy.pxd":790 + * cdef int delta_offset + * cdef tuple i + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":791 + * cdef tuple i + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "numpy.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) { + PyObject* sequence = ((PyObject *)__pyx_v_fields); + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + } else if (1) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else + { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "numpy.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (__pyx_t_7) { + __pyx_t_8 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_8 = __pyx_t_7; + } + if (!__pyx_t_8) { + + /* "numpy.pxd":802 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + __pyx_t_9 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_10 = __pyx_t_9; + } else { + __pyx_t_10 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_10; + } else { + __pyx_t_7 = __pyx_t_8; + } + if (__pyx_t_7) { + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "numpy.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!__pyx_t_7) break; + + /* "numpy.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 120; + + /* "numpy.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "numpy.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1); + } + + /* "numpy.pxd":818 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize); + + /* "numpy.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_7 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":821 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_7 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":826 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 98; + goto __pyx_L13; + } + + /* "numpy.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 66; + goto __pyx_L13; + } + + /* "numpy.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 104; + goto __pyx_L13; + } + + /* "numpy.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 72; + goto __pyx_L13; + } + + /* "numpy.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 105; + goto __pyx_L13; + } + + /* "numpy.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 73; + goto __pyx_L13; + } + + /* "numpy.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 108; + goto __pyx_L13; + } + + /* "numpy.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 76; + goto __pyx_L13; + } + + /* "numpy.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 113; + goto __pyx_L13; + } + + /* "numpy.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 81; + goto __pyx_L13; + } + + /* "numpy.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 102; + goto __pyx_L13; + } + + /* "numpy.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 100; + goto __pyx_L13; + } + + /* "numpy.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 103; + goto __pyx_L13; + } + + /* "numpy.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 102; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 100; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 103; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 79; + goto __pyx_L13; + } + /*else*/ { + + /* "numpy.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_16), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L13:; + + /* "numpy.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_12; + } + __pyx_L11:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "numpy.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":965 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "numpy.pxd":967 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":968 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":970 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + Py_INCREF(__pyx_v_base); + + /* "numpy.pxd":971 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "numpy.pxd":972 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "numpy.pxd":973 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "numpy.pxd":976 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":977 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":979 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis __pyx_vtable_7sklearn_5earth_6_basis_Basis; + +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_Basis(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)o); + p->__pyx_vtab = __pyx_vtabptr_7sklearn_5earth_6_basis_Basis; + p->order = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_6_basis_Basis(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *p = (struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->order); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_6_basis_Basis(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *p = (struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)o; + if (p->order) { + e = (*v)(p->order, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_6_basis_Basis(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *p = (struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)o; + PyObject* tmp; + tmp = ((PyObject*)p->order); + p->order = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_7sklearn_5earth_6_basis_Basis(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyObject *__pyx_getprop_7sklearn_5earth_6_basis_5Basis_num_variables(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_7sklearn_5earth_6_basis_5Basis_13num_variables_1__get__(o); +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_6_basis_Basis[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_eq"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_11_eq, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("piter"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_13piter, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_18translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("scale"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_20scale, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_root"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_22get_root, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_24append, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_30get, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("plen"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_34plen, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("transform"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_36transform, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("weighted_transform"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_5Basis_38weighted_transform, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_7sklearn_5earth_6_basis_Basis[] = { + {(char *)"num_variables", __pyx_getprop_7sklearn_5earth_6_basis_5Basis_num_variables, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_Basis = { + __pyx_pw_7sklearn_5earth_6_basis_5Basis_28__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_7sklearn_5earth_6_basis_Basis, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_Basis = { + __pyx_pw_7sklearn_5earth_6_basis_5Basis_28__len__, /*mp_length*/ + __pyx_pw_7sklearn_5earth_6_basis_5Basis_32__getitem__, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_6_basis_Basis = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._basis.Basis"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_Basis), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_6_basis_Basis, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_Basis, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Basis, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_6_basis_5Basis_16__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("A container that provides functionality related to a set of BasisFunctions with a\n common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are\n added."), /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_6_basis_Basis, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_6_basis_Basis, /*tp_clear*/ + __pyx_pw_7sklearn_5earth_6_basis_5Basis_9__richcmp__, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pw_7sklearn_5earth_6_basis_5Basis_26__iter__, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_6_basis_Basis, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_7sklearn_5earth_6_basis_Basis, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_6_basis_5Basis_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_6_basis_Basis, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction; + +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_BasisFunction(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)o); + p->__pyx_vtab = __pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + p->parent = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)Py_None); Py_INCREF(Py_None); + p->child_map = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->children = ((PyObject*)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_6_basis_BasisFunction(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->parent); + Py_CLEAR(p->child_map); + Py_CLEAR(p->children); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_6_basis_BasisFunction(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)o; + if (p->parent) { + e = (*v)(((PyObject*)p->parent), a); if (e) return e; + } + if (p->child_map) { + e = (*v)(p->child_map, a); if (e) return e; + } + if (p->children) { + e = (*v)(p->children, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_6_basis_BasisFunction(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)o; + PyObject* tmp; + tmp = ((PyObject*)p->parent); + p->parent = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->child_map); + p->child_map = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->children); + p->children = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_6_basis_BasisFunction[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_get_root"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_5_get_root, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_7_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_get_parent_state"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_9_get_parent_state, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_set_parent_state"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_11_set_parent_state, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_13__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_eq"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_15_eq, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("has_knot"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_19has_knot, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("is_prunable"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_21is_prunable, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("is_pruned"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_23is_pruned, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("is_splittable"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_25is_splittable, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("make_splittable"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_27make_splittable, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("make_unsplittable"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_29make_unsplittable, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_set_parent"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_31_set_parent, METH_O, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_30_set_parent)}, + {__Pyx_NAMESTR("_add_child"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_33_add_child, METH_O, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_32_add_child)}, + {__Pyx_NAMESTR("get_parent"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_35get_parent, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("prune"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_37prune, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("unprune"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_39unprune, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("knots"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_41knots, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("degree"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_43degree, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("apply"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_45apply, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_44apply)}, + {__Pyx_NAMESTR("valid_knots"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_47valid_knots, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_6_basis_13BasisFunction_46valid_knots)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_6_basis_BasisFunction = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._basis.BasisFunction"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_6_basis_BasisFunction, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods."), /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_6_basis_BasisFunction, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_6_basis_BasisFunction, /*tp_clear*/ + __pyx_pw_7sklearn_5earth_6_basis_13BasisFunction_17__richcmp__, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_6_basis_BasisFunction, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_6_basis_BasisFunction, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction __pyx_vtable_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction; + +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_6_basis_BasisFunction(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction*)__pyx_vtabptr_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction[] = { + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._basis.PicklePlaceHolderBasisFunction"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_6_basis_BasisFunction, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("This is a place holder for unpickling the basis function tree."), /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_6_basis_BasisFunction, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_6_basis_BasisFunction, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction; + +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_ConstantBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_6_basis_BasisFunction(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction*)__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_6_basis_ConstantBasisFunction[] = { + {__Pyx_NAMESTR("_get_root"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_3_get_root, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_get_parent_state"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_5_get_parent_state, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_set_parent_state"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_7_set_parent_state, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("degree"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_9degree, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_11translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("scale"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_13scale, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_set_parent"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_15_set_parent, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_parent"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_17get_parent, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("apply"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_19apply, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_6_basis_21ConstantBasisFunction_18apply)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_6_basis_ConstantBasisFunction = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._basis.ConstantBasisFunction"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_6_basis_BasisFunction, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_21__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_6_basis_BasisFunction, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_6_basis_BasisFunction, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_6_basis_ConstantBasisFunction, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_6_basis_21ConstantBasisFunction_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_6_basis_ConstantBasisFunction, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; + +static struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *__pyx_freelist_7sklearn_5earth_6_basis___pyx_scope_struct__piter[8]; +static int __pyx_freecount_7sklearn_5earth_6_basis___pyx_scope_struct__piter = 0; + +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis___pyx_scope_struct__piter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *p; + PyObject *o; + if (likely((__pyx_freecount_7sklearn_5earth_6_basis___pyx_scope_struct__piter > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter)))) { + o = (PyObject*)__pyx_freelist_7sklearn_5earth_6_basis___pyx_scope_struct__piter[--__pyx_freecount_7sklearn_5earth_6_basis___pyx_scope_struct__piter]; + memset(o, 0, sizeof(struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter)); + PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + p = ((struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *)o); + p->__pyx_v_bf = 0; + p->__pyx_v_self = 0; + p->__pyx_t_0 = 0; + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_6_basis___pyx_scope_struct__piter(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *p = (struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_bf); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_t_0); + if ((__pyx_freecount_7sklearn_5earth_6_basis___pyx_scope_struct__piter < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter))) { + __pyx_freelist_7sklearn_5earth_6_basis___pyx_scope_struct__piter[__pyx_freecount_7sklearn_5earth_6_basis___pyx_scope_struct__piter++] = ((struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_7sklearn_5earth_6_basis___pyx_scope_struct__piter(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *p = (struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *)o; + if (p->__pyx_v_bf) { + e = (*v)(p->__pyx_v_bf, a); if (e) return e; + } + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; + } + if (p->__pyx_t_0) { + e = (*v)(p->__pyx_t_0, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_6_basis___pyx_scope_struct__piter(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *p = (struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter *)o; + PyObject* tmp; + tmp = ((PyObject*)p->__pyx_v_bf); + p->__pyx_v_bf = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_t_0); + p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_6_basis___pyx_scope_struct__piter[] = { + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_6_basis___pyx_scope_struct__piter = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._basis.__pyx_scope_struct__piter"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_6_basis___pyx_scope_struct__piter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_6_basis___pyx_scope_struct__piter, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_6_basis___pyx_scope_struct__piter, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_6_basis___pyx_scope_struct__piter, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_6_basis___pyx_scope_struct__piter, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_6_basis___pyx_scope_struct__piter, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction; + +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_HingeBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_6_basis_BasisFunction(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction*)__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction; + p->label = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_6_basis_HingeBasisFunction(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->label); + PyObject_GC_Track(o); + __pyx_tp_dealloc_7sklearn_5earth_6_basis_BasisFunction(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_6_basis_HingeBasisFunction(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)o; + e = __pyx_tp_traverse_7sklearn_5earth_6_basis_BasisFunction(o, v, a); if (e) return e; + if (p->label) { + e = (*v)(p->label, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_6_basis_HingeBasisFunction(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *)o; + PyObject* tmp; + __pyx_tp_clear_7sklearn_5earth_6_basis_BasisFunction(o); + tmp = ((PyObject*)p->label); + p->label = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_6_basis_HingeBasisFunction[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("has_knot"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_9has_knot, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_11translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("scale"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_13scale, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_variable"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_17get_variable, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_knot"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_19get_knot, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_reverse"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_21get_reverse, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_knot_idx"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_23get_knot_idx, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("apply"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_25apply, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_6_basis_18HingeBasisFunction_24apply)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_6_basis_HingeBasisFunction = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._basis.HingeBasisFunction"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_6_basis_HingeBasisFunction, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_15__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_6_basis_HingeBasisFunction, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_6_basis_HingeBasisFunction, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_6_basis_HingeBasisFunction, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_6_basis_18HingeBasisFunction_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_6_basis_HingeBasisFunction, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction __pyx_vtable_7sklearn_5earth_6_basis_LinearBasisFunction; + +static PyObject *__pyx_tp_new_7sklearn_5earth_6_basis_LinearBasisFunction(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_6_basis_BasisFunction(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction*)__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction; + p->label = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_6_basis_LinearBasisFunction(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->label); + PyObject_GC_Track(o); + __pyx_tp_dealloc_7sklearn_5earth_6_basis_BasisFunction(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_6_basis_LinearBasisFunction(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)o; + e = __pyx_tp_traverse_7sklearn_5earth_6_basis_BasisFunction(o, v, a); if (e) return e; + if (p->label) { + e = (*v)(p->label, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_6_basis_LinearBasisFunction(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *p = (struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *)o; + PyObject* tmp; + __pyx_tp_clear_7sklearn_5earth_6_basis_BasisFunction(o); + tmp = ((PyObject*)p->label); + p->label = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_6_basis_LinearBasisFunction[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_9translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("scale"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_11scale, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_variable"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_15get_variable, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("apply"), (PyCFunction)__pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_17apply, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_6_basis_19LinearBasisFunction_16apply)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_6_basis_LinearBasisFunction = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._basis.LinearBasisFunction"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_6_basis_LinearBasisFunction, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_13__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_6_basis_LinearBasisFunction, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_6_basis_LinearBasisFunction, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_6_basis_LinearBasisFunction, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_6_basis_19LinearBasisFunction_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_6_basis_LinearBasisFunction, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + __Pyx_NAMESTR("_basis"), + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, + {&__pyx_kp_u_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 1, 0, 0}, + {&__pyx_kp_u_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 1, 0, 0}, + {&__pyx_kp_u_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0, 0}, + {&__pyx_kp_u_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 1, 0, 0}, + {&__pyx_kp_u_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 1, 0, 0}, + {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0}, + {&__pyx_kp_u_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 1, 0, 0}, + {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, + {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, + {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0}, + {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0}, + {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0}, + {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0}, + {&__pyx_n_s__B, __pyx_k__B, sizeof(__pyx_k__B), 0, 0, 1, 1}, + {&__pyx_n_s__NotImplemented, __pyx_k__NotImplemented, sizeof(__pyx_k__NotImplemented), 0, 0, 1, 1}, + {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1}, + {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, + {&__pyx_n_s__X, __pyx_k__X, sizeof(__pyx_k__X), 0, 0, 1, 1}, + {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1}, + {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, + {&__pyx_n_s____iter__, __pyx_k____iter__, sizeof(__pyx_k____iter__), 0, 0, 1, 1}, + {&__pyx_n_s____len__, __pyx_k____len__, sizeof(__pyx_k____len__), 0, 0, 1, 1}, + {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_getbuffer, __pyx_k____pyx_getbuffer, sizeof(__pyx_k____pyx_getbuffer), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_releasebuffer, __pyx_k____pyx_releasebuffer, sizeof(__pyx_k____pyx_releasebuffer), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_vtable__, __pyx_k____pyx_vtable__, sizeof(__pyx_k____pyx_vtable__), 0, 0, 1, 1}, + {&__pyx_n_s____setstate__, __pyx_k____setstate__, sizeof(__pyx_k____setstate__), 0, 0, 1, 1}, + {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s___add_child, __pyx_k___add_child, sizeof(__pyx_k___add_child), 0, 0, 1, 1}, + {&__pyx_n_s___eq, __pyx_k___eq, sizeof(__pyx_k___eq), 0, 0, 1, 1}, + {&__pyx_n_s___get_parent_state, __pyx_k___get_parent_state, sizeof(__pyx_k___get_parent_state), 0, 0, 1, 1}, + {&__pyx_n_s___get_root, __pyx_k___get_root, sizeof(__pyx_k___get_root), 0, 0, 1, 1}, + {&__pyx_n_s___getstate, __pyx_k___getstate, sizeof(__pyx_k___getstate), 0, 0, 1, 1}, + {&__pyx_n_s___set_parent, __pyx_k___set_parent, sizeof(__pyx_k___set_parent), 0, 0, 1, 1}, + {&__pyx_n_s___set_parent_state, __pyx_k___set_parent_state, sizeof(__pyx_k___set_parent_state), 0, 0, 1, 1}, + {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1}, + {&__pyx_n_s__apply, __pyx_k__apply, sizeof(__pyx_k__apply), 0, 0, 1, 1}, + {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1}, + {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1}, + {&__pyx_n_s__beta, __pyx_k__beta, sizeof(__pyx_k__beta), 0, 0, 1, 1}, + {&__pyx_n_s__check_every, __pyx_k__check_every, sizeof(__pyx_k__check_every), 0, 0, 1, 1}, + {&__pyx_n_s__child_map, __pyx_k__child_map, sizeof(__pyx_k__child_map), 0, 0, 1, 1}, + {&__pyx_n_s__children, __pyx_k__children, sizeof(__pyx_k__children), 0, 0, 1, 1}, + {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1}, + {&__pyx_n_s__degree, __pyx_k__degree, sizeof(__pyx_k__degree), 0, 0, 1, 1}, + {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1}, + {&__pyx_n_s__empty, __pyx_k__empty, sizeof(__pyx_k__empty), 0, 0, 1, 1}, + {&__pyx_n_s__endspan, __pyx_k__endspan, sizeof(__pyx_k__endspan), 0, 0, 1, 1}, + {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1}, + {&__pyx_n_s__get_knot, __pyx_k__get_knot, sizeof(__pyx_k__get_knot), 0, 0, 1, 1}, + {&__pyx_n_s__get_knot_idx, __pyx_k__get_knot_idx, sizeof(__pyx_k__get_knot_idx), 0, 0, 1, 1}, + {&__pyx_n_s__get_parent, __pyx_k__get_parent, sizeof(__pyx_k__get_parent), 0, 0, 1, 1}, + {&__pyx_n_s__get_reverse, __pyx_k__get_reverse, sizeof(__pyx_k__get_reverse), 0, 0, 1, 1}, + {&__pyx_n_s__get_root, __pyx_k__get_root, sizeof(__pyx_k__get_root), 0, 0, 1, 1}, + {&__pyx_n_s__get_variable, __pyx_k__get_variable, sizeof(__pyx_k__get_variable), 0, 0, 1, 1}, + {&__pyx_n_s__has_knot, __pyx_k__has_knot, sizeof(__pyx_k__has_knot), 0, 0, 1, 1}, + {&__pyx_n_s__intercepts, __pyx_k__intercepts, sizeof(__pyx_k__intercepts), 0, 0, 1, 1}, + {&__pyx_n_s__is_prunable, __pyx_k__is_prunable, sizeof(__pyx_k__is_prunable), 0, 0, 1, 1}, + {&__pyx_n_s__is_pruned, __pyx_k__is_pruned, sizeof(__pyx_k__is_pruned), 0, 0, 1, 1}, + {&__pyx_n_s__is_splittable, __pyx_k__is_splittable, sizeof(__pyx_k__is_splittable), 0, 0, 1, 1}, + {&__pyx_n_s__knot, __pyx_k__knot, sizeof(__pyx_k__knot), 0, 0, 1, 1}, + {&__pyx_n_s__knot_idx, __pyx_k__knot_idx, sizeof(__pyx_k__knot_idx), 0, 0, 1, 1}, + {&__pyx_n_s__knots, __pyx_k__knots, sizeof(__pyx_k__knots), 0, 0, 1, 1}, + {&__pyx_n_s__label, __pyx_k__label, sizeof(__pyx_k__label), 0, 0, 1, 1}, + {&__pyx_n_s__make_splittable, __pyx_k__make_splittable, sizeof(__pyx_k__make_splittable), 0, 0, 1, 1}, + {&__pyx_n_s__make_unsplittable, __pyx_k__make_unsplittable, sizeof(__pyx_k__make_unsplittable), 0, 0, 1, 1}, + {&__pyx_n_s__minspan, __pyx_k__minspan, sizeof(__pyx_k__minspan), 0, 0, 1, 1}, + {&__pyx_n_s__minspan_alpha, __pyx_k__minspan_alpha, sizeof(__pyx_k__minspan_alpha), 0, 0, 1, 1}, + {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1}, + {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, + {&__pyx_n_s__num_variables, __pyx_k__num_variables, sizeof(__pyx_k__num_variables), 0, 0, 1, 1}, + {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, + {&__pyx_n_s__order, __pyx_k__order, sizeof(__pyx_k__order), 0, 0, 1, 1}, + {&__pyx_n_s__parent, __pyx_k__parent, sizeof(__pyx_k__parent), 0, 0, 1, 1}, + {&__pyx_n_s__pickle_place_holder, __pyx_k__pickle_place_holder, sizeof(__pyx_k__pickle_place_holder), 0, 0, 1, 1}, + {&__pyx_n_s__plen, __pyx_k__plen, sizeof(__pyx_k__plen), 0, 0, 1, 1}, + {&__pyx_n_s__prunable, __pyx_k__prunable, sizeof(__pyx_k__prunable), 0, 0, 1, 1}, + {&__pyx_n_s__prune, __pyx_k__prune, sizeof(__pyx_k__prune), 0, 0, 1, 1}, + {&__pyx_n_s__pruned, __pyx_k__pruned, sizeof(__pyx_k__pruned), 0, 0, 1, 1}, + {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, + {&__pyx_n_s__recurse, __pyx_k__recurse, sizeof(__pyx_k__recurse), 0, 0, 1, 1}, + {&__pyx_n_s__reverse, __pyx_k__reverse, sizeof(__pyx_k__reverse), 0, 0, 1, 1}, + {&__pyx_n_s__root, __pyx_k__root, sizeof(__pyx_k__root), 0, 0, 1, 1}, + {&__pyx_n_s__scale, __pyx_k__scale, sizeof(__pyx_k__scale), 0, 0, 1, 1}, + {&__pyx_n_s__send, __pyx_k__send, sizeof(__pyx_k__send), 0, 0, 1, 1}, + {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1}, + {&__pyx_n_s__slopes, __pyx_k__slopes, sizeof(__pyx_k__slopes), 0, 0, 1, 1}, + {&__pyx_n_s__splittable, __pyx_k__splittable, sizeof(__pyx_k__splittable), 0, 0, 1, 1}, + {&__pyx_n_s__super, __pyx_k__super, sizeof(__pyx_k__super), 0, 0, 1, 1}, + {&__pyx_n_s__throw, __pyx_k__throw, sizeof(__pyx_k__throw), 0, 0, 1, 1}, + {&__pyx_n_s__transform, __pyx_k__transform, sizeof(__pyx_k__transform), 0, 0, 1, 1}, + {&__pyx_n_s__translate, __pyx_k__translate, sizeof(__pyx_k__translate), 0, 0, 1, 1}, + {&__pyx_n_s__unprune, __pyx_k__unprune, sizeof(__pyx_k__unprune), 0, 0, 1, 1}, + {&__pyx_n_s__update, __pyx_k__update, sizeof(__pyx_k__update), 0, 0, 1, 1}, + {&__pyx_n_s__valid_knots, __pyx_k__valid_knots, sizeof(__pyx_k__valid_knots), 0, 0, 1, 1}, + {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1}, + {&__pyx_n_s__variable, __pyx_k__variable, sizeof(__pyx_k__variable), 0, 0, 1, 1}, + {&__pyx_n_s__variable_idx, __pyx_k__variable_idx, sizeof(__pyx_k__variable_idx), 0, 0, 1, 1}, + {&__pyx_n_s__weighted_transform, __pyx_k__weighted_transform, sizeof(__pyx_k__weighted_transform), 0, 0, 1, 1}, + {&__pyx_n_s__weights, __pyx_k__weights, sizeof(__pyx_k__weights), 0, 0, 1, 1}, + {&__pyx_n_s__workspace, __pyx_k__workspace, sizeof(__pyx_k__workspace), 0, 0, 1, 1}, + {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s__NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "sklearn/earth/_basis.pyx":579 + * if bf.is_pruned(): + * continue + * bf.apply(X, B[:, col], recurse=True) # <<<<<<<<<<<<<< + * col += 1 + * + */ + __pyx_k_slice_9 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_9); + __Pyx_GIVEREF(__pyx_k_slice_9); + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_k_tuple_11 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_10)); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_11); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11)); + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_k_tuple_13 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_12)); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_13); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_k_tuple_15 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_14)); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_15); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15)); + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_k_tuple_18 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_17)); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_18); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18)); + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_k_tuple_19 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_14)); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_19); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_k_tuple_21 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_20)); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_21); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_basis(void); /*proto*/ +PyMODINIT_FUNC init_basis(void) +#else +PyMODINIT_FUNC PyInit__basis(void); /*proto*/ +PyMODINIT_FUNC PyInit__basis(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__basis(void)", 0); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __Pyx_CyFunction_USED + if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_basis"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_d); + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "sklearn.earth._basis")) { + if (unlikely(PyDict_SetItemString(modules, "sklearn.earth._basis", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + } + #endif + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + /*--- Initialize various global constants etc. ---*/ + if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if (__pyx_module_is_main_sklearn__earth___basis) { + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + /*--- Builtin init code ---*/ + if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Constants init code ---*/ + if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_7sklearn_5earth_6_basis_Basis = &__pyx_vtable_7sklearn_5earth_6_basis_Basis; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.translate = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_translate; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.scale = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_scale; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.get_root = (struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_get_root; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.append = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_append; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.plen = (__pyx_t_7sklearn_5earth_6_basis_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_plen; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.get = (struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_get; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.transform = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_transform; + __pyx_vtable_7sklearn_5earth_6_basis_Basis.weighted_transform = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_5Basis_weighted_transform; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_6_basis_Basis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_6_basis_Basis.tp_dict, __pyx_vtabptr_7sklearn_5earth_6_basis_Basis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Basis", (PyObject *)&__pyx_type_7sklearn_5earth_6_basis_Basis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_Basis = &__pyx_type_7sklearn_5earth_6_basis_Basis; + __pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction = &__pyx_vtable_7sklearn_5earth_6_basis_BasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.has_knot = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_has_knot; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.is_prunable = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_is_prunable; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.is_pruned = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_is_pruned; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.is_splittable = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_is_splittable; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.make_splittable = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_make_splittable; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.make_unsplittable = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_make_unsplittable; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.get_children = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_get_children; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction._set_parent = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction__set_parent; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction._add_child = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction__add_child; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.get_parent = (struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_get_parent; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.prune = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_prune; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.unprune = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_unprune; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.knots = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_knots; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.degree = (__pyx_t_7sklearn_5earth_6_basis_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_degree; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.apply = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_apply; + __pyx_vtable_7sklearn_5earth_6_basis_BasisFunction.valid_knots = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int, int, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_13BasisFunction_valid_knots; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_6_basis_BasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_6_basis_BasisFunction.tp_dict, __pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "BasisFunction", (PyObject *)&__pyx_type_7sklearn_5earth_6_basis_BasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = &__pyx_type_7sklearn_5earth_6_basis_BasisFunction; + __pyx_vtabptr_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction = &__pyx_vtable_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + __pyx_type_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction.tp_base = __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction.tp_dict, __pyx_vtabptr_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "PicklePlaceHolderBasisFunction", (PyObject *)&__pyx_type_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction = &__pyx_type_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction; + __pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction = &__pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction.__pyx_base._set_parent = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction__set_parent; + __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction.__pyx_base.get_parent = (struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_get_parent; + __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction.__pyx_base.degree = (__pyx_t_7sklearn_5earth_6_basis_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_degree; + __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction.__pyx_base.apply = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args))__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply; + __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction.translate = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_translate; + __pyx_vtable_7sklearn_5earth_6_basis_ConstantBasisFunction.scale = (__pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_21ConstantBasisFunction_scale; + __pyx_type_7sklearn_5earth_6_basis_ConstantBasisFunction.tp_base = __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_6_basis_ConstantBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_6_basis_ConstantBasisFunction.tp_dict, __pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "ConstantBasisFunction", (PyObject *)&__pyx_type_7sklearn_5earth_6_basis_ConstantBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = &__pyx_type_7sklearn_5earth_6_basis_ConstantBasisFunction; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_6_basis___pyx_scope_struct__piter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis___pyx_scope_struct__piter = &__pyx_type_7sklearn_5earth_6_basis___pyx_scope_struct__piter; + __pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction = &__pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.__pyx_base.has_knot = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_has_knot; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.__pyx_base.apply = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_apply; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.translate = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_translate; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.scale = (__pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_scale; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.get_variable = (__pyx_t_7sklearn_5earth_6_basis_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_variable; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.get_knot = (__pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_knot; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.get_reverse = (int (*)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_reverse; + __pyx_vtable_7sklearn_5earth_6_basis_HingeBasisFunction.get_knot_idx = (__pyx_t_7sklearn_5earth_6_basis_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_18HingeBasisFunction_get_knot_idx; + __pyx_type_7sklearn_5earth_6_basis_HingeBasisFunction.tp_base = __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_6_basis_HingeBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_6_basis_HingeBasisFunction.tp_dict, __pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HingeBasisFunction", (PyObject *)&__pyx_type_7sklearn_5earth_6_basis_HingeBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = &__pyx_type_7sklearn_5earth_6_basis_HingeBasisFunction; + __pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction = &__pyx_vtable_7sklearn_5earth_6_basis_LinearBasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_LinearBasisFunction.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + __pyx_vtable_7sklearn_5earth_6_basis_LinearBasisFunction.__pyx_base.apply = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args))__pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_apply; + __pyx_vtable_7sklearn_5earth_6_basis_LinearBasisFunction.translate = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_translate; + __pyx_vtable_7sklearn_5earth_6_basis_LinearBasisFunction.scale = (__pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_scale; + __pyx_vtable_7sklearn_5earth_6_basis_LinearBasisFunction.get_variable = (__pyx_t_7sklearn_5earth_6_basis_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_6_basis_19LinearBasisFunction_get_variable; + __pyx_type_7sklearn_5earth_6_basis_LinearBasisFunction.tp_base = __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_6_basis_LinearBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_6_basis_LinearBasisFunction.tp_dict, __pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "LinearBasisFunction", (PyObject *)&__pyx_type_7sklearn_5earth_6_basis_LinearBasisFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = &__pyx_type_7sklearn_5earth_6_basis_LinearBasisFunction; + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + __pyx_t_1 = __Pyx_ImportModule("sklearn.earth._util"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "log2", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_log2, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_FLOAT_t)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "apply_weights_2d", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_apply_weights_2d, "PyObject *(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; + /*--- Execution code ---*/ + + /* "sklearn/earth/_basis.pyx":10 + * from libc.math cimport log + * from libc.math cimport abs + * cdef FLOAT_t ZERO_TOL = 1e-16 # <<<<<<<<<<<<<< + * import numpy as np + * + */ + __pyx_v_7sklearn_5earth_6_basis_ZERO_TOL = 1e-16; + + /* "sklearn/earth/_basis.pyx":11 + * from libc.math cimport abs + * cdef FLOAT_t ZERO_TOL = 1e-16 + * import numpy as np # <<<<<<<<<<<<<< + * + * cdef class BasisFunction: + */ + __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s__np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":285 + * '''This is a place holder for unpickling the basis function tree.''' + * + * pickle_place_holder = PicklePlaceHolderBasisFunction() # <<<<<<<<<<<<<< + * + * cdef class ConstantBasisFunction(BasisFunction): + */ + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_PicklePlaceHolderBasisFunction)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s__pickle_place_holder, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_basis.pyx":1 + * # distutils: language = c # <<<<<<<<<<<<<< + * # cython: cdivision = True + * # cython: boundscheck = False + */ + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + + /* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + if (__pyx_m) { + __Pyx_AddTraceback("init sklearn.earth._basis", __pyx_clineno, __pyx_lineno, __pyx_filename); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init sklearn.earth._basis"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* Runtime support code */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +static CYTHON_INLINE int __Pyx_CheckKeywordStrings( + PyObject *kwdict, + const char* function_name, + int kw_allowed) +{ + PyObject* key = 0; + Py_ssize_t pos = 0; +#if CPYTHON_COMPILING_IN_PYPY + if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) + goto invalid_keyword; + return 1; +#else + while (PyDict_Next(kwdict, &pos, &key, 0)) { + #if PY_MAJOR_VERSION < 3 + if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) + #endif + if (unlikely(!PyUnicode_Check(key))) + goto invalid_keyword_type; + } + if ((!kw_allowed) && unlikely(key)) + goto invalid_keyword; + return 1; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%s() keywords must be strings", function_name); + return 0; +#endif +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%s() got an unexpected keyword argument '%s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif + return 0; +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); +} + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +} + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) { + if (likely(PyList_CheckExact(L))) { + if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return NULL; + Py_INCREF(Py_None); + return Py_None; /* this is just to have an accurate signature */ + } else { + return __Pyx_PyObject_CallMethod1(L, __pyx_n_s__append, x); + } +} + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return NULL; + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + int r; + if (!j) return -1; + r = PyObject_SetItem(o, j, v); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); + if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { + PyObject* old = PyList_GET_ITEM(o, n); + Py_INCREF(v); + PyList_SET_ITEM(o, n, v); + Py_DECREF(old); + return 1; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_ass_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return -1; + } + } + return m->sq_ass_item(o, i, v); + } + } +#else +#if CYTHON_COMPILING_IN_PYPY + if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) { +#else + if (is_list || PySequence_Check(o)) { +#endif + return PySequence_SetItem(o, i, v); + } +#endif + return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); +} + +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) /* First char was not a digit */ + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; /* Consume from buffer string */ + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; /* breaks both loops as ctx->enc_count == 0 */ + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; /* empty struct */ + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + if (isspace(*ts)) + continue; + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case 10: + case 13: + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': /* substruct */ + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': /* end of substruct; either repeat or move on */ + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } /* fall through */ + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 's': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + } else { + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + } + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%s() got an unexpected keyword argument '%s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON + result = PyDict_GetItem(__pyx_d, name); + if (result) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +static void __Pyx_RaiseBufferFallbackError(void) { + PyErr_Format(PyExc_ValueError, + "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); +} + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + #if PY_VERSION_HEX < 0x02050000 + if (PyClass_Check(type)) { + #else + if (PyType_Check(type)) { + #endif +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + #if PY_VERSION_HEX < 0x02050000 + if (PyInstance_Check(type)) { + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + Py_INCREF(type); + } else { + type = 0; + PyErr_SetString(PyExc_TypeError, + "raise: exception must be an old-style class or instance"); + goto raise_error; + } + #else + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + #endif + } + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else /* Python 3+ */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + index, (index == 1) ? "" : "s"); +} + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s____pyx_vtable__, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong val) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(npy_ulonglong) == sizeof(char)) || + (sizeof(npy_ulonglong) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(npy_ulonglong) == sizeof(int)) || + (sizeof(npy_ulonglong) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); + else + return PyLong_FromLongLong((PY_LONG_LONG)val); + } else { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + return _PyLong_FromByteArray(bytes, sizeof(npy_ulonglong), + little, !is_unsigned); + } +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *getbuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_getbuffer); + if (getbuffer_cobj) { + getbufferproc func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj); + Py_DECREF(getbuffer_cobj); + if (!func) + goto fail; + return func(obj, view, flags); + } else { + PyErr_Clear(); + } + } + #endif + PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *releasebuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_releasebuffer); + if (releasebuffer_cobj) { + releasebufferproc func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj); + Py_DECREF(releasebuffer_cobj); + if (!func) + goto fail; + func(obj, view); + return; + } else { + PyErr_Clear(); + } + } + #endif + goto nofail; +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + PyErr_WriteUnraisable(obj); +nofail: + Py_DECREF(obj); + view->obj = NULL; +} +#endif /* PY_MAJOR_VERSION < 3 */ + + + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + #if PY_VERSION_HEX >= 0x02050000 + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; /* try absolute import on failure */ + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } + #else + if (level>0) { + PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); + goto bad; + } + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, NULL); + #endif +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject* x) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if (sizeof(npy_ulonglong) == sizeof(char)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedChar(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedChar(x); + } else if (sizeof(npy_ulonglong) == sizeof(short)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedShort(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedShort(x); + } else if (sizeof(npy_ulonglong) == sizeof(int)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedInt(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedInt(x); + } else if (sizeof(npy_ulonglong) == sizeof(long)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLong(x); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLongLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLongLong(x); + } else { + #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); + #else + npy_ulonglong val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } + #endif + return (npy_ulonglong)-1; + } +} + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { + const unsigned char neg_one = (unsigned char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned char" : + "value too large to convert to unsigned char"); + } + return (unsigned char)-1; + } + return (unsigned char)val; + } + return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { + const unsigned short neg_one = (unsigned short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned short" : + "value too large to convert to unsigned short"); + } + return (unsigned short)-1; + } + return (unsigned short)val; + } + return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { + const unsigned int neg_one = (unsigned int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned int" : + "value too large to convert to unsigned int"); + } + return (unsigned int)-1; + } + return (unsigned int)val; + } + return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { + const char neg_one = (char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to char" : + "value too large to convert to char"); + } + return (char)-1; + } + return (char)val; + } + return (char)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { + const short neg_one = (short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to short" : + "value too large to convert to short"); + } + return (short)-1; + } + return (short)val; + } + return (short)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { + const signed char neg_one = (signed char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed char" : + "value too large to convert to signed char"); + } + return (signed char)-1; + } + return (signed char)val; + } + return (signed char)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { + const signed short neg_one = (signed short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed short" : + "value too large to convert to signed short"); + } + return (signed short)-1; + } + return (signed short)val; + } + return (signed short)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { + const signed int neg_one = (signed int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed int" : + "value too large to convert to signed int"); + } + return (signed int)-1; + } + return (signed int)val; + } + return (signed int)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { + const unsigned long neg_one = (unsigned long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned long)PyLong_AsLong(x); + } + } else { + unsigned long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned long)-1; + val = __Pyx_PyInt_AsUnsignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { + const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + unsigned PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsUnsignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { + const long neg_one = (long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (long)PyLong_AsLong(x); + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (long)-1; + val = __Pyx_PyInt_AsLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { + const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { + const signed long neg_one = (signed long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed long)PyLong_AsLong(x); + } + } else { + signed long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed long)-1; + val = __Pyx_PyInt_AsSignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { + const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + signed PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsSignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; +#else + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); +#endif + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} + +static PyObject *__Pyx_Generator_Next(PyObject *self); +static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value); +static PyObject *__Pyx_Generator_Close(PyObject *self); +static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args); +static PyTypeObject *__pyx_GeneratorType = 0; +#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType) +#define __Pyx_Generator_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) +#if 1 || PY_VERSION_HEX < 0x030300B0 +static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { + PyObject *et, *ev, *tb; + PyObject *value = NULL; + __Pyx_ErrFetch(&et, &ev, &tb); + if (!et) { + Py_XDECREF(tb); + Py_XDECREF(ev); + Py_INCREF(Py_None); + *pvalue = Py_None; + return 0; + } + if (unlikely(et != PyExc_StopIteration) && + unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + if (likely(et == PyExc_StopIteration)) { + if (likely(!ev) || !PyObject_IsInstance(ev, PyExc_StopIteration)) { + if (!ev) { + Py_INCREF(Py_None); + ev = Py_None; + } + Py_XDECREF(tb); + Py_DECREF(et); + *pvalue = ev; + return 0; + } + } + PyErr_NormalizeException(&et, &ev, &tb); + if (unlikely(!PyObject_IsInstance(ev, PyExc_StopIteration))) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + Py_XDECREF(tb); + Py_DECREF(et); +#if PY_VERSION_HEX >= 0x030300A0 + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); +#else + { + PyObject* args = PyObject_GetAttr(ev, __pyx_n_s__args); + Py_DECREF(ev); + if (likely(args)) { + value = PyObject_GetItem(args, 0); + Py_DECREF(args); + } + if (unlikely(!value)) { + __Pyx_ErrRestore(NULL, NULL, NULL); + Py_INCREF(Py_None); + value = Py_None; + } + } +#endif + *pvalue = value; + return 0; +} +#endif +static CYTHON_INLINE +void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self) { + PyObject *exc_type = self->exc_type; + PyObject *exc_value = self->exc_value; + PyObject *exc_traceback = self->exc_traceback; + self->exc_type = NULL; + self->exc_value = NULL; + self->exc_traceback = NULL; + Py_XDECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_traceback); +} +static CYTHON_INLINE +int __Pyx_Generator_CheckRunning(__pyx_GeneratorObject *gen) { + if (unlikely(gen->is_running)) { + PyErr_SetString(PyExc_ValueError, + "generator already executing"); + return 1; + } + return 0; +} +static CYTHON_INLINE +PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) { + PyObject *retval; + assert(!self->is_running); + if (unlikely(self->resume_label == 0)) { + if (unlikely(value && value != Py_None)) { + PyErr_SetString(PyExc_TypeError, + "can't send non-None value to a " + "just-started generator"); + return NULL; + } + } + if (unlikely(self->resume_label == -1)) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + if (value) { +#if CYTHON_COMPILING_IN_PYPY +#else + /* Generators always return to their most recent caller, not + * necessarily their creator. */ + if (self->exc_traceback) { + PyThreadState *tstate = PyThreadState_GET(); + PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; + PyFrameObject *f = tb->tb_frame; + Py_XINCREF(tstate->frame); + assert(f->f_back == NULL); + f->f_back = tstate->frame; + } +#endif + __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, + &self->exc_traceback); + } else { + __Pyx_Generator_ExceptionClear(self); + } + self->is_running = 1; + retval = self->body((PyObject *) self, value); + self->is_running = 0; + if (retval) { + __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, + &self->exc_traceback); +#if CYTHON_COMPILING_IN_PYPY +#else + /* Don't keep the reference to f_back any longer than necessary. It + * may keep a chain of frames alive or it could create a reference + * cycle. */ + if (self->exc_traceback) { + PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; + PyFrameObject *f = tb->tb_frame; + Py_CLEAR(f->f_back); + } +#endif + } else { + __Pyx_Generator_ExceptionClear(self); + } + return retval; +} +static CYTHON_INLINE +PyObject *__Pyx_Generator_FinishDelegation(__pyx_GeneratorObject *gen) { + PyObject *ret; + PyObject *val = NULL; + __Pyx_Generator_Undelegate(gen); + __Pyx_PyGen_FetchStopIterationValue(&val); + ret = __Pyx_Generator_SendEx(gen, val); + Py_XDECREF(val); + return ret; +} +static PyObject *__Pyx_Generator_Next(PyObject *self) { + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(__Pyx_Generator_CheckRunning(gen))) + return NULL; + if (yf) { + PyObject *ret; + gen->is_running = 1; + ret = Py_TYPE(yf)->tp_iternext(yf); + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + return __Pyx_Generator_FinishDelegation(gen); + } + return __Pyx_Generator_SendEx(gen, Py_None); +} +static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) { + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(__Pyx_Generator_CheckRunning(gen))) + return NULL; + if (yf) { + PyObject *ret; + gen->is_running = 1; + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Generator_Send(yf, value); + } else { + if (value == Py_None) + ret = PyIter_Next(yf); + else + ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s__send, value); + } + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + return __Pyx_Generator_FinishDelegation(gen); + } + return __Pyx_Generator_SendEx(gen, value); +} +static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) { + PyObject *retval = NULL; + int err = 0; + if (__Pyx_Generator_CheckExact(yf)) { + retval = __Pyx_Generator_Close(yf); + if (!retval) + return -1; + } else { + PyObject *meth; + gen->is_running = 1; + meth = PyObject_GetAttr(yf, __pyx_n_s__close); + if (unlikely(!meth)) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_WriteUnraisable(yf); + } + PyErr_Clear(); + } else { + retval = PyObject_CallFunction(meth, NULL); + Py_DECREF(meth); + if (!retval) + err = -1; + } + gen->is_running = 0; + } + Py_XDECREF(retval); + return err; +} +static PyObject *__Pyx_Generator_Close(PyObject *self) { + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; + PyObject *retval, *raised_exception; + PyObject *yf = gen->yieldfrom; + int err = 0; + if (unlikely(__Pyx_Generator_CheckRunning(gen))) + return NULL; + if (yf) { + Py_INCREF(yf); + err = __Pyx_Generator_CloseIter(gen, yf); + __Pyx_Generator_Undelegate(gen); + Py_DECREF(yf); + } + if (err == 0) +#if PY_VERSION_HEX < 0x02050000 + PyErr_SetNone(PyExc_StopIteration); +#else + PyErr_SetNone(PyExc_GeneratorExit); +#endif + retval = __Pyx_Generator_SendEx(gen, NULL); + if (retval) { + Py_DECREF(retval); + PyErr_SetString(PyExc_RuntimeError, + "generator ignored GeneratorExit"); + return NULL; + } + raised_exception = PyErr_Occurred(); + if (!raised_exception + || raised_exception == PyExc_StopIteration +#if PY_VERSION_HEX >= 0x02050000 + || raised_exception == PyExc_GeneratorExit + || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit) +#endif + || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration)) + { + if (raised_exception) PyErr_Clear(); /* ignore these errors */ + Py_INCREF(Py_None); + return Py_None; + } + return NULL; +} +static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) { + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; + PyObject *typ; + PyObject *tb = NULL; + PyObject *val = NULL; + PyObject *yf = gen->yieldfrom; + if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) + return NULL; + if (unlikely(__Pyx_Generator_CheckRunning(gen))) + return NULL; + if (yf) { + PyObject *ret; + Py_INCREF(yf); +#if PY_VERSION_HEX >= 0x02050000 + if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) { + int err = __Pyx_Generator_CloseIter(gen, yf); + Py_DECREF(yf); + __Pyx_Generator_Undelegate(gen); + if (err < 0) + return __Pyx_Generator_SendEx(gen, NULL); + goto throw_here; + } +#endif + gen->is_running = 1; + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Generator_Throw(yf, args); + } else { + PyObject *meth = PyObject_GetAttr(yf, __pyx_n_s__throw); + if (unlikely(!meth)) { + Py_DECREF(yf); + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + gen->is_running = 0; + return NULL; + } + PyErr_Clear(); + __Pyx_Generator_Undelegate(gen); + gen->is_running = 0; + goto throw_here; + } + ret = PyObject_CallObject(meth, args); + Py_DECREF(meth); + } + gen->is_running = 0; + Py_DECREF(yf); + if (!ret) { + ret = __Pyx_Generator_FinishDelegation(gen); + } + return ret; + } +throw_here: + __Pyx_Raise(typ, val, tb, NULL); + return __Pyx_Generator_SendEx(gen, NULL); +} +static int __Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg) { + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; + Py_VISIT(gen->closure); + Py_VISIT(gen->classobj); + Py_VISIT(gen->yieldfrom); + Py_VISIT(gen->exc_type); + Py_VISIT(gen->exc_value); + Py_VISIT(gen->exc_traceback); + return 0; +} +static int __Pyx_Generator_clear(PyObject *self) { + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; + Py_CLEAR(gen->closure); + Py_CLEAR(gen->classobj); + Py_CLEAR(gen->yieldfrom); + Py_CLEAR(gen->exc_type); + Py_CLEAR(gen->exc_value); + Py_CLEAR(gen->exc_traceback); + return 0; +} +static void __Pyx_Generator_dealloc(PyObject *self) { + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; + PyObject_GC_UnTrack(gen); + if (gen->gi_weakreflist != NULL) + PyObject_ClearWeakRefs(self); + PyObject_GC_Track(self); + if (gen->resume_label > 0) { + Py_TYPE(gen)->tp_del(self); + if (self->ob_refcnt > 0) + return; /* resurrected. :( */ + } + PyObject_GC_UnTrack(self); + __Pyx_Generator_clear(self); + PyObject_GC_Del(gen); +} +static void __Pyx_Generator_del(PyObject *self) { + PyObject *res; + PyObject *error_type, *error_value, *error_traceback; + __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; + if (gen->resume_label <= 0) + return ; + assert(self->ob_refcnt == 0); + self->ob_refcnt = 1; + __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); + res = __Pyx_Generator_Close(self); + if (res == NULL) + PyErr_WriteUnraisable(self); + else + Py_DECREF(res); + __Pyx_ErrRestore(error_type, error_value, error_traceback); + /* Undo the temporary resurrection; can't use DECREF here, it would + * cause a recursive call. + */ + assert(self->ob_refcnt > 0); + if (--self->ob_refcnt == 0) + return; /* this is the normal path out */ + /* close() resurrected it! Make it look like the original Py_DECREF + * never happened. + */ + { + Py_ssize_t refcnt = self->ob_refcnt; + _Py_NewReference(self); + self->ob_refcnt = refcnt; + } +#if CYTHON_COMPILING_IN_CPYTHON + assert(PyType_IS_GC(self->ob_type) && + _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); + /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so + * we need to undo that. */ + _Py_DEC_REFTOTAL; +#endif + /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object + * chain, so no more to do there. + * If COUNT_ALLOCS, the original decref bumped tp_frees, and + * _Py_NewReference bumped tp_allocs: both of those need to be + * undone. + */ +#ifdef COUNT_ALLOCS + --Py_TYPE(self)->tp_frees; + --Py_TYPE(self)->tp_allocs; +#endif +} +static PyMemberDef __pyx_Generator_memberlist[] = { + {(char *) "gi_running", +#if PY_VERSION_HEX >= 0x02060000 + T_BOOL, +#else + T_BYTE, +#endif + offsetof(__pyx_GeneratorObject, is_running), + READONLY, + NULL}, + {0, 0, 0, 0, 0} +}; +static PyMethodDef __pyx_Generator_methods[] = { + {__Pyx_NAMESTR("send"), (PyCFunction) __Pyx_Generator_Send, METH_O, 0}, + {__Pyx_NAMESTR("throw"), (PyCFunction) __Pyx_Generator_Throw, METH_VARARGS, 0}, + {__Pyx_NAMESTR("close"), (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; +static PyTypeObject __pyx_GeneratorType_type = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("generator"), /*tp_name*/ + sizeof(__pyx_GeneratorObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __Pyx_Generator_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ +#if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ +#else + 0, /*reserved*/ +#endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/ + 0, /*tp_doc*/ + (traverseproc) __Pyx_Generator_traverse, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + offsetof(__pyx_GeneratorObject, gi_weakreflist), /* tp_weaklistoffse */ + 0, /*tp_iter*/ + (iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/ + __pyx_Generator_methods, /*tp_methods*/ + __pyx_Generator_memberlist, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + __Pyx_Generator_del, /*tp_del*/ +#if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ +#endif +#if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ +#endif +}; +static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, + PyObject *closure) { + __pyx_GeneratorObject *gen = + PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType_type); + if (gen == NULL) + return NULL; + gen->body = body; + gen->closure = closure; + Py_XINCREF(closure); + gen->is_running = 0; + gen->resume_label = 0; + gen->classobj = NULL; + gen->yieldfrom = NULL; + gen->exc_type = NULL; + gen->exc_value = NULL; + gen->exc_traceback = NULL; + gen->gi_weakreflist = NULL; + PyObject_GC_Track(gen); + return gen; +} +static int __pyx_Generator_init(void) { + __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr; + __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; + if (PyType_Ready(&__pyx_GeneratorType_type)) { + return -1; + } + __pyx_GeneratorType = &__pyx_GeneratorType_type; + return 0; +} + +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + #if PY_VERSION_HEX < 0x02050000 + return PyErr_Warn(NULL, message); + #else + return PyErr_WarnEx(NULL, message, 1); + #endif + } + return 0; +} + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility", + module_name, class_name); + #if PY_VERSION_HEX < 0x02050000 + if (PyErr_Warn(NULL, warning) < 0) goto bad; + #else + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + #endif + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s has the wrong size, try recompiling", + module_name, class_name); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportFunction +#define __PYX_HAVE_RT_ImportFunction +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, funcname); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%s does not export expected C function %s", + PyModule_GetName(module), funcname); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); + goto bad; + } + tmp.p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, desc); + goto bad; + } + tmp.p = PyCObject_AsVoidPtr(cobj);} +#endif + *f = tmp.fp; + if (!(*f)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = (start + end) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, /*int firstlineno,*/ + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_globals = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else /* Python 3+ has unicode identifiers */ + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else /* PY_VERSION_HEX < 0x03030000 */ + if (PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_DATA_SIZE(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ + return PyUnicode_AsUTF8AndSize(o, length); +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ +#endif /* PY_VERSION_HEX < 0x03030000 */ + } else +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (r < 0) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return Py_INCREF(x), x; + m = Py_TYPE(x)->tp_as_number; +#if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%s__ returned non-%s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject* x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { +#if PY_VERSION_HEX < 0x02050000 + if (ival <= LONG_MAX) + return PyInt_FromLong((long)ival); + else { + unsigned char *bytes = (unsigned char *) &ival; + int one = 1; int little = (int)*(unsigned char*)&one; + return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); + } +#else + return PyInt_FromSize_t(ival); +#endif +} +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { + unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); + if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t)-1; + } + return (size_t)val; +} + + +#endif /* Py_PYTHON_H */ diff --git a/sklearn/earth/_basis.pxd b/sklearn/earth/_basis.pxd new file mode 100644 index 0000000000000..1d3dc1a93237f --- /dev/null +++ b/sklearn/earth/_basis.pxd @@ -0,0 +1,123 @@ +cimport numpy as cnp +ctypedef cnp.float64_t FLOAT_t +ctypedef cnp.intp_t INT_t +ctypedef cnp.ulong_t INDEX_t +ctypedef cnp.uint8_t BOOL_t + +cdef class BasisFunction: + '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + + cdef BasisFunction parent + cdef dict child_map + cdef list children + cdef bint pruned + cdef bint prunable + cdef bint splittable + + cpdef bint has_knot(BasisFunction self) + + cpdef bint is_prunable(BasisFunction self) + + cpdef bint is_pruned(BasisFunction self) + + cpdef bint is_splittable(BasisFunction self) + + cpdef bint make_splittable(BasisFunction self) + + cpdef bint make_unsplittable(BasisFunction self) + + cdef list get_children(BasisFunction self) + + cpdef _set_parent(self, BasisFunction parent) + + cpdef _add_child(self, BasisFunction child) + + cpdef BasisFunction get_parent(self) + + cpdef prune(self) + + cpdef unprune(self) + + cpdef knots(BasisFunction self, INDEX_t variable) + + cpdef INDEX_t degree(BasisFunction self) + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + + cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace) + + +cdef class ConstantBasisFunction(BasisFunction): + + cpdef INDEX_t degree(ConstantBasisFunction self) + + cpdef translate(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse) + + cpdef FLOAT_t scale(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts) + + cpdef _set_parent(self, BasisFunction parent) + + cpdef BasisFunction get_parent(self) + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + + +cdef class HingeBasisFunction(BasisFunction): + cdef FLOAT_t knot + cdef INDEX_t knot_idx + cdef INDEX_t variable + cdef bint reverse + cdef str label + + cpdef bint has_knot(HingeBasisFunction self) + + cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse) + + cpdef FLOAT_t scale(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts) + + cpdef INDEX_t get_variable(self) + + cpdef FLOAT_t get_knot(self) + + cpdef bint get_reverse(self) + + cpdef INDEX_t get_knot_idx(self) + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + +cdef class LinearBasisFunction(BasisFunction): + cdef INDEX_t variable + cdef str label + + cpdef translate(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse) + + cpdef FLOAT_t scale(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts) + + cpdef INDEX_t get_variable(self) + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + + +cdef class Basis: + '''A wrapper that provides functionality related to a set of BasisFunctions with a + common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + added.''' + + cdef list order + cdef readonly INDEX_t num_variables + + cpdef translate(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts) + + cpdef scale(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, cnp.ndarray[FLOAT_t, ndim=1] beta) + + cpdef BasisFunction get_root(Basis self) + + cpdef append(Basis self, BasisFunction basis_function) + + cpdef INDEX_t plen(Basis self) + + cpdef BasisFunction get(Basis self, INDEX_t i) + + cpdef transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B) + + cpdef weighted_transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights) diff --git a/sklearn/earth/_basis.pyx b/sklearn/earth/_basis.pyx new file mode 100644 index 0000000000000..622db3eed3f2f --- /dev/null +++ b/sklearn/earth/_basis.pyx @@ -0,0 +1,587 @@ +# distutils: language = c +# cython: cdivision = True +# cython: boundscheck = False +# cython: wraparound = False +# cython: profile = False + +from ._util cimport log2, apply_weights_2d +from libc.math cimport log +from libc.math cimport abs +cdef FLOAT_t ZERO_TOL = 1e-16 +import numpy as np + +cdef class BasisFunction: + + def __cinit__(BasisFunction self): + self.pruned = False + self.children = [] + self.prunable = True + self.child_map = {} + self.splittable = True + + def __reduce__(self): + return (self.__class__, (), self._getstate()) + + def _get_root(self): + return self.parent._get_root() + + def _getstate(self): + result = {'pruned': self.pruned, + 'children': self.children, + 'prunable': self.prunable, + 'child_map': self.child_map, + 'splittable': self.splittable} + result.update(self._get_parent_state()) + return result + + def _get_parent_state(self): + return {'parent': self.parent} + + def _set_parent_state(self, state): + self.parent = state['parent'] + + def __setstate__(self, state): + self.pruned = state['pruned'] + self.children = state['children'] + self.prunable = state['prunable'] + self.child_map = state['child_map'] + self.splittable = state['splittable'] + self._set_parent_state(state) + + def _eq(self, other): + if self.__class__ is not other.__class__: + return False + self_state = self._getstate() + other_state = other._getstate() + del self_state['children'] + del self_state['child_map'] + del other_state['children'] + del other_state['child_map'] + return self_state == other_state + + def __richcmp__(self, other, method): + if method == 2: + return self._eq(other) + elif method == 3: + return not self._eq(other) + else: + return NotImplemented + + cpdef bint has_knot(BasisFunction self): + return False + + cpdef bint is_prunable(BasisFunction self): + return self.prunable + + cpdef bint is_pruned(BasisFunction self): + return self.pruned + + cpdef bint is_splittable(BasisFunction self): + return self.splittable + + cpdef bint make_splittable(BasisFunction self): + self.splittable = True + + cpdef bint make_unsplittable(BasisFunction self): + self.splittable = False + + cdef list get_children(BasisFunction self): + return self.children + + cpdef _set_parent(self, BasisFunction parent): + '''Calls _add_child.''' + self.parent = parent + self.parent._add_child(self) + + cpdef _add_child(self, BasisFunction child): + '''Called by _set_parent.''' + cdef INDEX_t n = len(self.children) + self.children.append(child) + cdef int var = child.get_variable() + if var in self.child_map: + self.child_map[var].append(n) + else: + self.child_map[var] = [n] + + cpdef BasisFunction get_parent(self): + return self.parent + + cpdef prune(self): + self.pruned = True + + cpdef unprune(self): + self.pruned = False + + cpdef knots(BasisFunction self, INDEX_t variable): + + cdef list children + cdef BasisFunction child + if variable in self.child_map: + children = self.child_map[variable] + else: + return [] + cdef INDEX_t n = len(children) + cdef INDEX_t i + cdef list result = [] + cdef int idx + for i in range(n): + idx = children[i] + child = self.get_children()[idx] + if child.has_knot(): + result.append(child.get_knot_idx()) + return result + + cpdef INDEX_t degree(BasisFunction self): + return self.parent.degree() + 1 + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): + ''' + X - Data matrix + b - parent vector + recurse - If False, assume b already contains the result of the parent function. Otherwise, recurse to compute + parent function. + ''' + + cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace): + ''' + values - The unsorted values of self in the data set + variable - The sorted values of variable in the data set + variable_idx - The index of the variable in the data set + workspace - An m-vector (where m is the number of samples) used internally + ''' + cdef INDEX_t i + cdef INDEX_t j + cdef INDEX_t k + cdef INDEX_t m = values.shape[0] + cdef FLOAT_t float_tmp + cdef INT_t int_tmp + cdef INDEX_t count + cdef int minspan_ + cdef cnp.ndarray[INT_t, ndim = 1] result + cdef INDEX_t num_used + cdef INDEX_t prev + cdef INDEX_t start + cdef int idx + cdef int last_idx + cdef FLOAT_t first_var_value = variable[m - 1] + cdef FLOAT_t last_var_value = variable[m - 1] + + # Calculate the used knots + cdef list used_knots = self.knots(variable_idx) + used_knots.sort() + + # Initialize workspace to 1 where value is nonzero + # Also, find first_var_value as the maximum variable + # where value is nonzero and last_var_value to the + # minimum variable where value is nonzero + count = 0 + for i in range(m): + if abs(values[i]) > ZERO_TOL: + workspace[i] = 1 + count += 1 + if variable[i] >= first_var_value: + first_var_value = variable[i] + last_var_value = variable[i] + else: + workspace[i] = 0 + + # Calculate minspan + if minspan < 0: + minspan_ = (-log2(-(1.0 / (n * count)) * log(1.0 - minspan_alpha)) / 2.5) + else: + minspan_ = minspan + + # Take out the used points and apply minspan + num_used = len(used_knots) + prev = 0 + last_idx = -1 + for i in range(num_used): + idx = used_knots[i] + if last_idx == idx: + continue + workspace[idx] = 0 + j = idx + k = 0 + while j > prev + 1 and k < minspan_: + if workspace[j - 1]: + workspace[j - 1] = False + k += 1 + j -= 1 + j = idx + 1 + k = 0 + while j < m and k < minspan_: + if workspace[j]: + workspace[j] = False + k += 1 + j += 1 + prev = idx + last_idx = idx + + # Apply endspan + i = 0 + j = 0 + while i < endspan: + if workspace[j]: + workspace[j] = 0 + i += 1 + j += 1 + if j == m: + break + i = 0 + j = m - 1 + while i < endspan: + if workspace[j]: + workspace[j] = 0 + i += 1 + if j == 0: + break + j -= 1 + + # Implement check_every + int_tmp = 0 + count = 0 + for i in range(m): + if workspace[i]: + if (int_tmp % check_every) != 0: + workspace[i] = 0 + else: + count += 1 + int_tmp += 1 + else: + int_tmp = 0 + + # Make sure the greatest value is not a candidate (this can happen if + # the first endspan+1 values are the same) + for i in range(m): + if workspace[i]: + if variable[i] == first_var_value: + workspace[i] = 0 + count -= 1 + else: + break + + # Also make sure the least value is not a candidate + for i in range(m): + if workspace[m - i - 1]: + if variable[m - i - 1] == last_var_value: + workspace[m - i - 1] = 0 + count -= 1 + else: + break + + # Create result array and return + result = np.empty(shape=count, dtype=int) + j = 0 + for i in range(m): + if workspace[i]: + result[j] = i + j += 1 + + return result + +cdef class PicklePlaceHolderBasisFunction(BasisFunction): + '''This is a place holder for unpickling the basis function tree.''' + +pickle_place_holder = PicklePlaceHolderBasisFunction() + +cdef class ConstantBasisFunction(BasisFunction): + def __init__(self): # @DuplicatedSignature + self.prunable = False + + def _get_root(self): + return self + + def _get_parent_state(self): + return {} + + def _set_parent_state(self, state): + pass + + cpdef INDEX_t degree(ConstantBasisFunction self): + return 0 + + cpdef translate(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + pass + + cpdef FLOAT_t scale(ConstantBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + return < FLOAT_t > 1.0 + + cpdef _set_parent(self, BasisFunction parent): + raise NotImplementedError + + cpdef BasisFunction get_parent(self): + raise NotImplementedError + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=False): + ''' + X - Data matrix + b - parent vector + recurse - The ConstantBasisFunction is the parent of all BasisFunctions and never has a parent. + Therefore the recurse argument is ignored. This spares child BasisFunctions from + having to know whether their parents have parents. + ''' + cdef INDEX_t i # @DuplicatedSignature + cdef INDEX_t m = len(b) + for i in range(m): + b[i] = 1.0 + + def __str__(self): + return '(Intercept)' + +cdef class HingeBasisFunction(BasisFunction): + + #@DuplicatedSignature + def __init__(self, BasisFunction parent, FLOAT_t knot, INDEX_t knot_idx, INDEX_t variable, bint reverse, label=None): + self.knot = knot + self.knot_idx = knot_idx + self.variable = variable + self.reverse = reverse + self.label = label if label is not None else 'x' + str(variable) + self._set_parent(parent) + + def __reduce__(self): + return (self.__class__, (pickle_place_holder, 1.0, 1, 1, True, ''), self._getstate()) + + def _getstate(self): + result = super(HingeBasisFunction, self)._getstate() + result.update({'knot': self.knot, + 'knot_idx': self.knot_idx, + 'variable': self.variable, + 'reverse': self.reverse, + 'label': self.label}) + return result + + def __setstate__(self, state): + self.knot = state['knot'] + self.knot_idx = state['knot_idx'] + self.variable = state['variable'] + self.reverse = state['reverse'] + self.label = state['label'] + super(HingeBasisFunction, self).__setstate__(state) + + cpdef bint has_knot(HingeBasisFunction self): + return True + + cpdef translate(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + self.knot = slopes[self.variable] * \ + self.knot + intercepts[self.variable] + if slopes[self.variable] < 0: + self.reverse = not self.reverse + if recurse: + self.parent.translate(slopes, intercepts) + + cpdef FLOAT_t scale(HingeBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + result = self.parent.scale(slopes, intercepts) + result /= slopes[self.variable] + return result + + def __str__(self): + result = '' + if self.variable is not None: + if not self.reverse: + if self.knot >= 0: + result = 'h(%s-%G)' % (self.label, self.knot) + else: + result = 'h(%s+%G)' % (self.label, -self.knot) + else: + result = 'h(%G-%s)' % (self.knot, self.label) + parent = str( + self.parent) if not self.parent.__class__ is ConstantBasisFunction else '' + if parent != '': + result += '*%s' % (str(self.parent),) + return result + + cpdef INDEX_t get_variable(self): + return self.variable + + cpdef FLOAT_t get_knot(self): + return self.knot + + cpdef bint get_reverse(self): + return self.reverse + + cpdef INDEX_t get_knot_idx(self): + return self.knot_idx + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): + ''' + X - Data matrix + b - parent vector + recurse - If False, assume b already contains the result of the parent function. Otherwise, recurse to compute + parent function. + ''' + if recurse: + self.parent.apply(X, b, recurse=True) + cdef INDEX_t i # @DuplicatedSignature + cdef INDEX_t m = len(b) # @DuplicatedSignature + cdef FLOAT_t tmp + if self.reverse: + for i in range(m): + tmp = self.knot - X[i, self.variable] + if tmp < 0: + tmp = 0.0 + b[i] *= tmp + else: + for i in range(m): + tmp = X[i, self.variable] - self.knot + if tmp < 0: + tmp = 0.0 + b[i] *= tmp + +cdef class LinearBasisFunction(BasisFunction): + #@DuplicatedSignature + def __init__(self, BasisFunction parent, INDEX_t variable, label=None): + self.variable = variable + self.label = label if label is not None else 'x' + str(variable) + self._set_parent(parent) + + def __reduce__(self): + return (self.__class__, (pickle_place_holder, 1, ''), self._getstate()) + + def _getstate(self): + result = super(LinearBasisFunction, self)._getstate() + result.update({'variable': self.variable, + 'label': self.label}) + return result + + def __setstate__(self, state): + self.variable = state['variable'] + self.label = state['label'] + super(LinearBasisFunction, self).__setstate__(state) + + cpdef translate(LinearBasisFunctionself, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, bint recurse): + pass + + cpdef FLOAT_t scale(LinearBasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + result = self.parent.scale(slopes, intercepts) + result /= slopes[self.variable] + return result + + def __str__(LinearBasisFunction self): + result = self.label + if not self.parent.__class__ is ConstantBasisFunction: + parent = str(self.parent) + result += '*' + parent + return result + + cpdef INDEX_t get_variable(self): + return self.variable + + cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse=True): + ''' + X - Data matrix + b - parent vector + recurse - If False, assume b already contains the result of the parent function. Otherwise, recurse to compute + parent function. + ''' + if recurse: + self.parent.apply(X, b, recurse=True) + cdef INDEX_t i # @DuplicatedSignature + cdef INDEX_t m = len(b) # @DuplicatedSignature + for i in range(m): + b[i] *= X[i, self.variable] + +cdef class Basis: + '''A container that provides functionality related to a set of BasisFunctions with a + common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + added.''' + + def __init__(Basis self, num_variables): # @DuplicatedSignature + self.order = [] + self.num_variables = num_variables + + def __reduce__(self): + return (self.__class__, (self.num_variables,), self._getstate()) + + def _getstate(self): + return {'order': self.order} + + def __setstate__(self, state): + self.order = state['order'] + + def __richcmp__(self, other, method): + if method == 2: + return self._eq(other) + elif method == 3: + return not self._eq(other) + else: + return NotImplemented + + def _eq(self, other): + return self.__class__ is other.__class__ and self._getstate() == other._getstate() + + def piter(Basis self): + for bf in self.order: + if not bf.is_pruned(): + yield bf + + def __str__(Basis self): + cdef INDEX_t i + cdef INDEX_t n = len(self) + result = '' + for i in range(n): + result += str(self[i]) + result += '\n' + return result + + cpdef translate(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts): + cdef INDEX_t n = len(self) + cdef INDEX_t i # @DuplicatedSignature + for i in range(n): + self.order[i].translate(slopes, intercepts, False) + + cpdef scale(Basis self, cnp.ndarray[FLOAT_t, ndim=1] slopes, cnp.ndarray[FLOAT_t, ndim=1] intercepts, cnp.ndarray[FLOAT_t, ndim=1] beta): + cdef INDEX_t n = len(self) # @DuplicatedSignature + cdef INDEX_t i # @DuplicatedSignature + cdef INDEX_t j = 0 + for i in range(n): + if self.order[i].is_pruned(): + continue + beta[j] *= self.order[i].scale(slopes, intercepts) + j += 1 + + cpdef BasisFunction get_root(Basis self): + return self.root + + cpdef append(Basis self, BasisFunction basis_function): + self.order.append(basis_function) + + def __iter__(Basis self): + return self.order.__iter__() + + def __len__(Basis self): + return self.order.__len__() + + cpdef BasisFunction get(Basis self, INDEX_t i): + return self.order[i] + + def __getitem__(Basis self, INDEX_t i): + return self.get(i) + + cpdef INDEX_t plen(Basis self): + cdef INDEX_t length = 0 + cdef INDEX_t i + cdef INDEX_t n = len(self.order) + for i in range(n): + if not self.order[i].is_pruned(): + length += 1 + return length + + cpdef transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B): + cdef INDEX_t i # @DuplicatedSignature + cdef INDEX_t n = self.__len__() + cdef BasisFunction bf + cdef INDEX_t col = 0 + for i in range(n): + bf = self.order[i] + if bf.is_pruned(): + continue + bf.apply(X, B[:, col], recurse=True) + col += 1 + + cpdef weighted_transform(Basis self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): + cdef INDEX_t i # @DuplicatedSignature + cdef INDEX_t n = self.__len__() + + self.transform(X, B) + apply_weights_2d(B, weights) diff --git a/sklearn/earth/_forward.c b/sklearn/earth/_forward.c new file mode 100644 index 0000000000000..50790c1cb1f28 --- /dev/null +++ b/sklearn/earth/_forward.c @@ -0,0 +1,14327 @@ +/* Generated by Cython 0.19.2 on Sat Nov 30 16:32:13 2013 */ + +#define PY_SSIZE_T_CLEAN +#ifndef CYTHON_USE_PYLONG_INTERNALS +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 0 +#else +#include "pyconfig.h" +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 1 +#else +#define CYTHON_USE_PYLONG_INTERNALS 0 +#endif +#endif +#endif +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02040000 + #error Cython requires Python 2.4+. +#else +#include /* For offsetof */ +#ifndef offsetof +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION +#define CYTHON_COMPILING_IN_PYPY 1 +#define CYTHON_COMPILING_IN_CPYTHON 0 +#else +#define CYTHON_COMPILING_IN_PYPY 0 +#define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if PY_VERSION_HEX < 0x02050000 + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ + (PyErr_Format(PyExc_TypeError, \ + "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ + (PyObject*)0)) + #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ + !PyComplex_Check(o)) + #define PyIndex_Check __Pyx_PyIndex_Check + #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) + #define __PYX_BUILD_PY_SSIZE_T "i" +#else + #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" + #define __Pyx_PyIndex_Check PyIndex_Check +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) + #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) + #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + #define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + #define PyType_Modified(t) + typedef struct { + void *buf; + PyObject *obj; + Py_ssize_t len; + Py_ssize_t itemsize; + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; + } Py_buffer; + #define PyBUF_SIMPLE 0 + #define PyBUF_WRITABLE 0x0001 + #define PyBUF_FORMAT 0x0004 + #define PyBUF_ND 0x0008 + #define PyBUF_STRIDES (0x0010 | PyBUF_ND) + #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) + #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) + #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) + #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) + #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) + typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); + typedef void (*releasebufferproc)(PyObject *, Py_buffer *); +#endif +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif +#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 + #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") +#endif +#if PY_MAJOR_VERSION >= 3 + #define Py_TPFLAGS_CHECKTYPES 0 + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_TPFLAGS_HAVE_VERSION_TAG 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PyBytesObject PyStringObject + #define PyBytes_Type PyString_Type + #define PyBytes_Check PyString_Check + #define PyBytes_CheckExact PyString_CheckExact + #define PyBytes_FromString PyString_FromString + #define PyBytes_FromStringAndSize PyString_FromStringAndSize + #define PyBytes_FromFormat PyString_FromFormat + #define PyBytes_DecodeEscape PyString_DecodeEscape + #define PyBytes_AsString PyString_AsString + #define PyBytes_AsStringAndSize PyString_AsStringAndSize + #define PyBytes_Size PyString_Size + #define PyBytes_AS_STRING PyString_AS_STRING + #define PyBytes_GET_SIZE PyString_GET_SIZE + #define PyBytes_Repr PyString_Repr + #define PyBytes_Concat PyString_Concat + #define PyBytes_ConcatAndDel PyString_ConcatAndDel +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ + PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) + #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) + #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) + #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) +#else + #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) + #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) +#else + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_NAMESTR(n) ((char *)(n)) + #define __Pyx_DOCSTR(n) ((char *)(n)) +#else + #define __Pyx_NAMESTR(n) (n) + #define __Pyx_DOCSTR(n) (n) +#endif +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + a quiet NaN. */ + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif + + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) +#define _USE_MATH_DEFINES +#endif +#include +#define __PYX_HAVE__sklearn__earth___forward +#define __PYX_HAVE_API__sklearn__earth___forward +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#include "math.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) +#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) +#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return u_end - u - 1; +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + const char* default_encoding_c = PyBytes_AS_STRING(default_encoding); + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (ascii_chars_u == NULL) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + } + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + default_encoding_c = PyBytes_AS_STRING(default_encoding); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(sys); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +#ifdef __GNUC__ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ +#else /* __GNUC__ */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "_forward.pyx", + "numpy.pxd", + "type.pxd", + "_basis.pxd", + "_record.pxd", +}; +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; /* for error messages only */ + struct __Pyx_StructField_* fields; + size_t size; /* sizeof(type) */ + size_t arraysize[8]; /* length of array in each dimension */ + int ndim; + char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */ + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "numpy.pxd":723 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "numpy.pxd":724 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "numpy.pxd":725 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "numpy.pxd":726 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "numpy.pxd":730 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "numpy.pxd":731 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "numpy.pxd":732 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "numpy.pxd":733 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "numpy.pxd":737 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "numpy.pxd":738 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "numpy.pxd":747 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "numpy.pxd":748 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "numpy.pxd":749 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "numpy.pxd":751 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "numpy.pxd":752 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "numpy.pxd":753 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "numpy.pxd":755 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "numpy.pxd":756 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "numpy.pxd":758 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "numpy.pxd":759 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "numpy.pxd":760 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "_basis.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_6_basis_FLOAT_t; + +/* "_basis.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_6_basis_INT_t; + +/* "_basis.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_6_basis_INDEX_t; + +/* "_basis.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef class BasisFunction: + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_6_basis_BOOL_t; + +/* "_record.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_7_record_FLOAT_t; + +/* "_record.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_7_record_INT_t; + +/* "_record.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * from _basis cimport Basis + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_7_record_INDEX_t; + +/* "_record.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * from _basis cimport Basis + * + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_7_record_BOOL_t; + +/* "_util.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_5_util_FLOAT_t; + +/* "_util.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_5_util_INT_t; + +/* "_util.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_5_util_INDEX_t; + +/* "_util.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef FLOAT_t log2(FLOAT_t x) + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_5_util_BOOL_t; + +/* "sklearn/earth/_forward.pxd":3 + * cimport numpy as cnp + * import numpy as np + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_8_forward_FLOAT_t; + +/* "sklearn/earth/_forward.pxd":4 + * import numpy as np + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_8_forward_INT_t; + +/* "sklearn/earth/_forward.pxd":5 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * from _basis cimport Basis + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_8_forward_INDEX_t; + +/* "sklearn/earth/_forward.pxd":6 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * from _basis cimport Basis + * from _record cimport ForwardPassRecord + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_8_forward_BOOL_t; +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis; +struct __pyx_obj_7sklearn_5earth_7_record_Iteration; +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration; +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction; +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction; +struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser; +struct __pyx_obj_7sklearn_5earth_7_record_Record; +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord; +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord; +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction; +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration; +struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration; +struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration; +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction; + +/* "numpy.pxd":762 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "numpy.pxd":763 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "numpy.pxd":764 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "numpy.pxd":766 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply; + +/* "_basis.pxd":45 + * cpdef INDEX_t degree(BasisFunction self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace) + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":62 + * cpdef BasisFunction get_parent(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":86 + * cpdef INDEX_t get_knot_idx(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cdef class LinearBasisFunction(BasisFunction): + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":98 + * cpdef INDEX_t get_variable(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "sklearn/earth/_forward.pxd":10 + * from _record cimport ForwardPassRecord + * + * ctypedef enum StoppingCondition: # <<<<<<<<<<<<<< + * MAXTERMS = 0, + * MAXRSQ = 1, + */ +enum __pyx_t_7sklearn_5earth_8_forward_StoppingCondition { + __pyx_e_7sklearn_5earth_8_forward_MAXTERMS = 0, + __pyx_e_7sklearn_5earth_8_forward_MAXRSQ = 1, + __pyx_e_7sklearn_5earth_8_forward_NOIMPRV = 2, + __pyx_e_7sklearn_5earth_8_forward_LOWGRSQ = 3, + __pyx_e_7sklearn_5earth_8_forward_NOCAND = 4 +}; +typedef enum __pyx_t_7sklearn_5earth_8_forward_StoppingCondition __pyx_t_7sklearn_5earth_8_forward_StoppingCondition; + +/* "_basis.pxd":101 + * + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A wrapper that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtab; + PyObject *order; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t num_variables; +}; + + +/* "_record.pxd":41 + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition) + * + * cdef class Iteration: # <<<<<<<<<<<<<< + * cdef FLOAT_t mse + * cdef INDEX_t size + */ +struct __pyx_obj_7sklearn_5earth_7_record_Iteration { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *__pyx_vtab; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t mse; + __pyx_t_7sklearn_5earth_7_record_INDEX_t size; +}; + + +/* "_record.pxd":57 + * pass + * + * cdef class ForwardPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t parent + * cdef INDEX_t variable + */ +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t parent; + __pyx_t_7sklearn_5earth_7_record_INDEX_t variable; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t knot; + int code; + int no_candidates; +}; + + +/* "_basis.pxd":7 + * ctypedef cnp.uint8_t BOOL_t + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + * + */ +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtab; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *parent; + PyObject *child_map; + PyObject *children; + int pruned; + int prunable; + int splittable; +}; + + +/* "_basis.pxd":50 + * + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(ConstantBasisFunction self) + */ +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; +}; + + +/* "sklearn/earth/_forward.pxd":19 + * cdef dict stopping_conditions + * + * cdef class ForwardPasser: # <<<<<<<<<<<<<< + * + * # User selected parameters + */ +struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *__pyx_vtab; + int endspan; + int minspan; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t endspan_alpha; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t minspan_alpha; + int max_terms; + int allow_linear; + int max_degree; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t thresh; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t penalty; + int check_every; + int min_search_points; + PyObject *xlabels; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t zero_tol; + PyArrayObject *X; + PyArrayObject *y; + PyArrayObject *sample_weight; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t m; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t n; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t sst; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t y_squared; + PyArrayObject *B; + PyArrayObject *B_orth; + PyArrayObject *c; + PyArrayObject *norms; + PyArrayObject *u; + PyArrayObject *B_orth_times_parent_cum; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t c_squared; + PyArrayObject *sort_tracker; + PyArrayObject *sorting; + PyArrayObject *mwork; + PyArrayObject *linear_variables; + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *record; + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *basis; +}; + + +/* "_record.pxd":8 + * from _basis cimport Basis + * + * cdef class Record: # <<<<<<<<<<<<<< + * cdef list iterations + * cdef int num_samples + */ +struct __pyx_obj_7sklearn_5earth_7_record_Record { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *__pyx_vtab; + PyObject *iterations; + int num_samples; + int num_variables; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t penalty; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t sst; +}; + + +/* "_record.pxd":25 + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration) + * + * cdef class PruningPassRecord(Record): # <<<<<<<<<<<<<< + * cdef INDEX_t selected + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord { + struct __pyx_obj_7sklearn_5earth_7_record_Record __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t selected; +}; + + +/* "_record.pxd":34 + * cpdef roll_back(PruningPassRecord self, Basis basis) + * + * cdef class ForwardPassRecord(Record): # <<<<<<<<<<<<<< + * cdef int stopping_condition + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord { + struct __pyx_obj_7sklearn_5earth_7_record_Record __pyx_base; + int stopping_condition; + PyObject *xlabels; +}; + + +/* "_basis.pxd":88 + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef str label + */ +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + PyObject *label; +}; + + +/* "_record.pxd":49 + * cpdef INDEX_t get_size(Iteration self) + * + * cdef class PruningPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t pruned + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t pruned; +}; + + +/* "_record.pxd":54 + * cpdef INDEX_t get_pruned(PruningPassIteration self) + * + * cdef class FirstPruningPassIteration(PruningPassIteration): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration __pyx_base; +}; + + +/* "_record.pxd":68 + * cpdef no_further_candidates(ForwardPassIteration self) + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): # <<<<<<<<<<<<<< + * cpdef INDEX_t get_size(FirstForwardPassIteration self) + */ +struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration __pyx_base; +}; + + +/* "_basis.pxd":65 + * + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef FLOAT_t knot + * cdef INDEX_t knot_idx + */ +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t knot; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t knot_idx; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + int reverse; + PyObject *label; +}; + + + +/* "_record.pxd":41 + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition) + * + * cdef class Iteration: # <<<<<<<<<<<<<< + * cdef FLOAT_t mse + * cdef INDEX_t size + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*get_mse)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_size)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *__pyx_vtabptr_7sklearn_5earth_7_record_Iteration; + + +/* "_record.pxd":49 + * cpdef INDEX_t get_size(Iteration self) + * + * cdef class PruningPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t pruned + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_pruned)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration; + + +/* "_basis.pxd":7 + * ctypedef cnp.uint8_t BOOL_t + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction { + int (*has_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_prunable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_pruned)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_unsplittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*get_children)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *); + PyObject *(*_set_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*_add_child)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*prune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*unprune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*degree)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*apply)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args); + PyArrayObject *(*valid_knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int, int, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + + +/* "_basis.pxd":88 + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef str label + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction; + + +/* "_record.pxd":8 + * from _basis cimport Basis + * + * cdef class Record: # <<<<<<<<<<<<<< + * cdef list iterations + * cdef int num_samples + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record { + PyObject *(*append)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*mse)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*rsq)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*gcv)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*grsq)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *__pyx_vtabptr_7sklearn_5earth_7_record_Record; + + +/* "_record.pxd":34 + * cpdef roll_back(PruningPassRecord self, Basis basis) + * + * cdef class ForwardPassRecord(Record): # <<<<<<<<<<<<<< + * cdef int stopping_condition + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record __pyx_base; + PyObject *(*set_stopping_condition)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *, int, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord; + + +/* "_basis.pxd":65 + * + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef FLOAT_t knot + * cdef INDEX_t knot_idx + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*get_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + int (*get_reverse)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_knot_idx)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction; + + +/* "_basis.pxd":50 + * + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(ConstantBasisFunction self) + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction; + + +/* "_record.pxd":25 + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration) + * + * cdef class PruningPassRecord(Record): # <<<<<<<<<<<<<< + * cdef INDEX_t selected + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record __pyx_base; + PyObject *(*set_selected)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_selected)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, int __pyx_skip_dispatch); + PyObject *(*roll_back)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord; + + +/* "_record.pxd":57 + * pass + * + * cdef class ForwardPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t parent + * cdef INDEX_t variable + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration __pyx_base; + PyObject *(*set_no_candidates)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int, int __pyx_skip_dispatch); + PyObject *(*no_further_candidates)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration; + + +/* "sklearn/earth/_forward.pyx":23 + * } + * + * cdef class ForwardPasser: # <<<<<<<<<<<<<< + * + * def __init__(ForwardPasser self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] sample_weight, **kwargs): + */ + +struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser { + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *(*get_basis)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch); + PyObject *(*init_linear_variables)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch); + PyObject *(*run)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch); + PyObject *(*stop_check)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *); + int (*orthonormal_update)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*orthonormal_downdate)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*next_pair)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *); + PyObject *(*best_knot)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, PyArrayObject *, PyArrayObject *, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t *); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *__pyx_vtabptr_7sklearn_5earth_8_forward_ForwardPasser; + + +/* "_basis.pxd":101 + * + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A wrapper that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis { + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_root)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + PyObject *(*append)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*plen)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*weighted_transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtabptr_7sklearn_5earth_6_basis_Basis; + + +/* "_record.pxd":68 + * cpdef no_further_candidates(ForwardPassIteration self) + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): # <<<<<<<<<<<<<< + * cpdef INDEX_t get_size(FirstForwardPassIteration self) + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration; + + +/* "_record.pxd":54 + * cpdef INDEX_t get_pruned(PruningPassIteration self) + * + * cdef class FirstPruningPassIteration(PruningPassIteration): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration; +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static CYTHON_INLINE int __Pyx_PyDict_Contains(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) + PyErr_SetObject(PyExc_KeyError, args); + Py_XDECREF(args); + } + return NULL; + } + Py_INCREF(value); + return value; +} +#else + #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#endif + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/ + +#define __Pyx_SetItemInt(o, i, v, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_SetItemInt_Fast(o, i, v, is_list, wraparound, boundscheck) : \ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v)) +static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck); + +static CYTHON_INLINE int __Pyx_PySequence_Contains(PyObject* item, PyObject* seq, int eq) { + int result = PySequence_Contains(seq, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ + +#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +static void __Pyx_RaiseBufferFallbackError(void); /*proto*/ + +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) +#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ + +#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) \ + __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) +static CYTHON_INLINE int __Pyx_PyObject_SetSlice( + PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** py_start, PyObject** py_stop, PyObject** py_slice, + int has_cstart, int has_cstop, int wraparound); + +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ + +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; +static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject *); + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong); + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); + +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); + +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); + +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); + +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); + +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); + +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); + +static int __Pyx_check_binary_version(void); + +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_setattr)) + return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); +#endif + return PyObject_SetAttr(obj, attr_name, value); +} +#else +#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) +#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) +#endif + +static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig); /*proto*/ + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/ + +typedef struct { + int code_line; + PyCodeObject* code_object; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'sklearn.earth._basis' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_Basis = 0; + +/* Module declarations from 'sklearn.earth._record' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_Record = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_Iteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration = 0; + +/* Module declarations from 'sklearn.earth._util' */ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t (*__pyx_f_7sklearn_5earth_5_util_log2)(__pyx_t_7sklearn_5earth_5_util_FLOAT_t); /*proto*/ +static PyObject *(*__pyx_f_7sklearn_5earth_5_util_apply_weights_slice)(PyArrayObject *, PyArrayObject *, __pyx_t_7sklearn_5earth_5_util_INDEX_t, int __pyx_skip_dispatch); /*proto*/ +static PyObject *(*__pyx_f_7sklearn_5earth_5_util_apply_weights_1d)(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t (*__pyx_f_7sklearn_5earth_5_util_gcv_adjust)(__pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch); /*proto*/ + +/* Module declarations from 'libc.math' */ + +/* Module declarations from 'sklearn.earth._forward' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_8_forward_ForwardPasser = 0; +static PyObject *__pyx_v_7sklearn_5earth_8_forward_stopping_conditions = 0; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t = { "FLOAT_t", NULL, sizeof(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t), { 0 }, 0, 'R', 0, 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t = { "INT_t", NULL, sizeof(__pyx_t_7sklearn_5earth_8_forward_INT_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_7sklearn_5earth_8_forward_INT_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_7sklearn_5earth_8_forward_INT_t), 0 }; +#define __Pyx_MODULE_NAME "sklearn.earth._forward" +int __pyx_module_is_main_sklearn__earth___forward = 0; + +/* Implementation of 'sklearn.earth._forward' */ +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_IndexError; +static PyObject *__pyx_builtin_round; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static int __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser___init__(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_sample_weight, PyObject *__pyx_v_kwargs); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_2get_basis(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_4init_linear_variables(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_6get_B_orth(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_8run(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_10orthonormal_update(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_12orthonormal_downdate(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_14trace(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_tp_new_7sklearn_5earth_8_forward_ForwardPasser(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static char __pyx_k_4[] = "Unknown variable selected in linvars argument."; +static char __pyx_k_6[] = "init_linear_variables"; +static char __pyx_k_9[] = "no_further_candidates"; +static char __pyx_k_10[] = "orthonormal_downdate"; +static char __pyx_k_26[] = "ndarray is not C contiguous"; +static char __pyx_k_28[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_30[] = "Non-native byte order not supported"; +static char __pyx_k_32[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_33[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_36[] = "Format string allocated too short."; +static char __pyx_k_38[] = "Reached maximum number of terms"; +static char __pyx_k_39[] = "Achieved RSQ value within threshold of 1"; +static char __pyx_k_40[] = "Improvement below threshold"; +static char __pyx_k_41[] = "GRSQ too low"; +static char __pyx_k_42[] = "No remaining candidate knot locations"; +static char __pyx_k__B[] = "B"; +static char __pyx_k__C[] = "C"; +static char __pyx_k__H[] = "H"; +static char __pyx_k__I[] = "I"; +static char __pyx_k__L[] = "L"; +static char __pyx_k__O[] = "O"; +static char __pyx_k__Q[] = "Q"; +static char __pyx_k__X[] = "X"; +static char __pyx_k__b[] = "b"; +static char __pyx_k__d[] = "d"; +static char __pyx_k__f[] = "f"; +static char __pyx_k__g[] = "g"; +static char __pyx_k__h[] = "h"; +static char __pyx_k__i[] = "i"; +static char __pyx_k__l[] = "l"; +static char __pyx_k__q[] = "q"; +static char __pyx_k__x[] = "x"; +static char __pyx_k__y[] = "y"; +static char __pyx_k__Zd[] = "Zd"; +static char __pyx_k__Zf[] = "Zf"; +static char __pyx_k__Zg[] = "Zg"; +static char __pyx_k__np[] = "np"; +static char __pyx_k__dot[] = "dot"; +static char __pyx_k__int[] = "int"; +static char __pyx_k__nan[] = "nan"; +static char __pyx_k__run[] = "run"; +static char __pyx_k__sum[] = "sum"; +static char __pyx_k__copy[] = "copy"; +static char __pyx_k__ones[] = "ones"; +static char __pyx_k__sqrt[] = "sqrt"; +static char __pyx_k__dtype[] = "dtype"; +static char __pyx_k__empty[] = "empty"; +static char __pyx_k__float[] = "float"; +static char __pyx_k__index[] = "index"; +static char __pyx_k__numpy[] = "numpy"; +static char __pyx_k__order[] = "order"; +static char __pyx_k__range[] = "range"; +static char __pyx_k__round[] = "round"; +static char __pyx_k__shape[] = "shape"; +static char __pyx_k__zeros[] = "zeros"; +static char __pyx_k__thresh[] = "thresh"; +static char __pyx_k____len__[] = "__len__"; +static char __pyx_k__argsort[] = "argsort"; +static char __pyx_k__endspan[] = "endspan"; +static char __pyx_k__linvars[] = "linvars"; +static char __pyx_k__minspan[] = "minspan"; +static char __pyx_k__penalty[] = "penalty"; +static char __pyx_k__xlabels[] = "xlabels"; +static char __pyx_k____main__[] = "__main__"; +static char __pyx_k____test__[] = "__test__"; +static char __pyx_k__get_size[] = "get_size"; +static char __pyx_k__get_basis[] = "get_basis"; +static char __pyx_k__max_terms[] = "max_terms"; +static char __pyx_k__IndexError[] = "IndexError"; +static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k____import__[] = "__import__"; +static char __pyx_k__max_degree[] = "max_degree"; +static char __pyx_k__check_every[] = "check_every"; +static char __pyx_k__RuntimeError[] = "RuntimeError"; +static char __pyx_k____pyx_capi__[] = "__pyx_capi__"; +static char __pyx_k__allow_linear[] = "allow_linear"; +static char __pyx_k__endspan_alpha[] = "endspan_alpha"; +static char __pyx_k__minspan_alpha[] = "minspan_alpha"; +static char __pyx_k__sample_weight[] = "sample_weight"; +static char __pyx_k____pyx_vtable__[] = "__pyx_vtable__"; +static char __pyx_k____pyx_getbuffer[] = "__pyx_getbuffer"; +static char __pyx_k__min_search_points[] = "min_search_points"; +static char __pyx_k__set_no_candidates[] = "set_no_candidates"; +static char __pyx_k__orthonormal_update[] = "orthonormal_update"; +static char __pyx_k____pyx_releasebuffer[] = "__pyx_releasebuffer"; +static char __pyx_k__stopping_conditions[] = "stopping_conditions"; +static PyObject *__pyx_n_s_10; +static PyObject *__pyx_kp_u_26; +static PyObject *__pyx_kp_u_28; +static PyObject *__pyx_kp_u_30; +static PyObject *__pyx_kp_u_32; +static PyObject *__pyx_kp_u_33; +static PyObject *__pyx_kp_u_36; +static PyObject *__pyx_kp_s_38; +static PyObject *__pyx_kp_s_39; +static PyObject *__pyx_kp_s_4; +static PyObject *__pyx_kp_s_40; +static PyObject *__pyx_kp_s_41; +static PyObject *__pyx_kp_s_42; +static PyObject *__pyx_n_s_6; +static PyObject *__pyx_n_s_9; +static PyObject *__pyx_n_s__C; +static PyObject *__pyx_n_s__IndexError; +static PyObject *__pyx_n_s__RuntimeError; +static PyObject *__pyx_n_s__ValueError; +static PyObject *__pyx_n_s__X; +static PyObject *__pyx_n_s____import__; +static PyObject *__pyx_n_s____len__; +static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____pyx_capi__; +static PyObject *__pyx_n_s____pyx_getbuffer; +static PyObject *__pyx_n_s____pyx_releasebuffer; +static PyObject *__pyx_n_s____pyx_vtable__; +static PyObject *__pyx_n_s____test__; +static PyObject *__pyx_n_s__allow_linear; +static PyObject *__pyx_n_s__argsort; +static PyObject *__pyx_n_s__check_every; +static PyObject *__pyx_n_s__copy; +static PyObject *__pyx_n_s__dot; +static PyObject *__pyx_n_s__dtype; +static PyObject *__pyx_n_s__empty; +static PyObject *__pyx_n_s__endspan; +static PyObject *__pyx_n_s__endspan_alpha; +static PyObject *__pyx_n_s__float; +static PyObject *__pyx_n_s__get_basis; +static PyObject *__pyx_n_s__get_size; +static PyObject *__pyx_n_s__index; +static PyObject *__pyx_n_s__int; +static PyObject *__pyx_n_s__linvars; +static PyObject *__pyx_n_s__max_degree; +static PyObject *__pyx_n_s__max_terms; +static PyObject *__pyx_n_s__min_search_points; +static PyObject *__pyx_n_s__minspan; +static PyObject *__pyx_n_s__minspan_alpha; +static PyObject *__pyx_n_s__nan; +static PyObject *__pyx_n_s__np; +static PyObject *__pyx_n_s__numpy; +static PyObject *__pyx_n_s__ones; +static PyObject *__pyx_n_s__order; +static PyObject *__pyx_n_s__orthonormal_update; +static PyObject *__pyx_n_s__penalty; +static PyObject *__pyx_n_s__range; +static PyObject *__pyx_n_s__round; +static PyObject *__pyx_n_s__run; +static PyObject *__pyx_n_s__sample_weight; +static PyObject *__pyx_n_s__set_no_candidates; +static PyObject *__pyx_n_s__shape; +static PyObject *__pyx_n_s__sqrt; +static PyObject *__pyx_n_s__stopping_conditions; +static PyObject *__pyx_n_s__sum; +static PyObject *__pyx_n_s__thresh; +static PyObject *__pyx_n_s__x; +static PyObject *__pyx_n_s__xlabels; +static PyObject *__pyx_n_s__y; +static PyObject *__pyx_n_s__zeros; +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_neg_1; +static PyObject *__pyx_int_15; +static PyObject *__pyx_int_100; +static PyObject *__pyx_k_slice_1; +static PyObject *__pyx_k_slice_2; +static PyObject *__pyx_k_slice_7; +static PyObject *__pyx_k_slice_8; +static PyObject *__pyx_k_tuple_3; +static PyObject *__pyx_k_tuple_5; +static PyObject *__pyx_k_slice_11; +static PyObject *__pyx_k_slice_12; +static PyObject *__pyx_k_slice_13; +static PyObject *__pyx_k_slice_14; +static PyObject *__pyx_k_slice_15; +static PyObject *__pyx_k_slice_16; +static PyObject *__pyx_k_slice_17; +static PyObject *__pyx_k_slice_18; +static PyObject *__pyx_k_slice_19; +static PyObject *__pyx_k_slice_20; +static PyObject *__pyx_k_slice_21; +static PyObject *__pyx_k_slice_22; +static PyObject *__pyx_k_slice_23; +static PyObject *__pyx_k_slice_24; +static PyObject *__pyx_k_slice_25; +static PyObject *__pyx_k_tuple_27; +static PyObject *__pyx_k_tuple_29; +static PyObject *__pyx_k_tuple_31; +static PyObject *__pyx_k_tuple_34; +static PyObject *__pyx_k_tuple_35; +static PyObject *__pyx_k_tuple_37; + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_y = 0; + PyArrayObject *__pyx_v_sample_weight = 0; + PyObject *__pyx_v_kwargs = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1; + __Pyx_GOTREF(__pyx_v_kwargs); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__y,&__pyx_n_s__sample_weight,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_weight)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __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_X = ((PyArrayObject *)values[0]); + __pyx_v_y = ((PyArrayObject *)values[1]); + __pyx_v_sample_weight = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_weight), __pyx_ptype_5numpy_ndarray, 1, "sample_weight", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser___init__(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self), __pyx_v_X, __pyx_v_y, __pyx_v_sample_weight, __pyx_v_kwargs); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_kwargs); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":25 + * cdef class ForwardPasser: + * + * def __init__(ForwardPasser self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] sample_weight, **kwargs): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * self.X = X + */ + +static int __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser___init__(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_sample_weight, PyObject *__pyx_v_kwargs) { + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_i; + PyObject *__pyx_v_linvar = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_sample_weight; + __Pyx_Buffer __pyx_pybuffer_sample_weight; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_t_6; + int __pyx_t_7; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_8; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_9; + long __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + Py_ssize_t __pyx_t_14; + PyObject *(*__pyx_t_15)(PyObject *); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_sample_weight.pybuffer.buf = NULL; + __pyx_pybuffer_sample_weight.refcount = 0; + __pyx_pybuffernd_sample_weight.data = NULL; + __pyx_pybuffernd_sample_weight.rcbuffer = &__pyx_pybuffer_sample_weight; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sample_weight.rcbuffer->pybuffer, (PyObject*)__pyx_v_sample_weight, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_sample_weight.diminfo[0].strides = __pyx_pybuffernd_sample_weight.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sample_weight.diminfo[0].shape = __pyx_pybuffernd_sample_weight.rcbuffer->pybuffer.shape[0]; + + /* "sklearn/earth/_forward.pyx":27 + * def __init__(ForwardPasser self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] sample_weight, **kwargs): + * cdef INDEX_t i + * self.X = X # <<<<<<<<<<<<<< + * self.y = y.copy() + * self.sample_weight = sample_weight + */ + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_GOTREF(__pyx_v_self->X); + __Pyx_DECREF(((PyObject *)__pyx_v_self->X)); + __pyx_v_self->X = ((PyArrayObject *)__pyx_v_X); + + /* "sklearn/earth/_forward.pyx":28 + * cdef INDEX_t i + * self.X = X + * self.y = y.copy() # <<<<<<<<<<<<<< + * self.sample_weight = sample_weight + * apply_weights_1d(self.y, self.sample_weight) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->y); + __Pyx_DECREF(((PyObject *)__pyx_v_self->y)); + __pyx_v_self->y = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":29 + * self.X = X + * self.y = y.copy() + * self.sample_weight = sample_weight # <<<<<<<<<<<<<< + * apply_weights_1d(self.y, self.sample_weight) + * self.m = self.X.shape[0] + */ + __Pyx_INCREF(((PyObject *)__pyx_v_sample_weight)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_sample_weight)); + __Pyx_GOTREF(__pyx_v_self->sample_weight); + __Pyx_DECREF(((PyObject *)__pyx_v_self->sample_weight)); + __pyx_v_self->sample_weight = ((PyArrayObject *)__pyx_v_sample_weight); + + /* "sklearn/earth/_forward.pyx":30 + * self.y = y.copy() + * self.sample_weight = sample_weight + * apply_weights_1d(self.y, self.sample_weight) # <<<<<<<<<<<<<< + * self.m = self.X.shape[0] + * self.n = self.X.shape[1] + */ + __pyx_t_2 = ((PyObject *)__pyx_v_self->y); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_1 = ((PyObject *)__pyx_v_self->sample_weight); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_f_7sklearn_5earth_5_util_apply_weights_1d(((PyArrayObject *)__pyx_t_2), ((PyArrayObject *)__pyx_t_1), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":31 + * self.sample_weight = sample_weight + * apply_weights_1d(self.y, self.sample_weight) + * self.m = self.X.shape[0] # <<<<<<<<<<<<<< + * self.n = self.X.shape[1] + * self.endspan = kwargs['endspan'] if 'endspan' in kwargs else -1 + */ + __pyx_v_self->m = (__pyx_v_self->X->dimensions[0]); + + /* "sklearn/earth/_forward.pyx":32 + * apply_weights_1d(self.y, self.sample_weight) + * self.m = self.X.shape[0] + * self.n = self.X.shape[1] # <<<<<<<<<<<<<< + * self.endspan = kwargs['endspan'] if 'endspan' in kwargs else -1 + * self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 + */ + __pyx_v_self->n = (__pyx_v_self->X->dimensions[1]); + + /* "sklearn/earth/_forward.pyx":33 + * self.m = self.X.shape[0] + * self.n = self.X.shape[1] + * self.endspan = kwargs['endspan'] if 'endspan' in kwargs else -1 # <<<<<<<<<<<<<< + * self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 + * self.endspan_alpha = kwargs[ + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__endspan), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__endspan)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(__pyx_int_neg_1); + __pyx_t_3 = __pyx_int_neg_1; + } + __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->endspan = __pyx_t_5; + + /* "sklearn/earth/_forward.pyx":34 + * self.n = self.X.shape[1] + * self.endspan = kwargs['endspan'] if 'endspan' in kwargs else -1 + * self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 # <<<<<<<<<<<<<< + * self.endspan_alpha = kwargs[ + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__minspan), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__minspan)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(__pyx_int_neg_1); + __pyx_t_3 = __pyx_int_neg_1; + } + __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->minspan = __pyx_t_5; + + /* "sklearn/earth/_forward.pyx":36 + * self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 + * self.endspan_alpha = kwargs[ + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 # <<<<<<<<<<<<<< + * self.minspan_alpha = kwargs[ + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__endspan_alpha), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + + /* "sklearn/earth/_forward.pyx":35 + * self.endspan = kwargs['endspan'] if 'endspan' in kwargs else -1 + * self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 + * self.endspan_alpha = kwargs[ # <<<<<<<<<<<<<< + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + * self.minspan_alpha = kwargs[ + */ + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__endspan_alpha)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + + /* "sklearn/earth/_forward.pyx":36 + * self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 + * self.endspan_alpha = kwargs[ + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 # <<<<<<<<<<<<<< + * self.minspan_alpha = kwargs[ + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + */ + __pyx_t_1 = PyFloat_FromDouble(.05); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":35 + * self.endspan = kwargs['endspan'] if 'endspan' in kwargs else -1 + * self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 + * self.endspan_alpha = kwargs[ # <<<<<<<<<<<<<< + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + * self.minspan_alpha = kwargs[ + */ + __pyx_v_self->endspan_alpha = __pyx_t_6; + + /* "sklearn/earth/_forward.pyx":38 + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + * self.minspan_alpha = kwargs[ + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 # <<<<<<<<<<<<<< + * self.max_terms = kwargs[ + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__minspan_alpha), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + + /* "sklearn/earth/_forward.pyx":37 + * self.endspan_alpha = kwargs[ + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + * self.minspan_alpha = kwargs[ # <<<<<<<<<<<<<< + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + * self.max_terms = kwargs[ + */ + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__minspan_alpha)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + + /* "sklearn/earth/_forward.pyx":38 + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + * self.minspan_alpha = kwargs[ + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 # <<<<<<<<<<<<<< + * self.max_terms = kwargs[ + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 + */ + __pyx_t_1 = PyFloat_FromDouble(.05); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":37 + * self.endspan_alpha = kwargs[ + * 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + * self.minspan_alpha = kwargs[ # <<<<<<<<<<<<<< + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + * self.max_terms = kwargs[ + */ + __pyx_v_self->minspan_alpha = __pyx_t_6; + + /* "sklearn/earth/_forward.pyx":40 + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + * self.max_terms = kwargs[ + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 # <<<<<<<<<<<<<< + * self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True + * self.max_degree = kwargs['max_degree'] if 'max_degree' in kwargs else 1 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__max_terms), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + + /* "sklearn/earth/_forward.pyx":39 + * self.minspan_alpha = kwargs[ + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + * self.max_terms = kwargs[ # <<<<<<<<<<<<<< + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 + * self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True + */ + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_terms)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + + /* "sklearn/earth/_forward.pyx":40 + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + * self.max_terms = kwargs[ + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 # <<<<<<<<<<<<<< + * self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True + * self.max_degree = kwargs['max_degree'] if 'max_degree' in kwargs else 1 + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((2 * __pyx_v_self->n) + 10)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":39 + * self.minspan_alpha = kwargs[ + * 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + * self.max_terms = kwargs[ # <<<<<<<<<<<<<< + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 + * self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True + */ + __pyx_v_self->max_terms = __pyx_t_5; + + /* "sklearn/earth/_forward.pyx":41 + * self.max_terms = kwargs[ + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 + * self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True # <<<<<<<<<<<<<< + * self.max_degree = kwargs['max_degree'] if 'max_degree' in kwargs else 1 + * self.thresh = kwargs['thresh'] if 'thresh' in kwargs else 0.001 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__allow_linear), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__allow_linear)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->allow_linear = __pyx_t_4; + + /* "sklearn/earth/_forward.pyx":42 + * 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 + * self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True + * self.max_degree = kwargs['max_degree'] if 'max_degree' in kwargs else 1 # <<<<<<<<<<<<<< + * self.thresh = kwargs['thresh'] if 'thresh' in kwargs else 0.001 + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__max_degree), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_degree)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(__pyx_int_1); + __pyx_t_3 = __pyx_int_1; + } + __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->max_degree = __pyx_t_5; + + /* "sklearn/earth/_forward.pyx":43 + * self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True + * self.max_degree = kwargs['max_degree'] if 'max_degree' in kwargs else 1 + * self.thresh = kwargs['thresh'] if 'thresh' in kwargs else 0.001 # <<<<<<<<<<<<<< + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + * self.check_every = kwargs[ + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__thresh), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__thresh)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_1 = PyFloat_FromDouble(0.001); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->thresh = __pyx_t_6; + + /* "sklearn/earth/_forward.pyx":44 + * self.max_degree = kwargs['max_degree'] if 'max_degree' in kwargs else 1 + * self.thresh = kwargs['thresh'] if 'thresh' in kwargs else 0.001 + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 # <<<<<<<<<<<<<< + * self.check_every = kwargs[ + * 'check_every'] if 'check_every' in kwargs else -1 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__penalty), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__penalty)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_1 = PyFloat_FromDouble(3.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->penalty = __pyx_t_6; + + /* "sklearn/earth/_forward.pyx":46 + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + * self.check_every = kwargs[ + * 'check_every'] if 'check_every' in kwargs else -1 # <<<<<<<<<<<<<< + * self.min_search_points = kwargs[ + * 'min_search_points'] if 'min_search_points' in kwargs else 100 + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__check_every), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + + /* "sklearn/earth/_forward.pyx":45 + * self.thresh = kwargs['thresh'] if 'thresh' in kwargs else 0.001 + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + * self.check_every = kwargs[ # <<<<<<<<<<<<<< + * 'check_every'] if 'check_every' in kwargs else -1 + * self.min_search_points = kwargs[ + */ + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__check_every)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(__pyx_int_neg_1); + __pyx_t_3 = __pyx_int_neg_1; + } + __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->check_every = __pyx_t_5; + + /* "sklearn/earth/_forward.pyx":48 + * 'check_every'] if 'check_every' in kwargs else -1 + * self.min_search_points = kwargs[ + * 'min_search_points'] if 'min_search_points' in kwargs else 100 # <<<<<<<<<<<<<< + * self.xlabels = kwargs['xlabels'] if 'xlabels' in kwargs else None + * if self.xlabels is None: + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__min_search_points), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + + /* "sklearn/earth/_forward.pyx":47 + * self.check_every = kwargs[ + * 'check_every'] if 'check_every' in kwargs else -1 + * self.min_search_points = kwargs[ # <<<<<<<<<<<<<< + * 'min_search_points'] if 'min_search_points' in kwargs else 100 + * self.xlabels = kwargs['xlabels'] if 'xlabels' in kwargs else None + */ + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__min_search_points)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(__pyx_int_100); + __pyx_t_3 = __pyx_int_100; + } + __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->min_search_points = __pyx_t_5; + + /* "sklearn/earth/_forward.pyx":49 + * self.min_search_points = kwargs[ + * 'min_search_points'] if 'min_search_points' in kwargs else 100 + * self.xlabels = kwargs['xlabels'] if 'xlabels' in kwargs else None # <<<<<<<<<<<<<< + * if self.xlabels is None: + * self.xlabels = ['x' + str(i) for i in range(self.n)] + */ + __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__xlabels), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__xlabels)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(Py_None); + __pyx_t_3 = Py_None; + } + if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->xlabels); + __Pyx_DECREF(((PyObject *)__pyx_v_self->xlabels)); + __pyx_v_self->xlabels = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":50 + * 'min_search_points'] if 'min_search_points' in kwargs else 100 + * self.xlabels = kwargs['xlabels'] if 'xlabels' in kwargs else None + * if self.xlabels is None: # <<<<<<<<<<<<<< + * self.xlabels = ['x' + str(i) for i in range(self.n)] + * if self.check_every < 0: + */ + __pyx_t_4 = (__pyx_v_self->xlabels == ((PyObject*)Py_None)); + __pyx_t_7 = (__pyx_t_4 != 0); + if (__pyx_t_7) { + + /* "sklearn/earth/_forward.pyx":51 + * self.xlabels = kwargs['xlabels'] if 'xlabels' in kwargs else None + * if self.xlabels is None: + * self.xlabels = ['x' + str(i) for i in range(self.n)] # <<<<<<<<<<<<<< + * if self.check_every < 0: + * self.check_every = (self.m / self.min_search_points) if self.m > self.min_search_points else 1 + */ + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = __pyx_v_self->n; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_v_i = __pyx_t_9; + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_n_s__x), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __Pyx_GOTREF(__pyx_v_self->xlabels); + __Pyx_DECREF(((PyObject *)__pyx_v_self->xlabels)); + __pyx_v_self->xlabels = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_forward.pyx":52 + * if self.xlabels is None: + * self.xlabels = ['x' + str(i) for i in range(self.n)] + * if self.check_every < 0: # <<<<<<<<<<<<<< + * self.check_every = (self.m / self.min_search_points) if self.m > self.min_search_points else 1 + * self.sst = (np.dot(self.y, self.y) - + */ + __pyx_t_7 = ((__pyx_v_self->check_every < 0) != 0); + if (__pyx_t_7) { + + /* "sklearn/earth/_forward.pyx":53 + * self.xlabels = ['x' + str(i) for i in range(self.n)] + * if self.check_every < 0: + * self.check_every = (self.m / self.min_search_points) if self.m > self.min_search_points else 1 # <<<<<<<<<<<<<< + * self.sst = (np.dot(self.y, self.y) - + * (np.dot(np.sqrt(self.sample_weight), self.y) / np.sqrt(np.sum(self.sample_weight))) ** 2) / self.m + */ + if (((__pyx_v_self->m > __pyx_v_self->min_search_points) != 0)) { + __pyx_t_10 = ((int)(__pyx_v_self->m / __pyx_v_self->min_search_points)); + } else { + __pyx_t_10 = 1; + } + __pyx_v_self->check_every = __pyx_t_10; + goto __pyx_L6; + } + __pyx_L6:; + + /* "sklearn/earth/_forward.pyx":54 + * if self.check_every < 0: + * self.check_every = (self.m / self.min_search_points) if self.m > self.min_search_points else 1 + * self.sst = (np.dot(self.y, self.y) - # <<<<<<<<<<<<<< + * (np.dot(np.sqrt(self.sample_weight), self.y) / np.sqrt(np.sum(self.sample_weight))) ** 2) / self.m + * self.y_squared = np.dot(self.y, self.y) + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__dot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self->y)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->y)); + __Pyx_INCREF(((PyObject *)__pyx_v_self->y)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->y)); + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":55 + * self.check_every = (self.m / self.min_search_points) if self.m > self.min_search_points else 1 + * self.sst = (np.dot(self.y, self.y) - + * (np.dot(np.sqrt(self.sample_weight), self.y) / np.sqrt(np.sum(self.sample_weight))) ** 2) / self.m # <<<<<<<<<<<<<< + * self.y_squared = np.dot(self.y, self.y) + * self.record = ForwardPassRecord( + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__dot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__sqrt); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self->sample_weight)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->sample_weight)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->sample_weight)); + __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __Pyx_INCREF(((PyObject *)__pyx_v_self->y)); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->y)); + __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__sqrt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__sum); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self->sample_weight)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->sample_weight)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->sample_weight)); + __pyx_t_13 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = PyNumber_Power(__pyx_t_3, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":54 + * if self.check_every < 0: + * self.check_every = (self.m / self.min_search_points) if self.m > self.min_search_points else 1 + * self.sst = (np.dot(self.y, self.y) - # <<<<<<<<<<<<<< + * (np.dot(np.sqrt(self.sample_weight), self.y) / np.sqrt(np.sum(self.sample_weight))) ** 2) / self.m + * self.y_squared = np.dot(self.y, self.y) + */ + __pyx_v_self->sst = __pyx_t_6; + + /* "sklearn/earth/_forward.pyx":56 + * self.sst = (np.dot(self.y, self.y) - + * (np.dot(np.sqrt(self.sample_weight), self.y) / np.sqrt(np.sum(self.sample_weight))) ** 2) / self.m + * self.y_squared = np.dot(self.y, self.y) # <<<<<<<<<<<<<< + * self.record = ForwardPassRecord( + * self.m, self.n, self.penalty, self.sst, self.xlabels) + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__dot); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self->y)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->y)); + __Pyx_INCREF(((PyObject *)__pyx_v_self->y)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self->y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->y)); + __pyx_t_3 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->y_squared = __pyx_t_6; + + /* "sklearn/earth/_forward.pyx":58 + * self.y_squared = np.dot(self.y, self.y) + * self.record = ForwardPassRecord( + * self.m, self.n, self.penalty, self.sst, self.xlabels) # <<<<<<<<<<<<<< + * self.basis = Basis(self.n) + * self.basis.append(ConstantBasisFunction()) + */ + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_13 = PyFloat_FromDouble(__pyx_v_self->penalty); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_12 = PyFloat_FromDouble(__pyx_v_self->sst); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __Pyx_INCREF(((PyObject *)__pyx_v_self->xlabels)); + PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_v_self->xlabels)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->xlabels)); + __pyx_t_3 = 0; + __pyx_t_1 = 0; + __pyx_t_13 = 0; + __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":57 + * (np.dot(np.sqrt(self.sample_weight), self.y) / np.sqrt(np.sum(self.sample_weight))) ** 2) / self.m + * self.y_squared = np.dot(self.y, self.y) + * self.record = ForwardPassRecord( # <<<<<<<<<<<<<< + * self.m, self.n, self.penalty, self.sst, self.xlabels) + * self.basis = Basis(self.n) + */ + __Pyx_GIVEREF(__pyx_t_12); + __Pyx_GOTREF(__pyx_v_self->record); + __Pyx_DECREF(((PyObject *)__pyx_v_self->record)); + __pyx_v_self->record = ((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_t_12); + __pyx_t_12 = 0; + + /* "sklearn/earth/_forward.pyx":59 + * self.record = ForwardPassRecord( + * self.m, self.n, self.penalty, self.sst, self.xlabels) + * self.basis = Basis(self.n) # <<<<<<<<<<<<<< + * self.basis.append(ConstantBasisFunction()) + * + */ + __pyx_t_12 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->n); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_Basis)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_12); + __Pyx_GOTREF(__pyx_v_self->basis); + __Pyx_DECREF(((PyObject *)__pyx_v_self->basis)); + __pyx_v_self->basis = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_t_12); + __pyx_t_12 = 0; + + /* "sklearn/earth/_forward.pyx":60 + * self.m, self.n, self.penalty, self.sst, self.xlabels) + * self.basis = Basis(self.n) + * self.basis.append(ConstantBasisFunction()) # <<<<<<<<<<<<<< + * + * self.sorting = np.empty(shape=self.m, dtype=np.int) + */ + __pyx_t_12 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->append(__pyx_v_self->basis, ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_12), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":62 + * self.basis.append(ConstantBasisFunction()) + * + * self.sorting = np.empty(shape=self.m, dtype=np.int) # <<<<<<<<<<<<<< + * self.mwork = np.empty(shape=self.m, dtype=np.int) + * self.u = np.empty(shape=self.max_terms, dtype=float) + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_13 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__shape), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s__int); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->sorting); + __Pyx_DECREF(((PyObject *)__pyx_v_self->sorting)); + __pyx_v_self->sorting = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":63 + * + * self.sorting = np.empty(shape=self.m, dtype=np.int) + * self.mwork = np.empty(shape=self.m, dtype=np.int) # <<<<<<<<<<<<<< + * self.u = np.empty(shape=self.max_terms, dtype=float) + * self.B_orth_times_parent_cum = np.empty( + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_12 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__shape), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__int); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_13); + __Pyx_GOTREF(__pyx_v_self->mwork); + __Pyx_DECREF(((PyObject *)__pyx_v_self->mwork)); + __pyx_v_self->mwork = ((PyArrayObject *)__pyx_t_13); + __pyx_t_13 = 0; + + /* "sklearn/earth/_forward.pyx":64 + * self.sorting = np.empty(shape=self.m, dtype=np.int) + * self.mwork = np.empty(shape=self.m, dtype=np.int) + * self.u = np.empty(shape=self.max_terms, dtype=float) # <<<<<<<<<<<<<< + * self.B_orth_times_parent_cum = np.empty( + * shape=self.max_terms, dtype=np.float) + */ + __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s__empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_13)); + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->max_terms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_13, ((PyObject *)__pyx_n_s__shape), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyDict_SetItem(__pyx_t_13, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_13)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->u); + __Pyx_DECREF(((PyObject *)__pyx_v_self->u)); + __pyx_v_self->u = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":65 + * self.mwork = np.empty(shape=self.m, dtype=np.int) + * self.u = np.empty(shape=self.max_terms, dtype=float) + * self.B_orth_times_parent_cum = np.empty( # <<<<<<<<<<<<<< + * shape=self.max_terms, dtype=np.float) + * self.B = np.ones( + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + + /* "sklearn/earth/_forward.pyx":66 + * self.u = np.empty(shape=self.max_terms, dtype=float) + * self.B_orth_times_parent_cum = np.empty( + * shape=self.max_terms, dtype=np.float) # <<<<<<<<<<<<<< + * self.B = np.ones( + * shape=(self.m, self.max_terms), order='C', dtype=np.float) + */ + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->max_terms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__shape), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__float); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_forward.pyx":65 + * self.mwork = np.empty(shape=self.m, dtype=np.int) + * self.u = np.empty(shape=self.max_terms, dtype=float) + * self.B_orth_times_parent_cum = np.empty( # <<<<<<<<<<<<<< + * shape=self.max_terms, dtype=np.float) + * self.B = np.ones( + */ + __Pyx_GIVEREF(__pyx_t_12); + __Pyx_GOTREF(__pyx_v_self->B_orth_times_parent_cum); + __Pyx_DECREF(((PyObject *)__pyx_v_self->B_orth_times_parent_cum)); + __pyx_v_self->B_orth_times_parent_cum = ((PyArrayObject *)__pyx_t_12); + __pyx_t_12 = 0; + + /* "sklearn/earth/_forward.pyx":67 + * self.B_orth_times_parent_cum = np.empty( + * shape=self.max_terms, dtype=np.float) + * self.B = np.ones( # <<<<<<<<<<<<<< + * shape=(self.m, self.max_terms), order='C', dtype=np.float) + * self.basis.weighted_transform(self.X, self.B[:,0:1], self.sample_weight) + */ + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__ones); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_12)); + + /* "sklearn/earth/_forward.pyx":68 + * shape=self.max_terms, dtype=np.float) + * self.B = np.ones( + * shape=(self.m, self.max_terms), order='C', dtype=np.float) # <<<<<<<<<<<<<< + * self.basis.weighted_transform(self.X, self.B[:,0:1], self.sample_weight) + * # An orthogonal matrix with the same column space as B + */ + __pyx_t_13 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->max_terms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_13 = 0; + __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_t_12, ((PyObject *)__pyx_n_s__shape), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + if (PyDict_SetItem(__pyx_t_12, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PyDict_SetItem(__pyx_t_12, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_forward.pyx":67 + * self.B_orth_times_parent_cum = np.empty( + * shape=self.max_terms, dtype=np.float) + * self.B = np.ones( # <<<<<<<<<<<<<< + * shape=(self.m, self.max_terms), order='C', dtype=np.float) + * self.basis.weighted_transform(self.X, self.B[:,0:1], self.sample_weight) + */ + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->B); + __Pyx_DECREF(((PyObject *)__pyx_v_self->B)); + __pyx_v_self->B = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":69 + * self.B = np.ones( + * shape=(self.m, self.max_terms), order='C', dtype=np.float) + * self.basis.weighted_transform(self.X, self.B[:,0:1], self.sample_weight) # <<<<<<<<<<<<<< + * # An orthogonal matrix with the same column space as B + * self.B_orth = self.B.copy() + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->X); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_self->B), ((PyObject *)__pyx_k_tuple_3)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((PyObject *)__pyx_v_self->sample_weight); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->weighted_transform(__pyx_v_self->basis, ((PyArrayObject *)__pyx_t_1), ((PyArrayObject *)__pyx_t_12), ((PyArrayObject *)__pyx_t_2), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":71 + * self.basis.weighted_transform(self.X, self.B[:,0:1], self.sample_weight) + * # An orthogonal matrix with the same column space as B + * self.B_orth = self.B.copy() # <<<<<<<<<<<<<< + * self.u = np.empty(shape=self.max_terms, dtype=np.float) + * self.c = np.empty(shape=self.max_terms, dtype=np.float) + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->B), __pyx_n_s__copy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_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_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->B_orth); + __Pyx_DECREF(((PyObject *)__pyx_v_self->B_orth)); + __pyx_v_self->B_orth = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":72 + * # An orthogonal matrix with the same column space as B + * self.B_orth = self.B.copy() + * self.u = np.empty(shape=self.max_terms, dtype=np.float) # <<<<<<<<<<<<<< + * self.c = np.empty(shape=self.max_terms, dtype=np.float) + * self.norms = np.empty(shape=self.max_terms, dtype=np.float) + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_12 = PyInt_FromLong(__pyx_v_self->max_terms); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__shape), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->u); + __Pyx_DECREF(((PyObject *)__pyx_v_self->u)); + __pyx_v_self->u = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":73 + * self.B_orth = self.B.copy() + * self.u = np.empty(shape=self.max_terms, dtype=np.float) + * self.c = np.empty(shape=self.max_terms, dtype=np.float) # <<<<<<<<<<<<<< + * self.norms = np.empty(shape=self.max_terms, dtype=np.float) + * self.c_squared = 0.0 + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_3 = PyInt_FromLong(__pyx_v_self->max_terms); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__shape), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__float); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_12); + __Pyx_GOTREF(__pyx_v_self->c); + __Pyx_DECREF(((PyObject *)__pyx_v_self->c)); + __pyx_v_self->c = ((PyArrayObject *)__pyx_t_12); + __pyx_t_12 = 0; + + /* "sklearn/earth/_forward.pyx":74 + * self.u = np.empty(shape=self.max_terms, dtype=np.float) + * self.c = np.empty(shape=self.max_terms, dtype=np.float) + * self.norms = np.empty(shape=self.max_terms, dtype=np.float) # <<<<<<<<<<<<<< + * self.c_squared = 0.0 + * self.sort_tracker = np.empty(shape=self.m, dtype=np.int) + */ + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_12)); + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->max_terms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_12, ((PyObject *)__pyx_n_s__shape), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__float); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyDict_SetItem(__pyx_t_12, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->norms); + __Pyx_DECREF(((PyObject *)__pyx_v_self->norms)); + __pyx_v_self->norms = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":75 + * self.c = np.empty(shape=self.max_terms, dtype=np.float) + * self.norms = np.empty(shape=self.max_terms, dtype=np.float) + * self.c_squared = 0.0 # <<<<<<<<<<<<<< + * self.sort_tracker = np.empty(shape=self.m, dtype=np.int) + * for i in range(self.m): + */ + __pyx_v_self->c_squared = 0.0; + + /* "sklearn/earth/_forward.pyx":76 + * self.norms = np.empty(shape=self.max_terms, dtype=np.float) + * self.c_squared = 0.0 + * self.sort_tracker = np.empty(shape=self.m, dtype=np.int) # <<<<<<<<<<<<<< + * for i in range(self.m): + * self.sort_tracker[i] = i + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__empty); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__shape), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__int); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(((PyObject *)__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_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->sort_tracker); + __Pyx_DECREF(((PyObject *)__pyx_v_self->sort_tracker)); + __pyx_v_self->sort_tracker = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":77 + * self.c_squared = 0.0 + * self.sort_tracker = np.empty(shape=self.m, dtype=np.int) + * for i in range(self.m): # <<<<<<<<<<<<<< + * self.sort_tracker[i] = i + * self.zero_tol = 1e-6 + */ + __pyx_t_8 = __pyx_v_self->m; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + __pyx_v_i = __pyx_t_9; + + /* "sklearn/earth/_forward.pyx":78 + * self.sort_tracker = np.empty(shape=self.m, dtype=np.int) + * for i in range(self.m): + * self.sort_tracker[i] = i # <<<<<<<<<<<<<< + * self.zero_tol = 1e-6 + * + */ + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_SetItemInt(((PyObject *)__pyx_v_self->sort_tracker), __pyx_v_i, __pyx_t_2, sizeof(__pyx_t_7sklearn_5earth_8_forward_INDEX_t)+1, __Pyx_PyInt_to_py_npy_ulonglong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + + /* "sklearn/earth/_forward.pyx":79 + * for i in range(self.m): + * self.sort_tracker[i] = i + * self.zero_tol = 1e-6 # <<<<<<<<<<<<<< + * + * self.linear_variables = np.zeros(shape=self.n, dtype=np.int) + */ + __pyx_v_self->zero_tol = 1e-6; + + /* "sklearn/earth/_forward.pyx":81 + * self.zero_tol = 1e-6 + * + * self.linear_variables = np.zeros(shape=self.n, dtype=np.int) # <<<<<<<<<<<<<< + * self.init_linear_variables() + * + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_12 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->n); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__shape), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__int); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->linear_variables); + __Pyx_DECREF(((PyObject *)__pyx_v_self->linear_variables)); + __pyx_v_self->linear_variables = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":82 + * + * self.linear_variables = np.zeros(shape=self.n, dtype=np.int) + * self.init_linear_variables() # <<<<<<<<<<<<<< + * + * # Add in user selected linear variables + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->init_linear_variables(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":85 + * + * # Add in user selected linear variables + * if 'linvars' in kwargs: # <<<<<<<<<<<<<< + * for linvar in kwargs['linvars']: + * if linvar in self.xlabels: + */ + __pyx_t_7 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__linvars), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = (__pyx_t_7 != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_forward.pyx":86 + * # Add in user selected linear variables + * if 'linvars' in kwargs: + * for linvar in kwargs['linvars']: # <<<<<<<<<<<<<< + * if linvar in self.xlabels: + * self.linear_variables[self.xlabels.index(linvar)] = 1 + */ + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__linvars)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_14 = 0; + __pyx_t_15 = NULL; + } else { + __pyx_t_14 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_1 = __pyx_t_15(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_XDECREF_SET(__pyx_v_linvar, __pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":87 + * if 'linvars' in kwargs: + * for linvar in kwargs['linvars']: + * if linvar in self.xlabels: # <<<<<<<<<<<<<< + * self.linear_variables[self.xlabels.index(linvar)] = 1 + * elif linvar in range(self.n): + */ + __pyx_t_4 = (__Pyx_PySequence_Contains(__pyx_v_linvar, ((PyObject *)__pyx_v_self->xlabels), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = (__pyx_t_4 != 0); + if (__pyx_t_7) { + + /* "sklearn/earth/_forward.pyx":88 + * for linvar in kwargs['linvars']: + * if linvar in self.xlabels: + * self.linear_variables[self.xlabels.index(linvar)] = 1 # <<<<<<<<<<<<<< + * elif linvar in range(self.n): + * self.linear_variables[linvar] = 1 + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->xlabels), __pyx_n_s__index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_linvar); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_linvar); + __Pyx_GIVEREF(__pyx_v_linvar); + __pyx_t_12 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + if (PyObject_SetItem(((PyObject *)__pyx_v_self->linear_variables), __pyx_t_12, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + goto __pyx_L12; + } + + /* "sklearn/earth/_forward.pyx":89 + * if linvar in self.xlabels: + * self.linear_variables[self.xlabels.index(linvar)] = 1 + * elif linvar in range(self.n): # <<<<<<<<<<<<<< + * self.linear_variables[linvar] = 1 + * else: + */ + __pyx_t_12 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->n); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_7 = (__Pyx_PySequence_Contains(__pyx_v_linvar, __pyx_t_12, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_4 = (__pyx_t_7 != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_forward.pyx":90 + * self.linear_variables[self.xlabels.index(linvar)] = 1 + * elif linvar in range(self.n): + * self.linear_variables[linvar] = 1 # <<<<<<<<<<<<<< + * else: + * raise IndexError( + */ + if (PyObject_SetItem(((PyObject *)__pyx_v_self->linear_variables), __pyx_v_linvar, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":92 + * self.linear_variables[linvar] = 1 + * else: + * raise IndexError( # <<<<<<<<<<<<<< + * 'Unknown variable selected in linvars argument.') + * + */ + __pyx_t_12 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_Raise(__pyx_t_12, 0, 0, 0); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L12:; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L9; + } + __pyx_L9:; + + /* "sklearn/earth/_forward.pyx":97 + * # Initialize B_orth, c, and c_squared (assuming column 0 of B_orth is + * # already filled with 1) + * self.orthonormal_update(0) # <<<<<<<<<<<<<< + * + * cpdef Basis get_basis(ForwardPasser self): + */ + ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_update(__pyx_v_self, 0, 0); + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sample_weight.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sample_weight.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF(__pyx_v_linvar); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":99 + * self.orthonormal_update(0) + * + * cpdef Basis get_basis(ForwardPasser self): # <<<<<<<<<<<<<< + * return self.basis + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_3get_basis(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_get_basis(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_basis", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_basis); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_3get_basis)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7sklearn_5earth_6_basis_Basis))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_forward.pyx":100 + * + * cpdef Basis get_basis(ForwardPasser self): + * return self.basis # <<<<<<<<<<<<<< + * + * cpdef init_linear_variables(ForwardPasser self): + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_self->basis)); + __pyx_r = __pyx_v_self->basis; + goto __pyx_L0; + + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.get_basis", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_3get_basis(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_3get_basis(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_basis (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_2get_basis(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":99 + * self.orthonormal_update(0) + * + * cpdef Basis get_basis(ForwardPasser self): # <<<<<<<<<<<<<< + * return self.basis + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_2get_basis(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_basis", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->get_basis(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.get_basis", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":102 + * return self.basis + * + * cpdef init_linear_variables(ForwardPasser self): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef INDEX_t endspan + */ + +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_5init_linear_variables(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_init_linear_variables(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_variable; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_endspan; + PyArrayObject *__pyx_v_order = 0; + PyArrayObject *__pyx_v_linear_variables = 0; + PyArrayObject *__pyx_v_B = 0; + PyArrayObject *__pyx_v_X = 0; + struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_v_root_basis_function = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_linear_variables; + __Pyx_Buffer __pyx_pybuffer_linear_variables; + __Pyx_LocalBuf_ND __pyx_pybuffernd_order; + __Pyx_Buffer __pyx_pybuffer_order; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyArrayObject *__pyx_t_3 = NULL; + PyArrayObject *__pyx_t_4 = NULL; + PyArrayObject *__pyx_t_5 = NULL; + int __pyx_t_6; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_7; + int __pyx_t_8; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + PyArrayObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_16; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_17; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("init_linear_variables", 0); + __pyx_pybuffer_order.pybuffer.buf = NULL; + __pyx_pybuffer_order.refcount = 0; + __pyx_pybuffernd_order.data = NULL; + __pyx_pybuffernd_order.rcbuffer = &__pyx_pybuffer_order; + __pyx_pybuffer_linear_variables.pybuffer.buf = NULL; + __pyx_pybuffer_linear_variables.refcount = 0; + __pyx_pybuffernd_linear_variables.data = NULL; + __pyx_pybuffernd_linear_variables.rcbuffer = &__pyx_pybuffer_linear_variables; + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_5init_linear_variables)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_forward.pyx":106 + * cdef INDEX_t endspan + * cdef cnp.ndarray[INT_t, ndim = 1] order + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + */ + __pyx_t_3 = ((PyArrayObject *)__pyx_v_self->linear_variables); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_linear_variables.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_linear_variables = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_linear_variables.diminfo[0].strides = __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_linear_variables.diminfo[0].shape = __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_3 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->linear_variables))); + __pyx_v_linear_variables = ((PyArrayObject *)__pyx_v_self->linear_variables); + + /* "sklearn/earth/_forward.pyx":107 + * cdef cnp.ndarray[INT_t, ndim = 1] order + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * if self.endspan < 0: + */ + __pyx_t_4 = ((PyArrayObject *)__pyx_v_self->B); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_B = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_4 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B))); + __pyx_v_B = ((PyArrayObject *)__pyx_v_self->B); + + /* "sklearn/earth/_forward.pyx":108 + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X # <<<<<<<<<<<<<< + * if self.endspan < 0: + * endspan = round(3 - log2(self.endspan_alpha / self.n)) + */ + __pyx_t_5 = ((PyArrayObject *)__pyx_v_self->X); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_X.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->X))); + __pyx_v_X = ((PyArrayObject *)__pyx_v_self->X); + + /* "sklearn/earth/_forward.pyx":109 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * if self.endspan < 0: # <<<<<<<<<<<<<< + * endspan = round(3 - log2(self.endspan_alpha / self.n)) + * else: + */ + __pyx_t_6 = ((__pyx_v_self->endspan < 0) != 0); + if (__pyx_t_6) { + + /* "sklearn/earth/_forward.pyx":110 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * if self.endspan < 0: + * endspan = round(3 - log2(self.endspan_alpha / self.n)) # <<<<<<<<<<<<<< + * else: + * endspan = self.endspan + */ + __pyx_t_1 = PyFloat_FromDouble((3.0 - __pyx_f_7sklearn_5earth_5_util_log2((__pyx_v_self->endspan_alpha / __pyx_v_self->n)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_builtin_round, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_7 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_7 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_endspan = __pyx_t_7; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":112 + * endspan = round(3 - log2(self.endspan_alpha / self.n)) + * else: + * endspan = self.endspan # <<<<<<<<<<<<<< + * cdef ConstantBasisFunction root_basis_function = self.basis[0] + * for variable in range(self.n): + */ + __pyx_t_8 = __pyx_v_self->endspan; + __pyx_v_endspan = __pyx_t_8; + } + __pyx_L3:; + + /* "sklearn/earth/_forward.pyx":113 + * else: + * endspan = self.endspan + * cdef ConstantBasisFunction root_basis_function = self.basis[0] # <<<<<<<<<<<<<< + * for variable in range(self.n): + * order = np.argsort(X[:, variable])[::-1] + */ + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->basis), 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_root_basis_function = ((struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":114 + * endspan = self.endspan + * cdef ConstantBasisFunction root_basis_function = self.basis[0] + * for variable in range(self.n): # <<<<<<<<<<<<<< + * order = np.argsort(X[:, variable])[::-1] + * if root_basis_function.valid_knots(B[order, 0], X[order, variable], + */ + __pyx_t_7 = __pyx_v_self->n; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_7; __pyx_t_9+=1) { + __pyx_v_variable = __pyx_t_9; + + /* "sklearn/earth/_forward.pyx":115 + * cdef ConstantBasisFunction root_basis_function = self.basis[0] + * for variable in range(self.n): + * order = np.argsort(X[:, variable])[::-1] # <<<<<<<<<<<<<< + * if root_basis_function.valid_knots(B[order, 0], X[order, variable], + * variable, self.check_every, endspan, + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__argsort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_k_slice_7); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_k_slice_7); + __Pyx_GIVEREF(__pyx_k_slice_7); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_X), ((PyObject *)__pyx_t_10)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = PyObject_GetItem(__pyx_t_1, __pyx_k_slice_8); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer); + __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_8 < 0)) { + PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_v_order, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14); + } + } + __pyx_pybuffernd_order.diminfo[0].strides = __pyx_pybuffernd_order.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_order.diminfo[0].shape = __pyx_pybuffernd_order.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_11 = 0; + __Pyx_XDECREF_SET(__pyx_v_order, ((PyArrayObject *)__pyx_t_10)); + __pyx_t_10 = 0; + + /* "sklearn/earth/_forward.pyx":116 + * for variable in range(self.n): + * order = np.argsort(X[:, variable])[::-1] + * if root_basis_function.valid_knots(B[order, 0], X[order, variable], # <<<<<<<<<<<<<< + * variable, self.check_every, endspan, + * self.minspan, self.minspan_alpha, + */ + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(((PyObject *)__pyx_v_order)); + PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_order)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_order)); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_10)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_order)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_order)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_order)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_X), ((PyObject *)__pyx_t_2)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_forward.pyx":119 + * variable, self.check_every, endspan, + * self.minspan, self.minspan_alpha, + * self.n, self.mwork).shape[0] == 0: # <<<<<<<<<<<<<< + * linear_variables[variable] = 1 + * else: + */ + __pyx_t_2 = ((PyObject *)__pyx_v_self->mwork); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_15 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *)__pyx_v_root_basis_function->__pyx_base.__pyx_vtab)->__pyx_base.valid_knots(((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_root_basis_function), ((PyArrayObject *)__pyx_t_1), ((PyArrayObject *)__pyx_t_10), __pyx_v_variable, __pyx_v_self->check_every, __pyx_v_endspan, __pyx_v_self->minspan, __pyx_v_self->minspan_alpha, __pyx_v_self->n, ((PyArrayObject *)__pyx_t_2), 0)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_6 = (((((PyArrayObject *)__pyx_t_15)->dimensions[0]) == 0) != 0); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (__pyx_t_6) { + + /* "sklearn/earth/_forward.pyx":120 + * self.minspan, self.minspan_alpha, + * self.n, self.mwork).shape[0] == 0: + * linear_variables[variable] = 1 # <<<<<<<<<<<<<< + * else: + * linear_variables[variable] = 0 + */ + __pyx_t_16 = __pyx_v_variable; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_linear_variables.diminfo[0].strides) = 1; + goto __pyx_L6; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":122 + * linear_variables[variable] = 1 + * else: + * linear_variables[variable] = 0 # <<<<<<<<<<<<<< + * + * def get_B_orth(ForwardPasser self): + */ + __pyx_t_17 = __pyx_v_variable; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_linear_variables.diminfo[0].strides) = 0; + } + __pyx_L6:; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_15); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_linear_variables.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.init_linear_variables", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_linear_variables.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_order); + __Pyx_XDECREF((PyObject *)__pyx_v_linear_variables); + __Pyx_XDECREF((PyObject *)__pyx_v_B); + __Pyx_XDECREF((PyObject *)__pyx_v_X); + __Pyx_XDECREF((PyObject *)__pyx_v_root_basis_function); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_5init_linear_variables(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_5init_linear_variables(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("init_linear_variables (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_4init_linear_variables(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":102 + * return self.basis + * + * cpdef init_linear_variables(ForwardPasser self): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef INDEX_t endspan + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_4init_linear_variables(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("init_linear_variables", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->init_linear_variables(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.init_linear_variables", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_7get_B_orth(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_7get_B_orth(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_B_orth (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_6get_B_orth(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":124 + * linear_variables[variable] = 0 + * + * def get_B_orth(ForwardPasser self): # <<<<<<<<<<<<<< + * return self.B_orth + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_6get_B_orth(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_B_orth", 0); + + /* "sklearn/earth/_forward.pyx":125 + * + * def get_B_orth(ForwardPasser self): + * return self.B_orth # <<<<<<<<<<<<<< + * + * cpdef run(ForwardPasser self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->B_orth)); + __pyx_r = ((PyObject *)__pyx_v_self->B_orth); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":127 + * return self.B_orth + * + * cpdef run(ForwardPasser self): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * while True: + */ + +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_9run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_run(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("run", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__run); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_9run)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_forward.pyx":129 + * cpdef run(ForwardPasser self): + * cdef INDEX_t i + * while True: # <<<<<<<<<<<<<< + * self.next_pair() + * if self.stop_check(): + */ + while (1) { + if (!1) break; + + /* "sklearn/earth/_forward.pyx":130 + * cdef INDEX_t i + * while True: + * self.next_pair() # <<<<<<<<<<<<<< + * if self.stop_check(): + * break + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->next_pair(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":131 + * while True: + * self.next_pair() + * if self.stop_check(): # <<<<<<<<<<<<<< + * break + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->stop_check(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_3) { + + /* "sklearn/earth/_forward.pyx":132 + * self.next_pair() + * if self.stop_check(): + * break # <<<<<<<<<<<<<< + * + * cdef stop_check(ForwardPasser self): + */ + goto __pyx_L4_break; + goto __pyx_L5; + } + __pyx_L5:; + } + __pyx_L4_break:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.run", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_9run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_9run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("run (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_8run(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":127 + * return self.B_orth + * + * cpdef run(ForwardPasser self): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * while True: + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_8run(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("run", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->run(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.run", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":134 + * break + * + * cdef stop_check(ForwardPasser self): # <<<<<<<<<<<<<< + * last = self.record.__len__() - 1 + * if self.record.iterations[last].get_size() + 2 > self.max_terms: + */ + +static PyObject *__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_stop_check(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self) { + PyObject *__pyx_v_last = NULL; + PyObject *__pyx_v_rsq = NULL; + PyObject *__pyx_v_previous_rsq = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("stop_check", 0); + + /* "sklearn/earth/_forward.pyx":135 + * + * cdef stop_check(ForwardPasser self): + * last = self.record.__len__() - 1 # <<<<<<<<<<<<<< + * if self.record.iterations[last].get_size() + 2 > self.max_terms: + * self.record.stopping_condition = MAXTERMS + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->record), __pyx_n_s____len__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_last = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":136 + * cdef stop_check(ForwardPasser self): + * last = self.record.__len__() - 1 + * if self.record.iterations[last].get_size() + 2 > self.max_terms: # <<<<<<<<<<<<<< + * self.record.stopping_condition = MAXTERMS + * return True + */ + if (unlikely(((PyObject *)__pyx_v_self->record->__pyx_base.iterations) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->record->__pyx_base.iterations), __pyx_v_last); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__get_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->max_terms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_4) { + + /* "sklearn/earth/_forward.pyx":137 + * last = self.record.__len__() - 1 + * if self.record.iterations[last].get_size() + 2 > self.max_terms: + * self.record.stopping_condition = MAXTERMS # <<<<<<<<<<<<<< + * return True + * rsq = self.record.rsq(last) + */ + __pyx_v_self->record->stopping_condition = __pyx_e_7sklearn_5earth_8_forward_MAXTERMS; + + /* "sklearn/earth/_forward.pyx":138 + * if self.record.iterations[last].get_size() + 2 > self.max_terms: + * self.record.stopping_condition = MAXTERMS + * return True # <<<<<<<<<<<<<< + * rsq = self.record.rsq(last) + * if rsq > 1 - self.thresh: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_forward.pyx":139 + * self.record.stopping_condition = MAXTERMS + * return True + * rsq = self.record.rsq(last) # <<<<<<<<<<<<<< + * if rsq > 1 - self.thresh: + * self.record.stopping_condition = MAXRSQ + */ + __pyx_t_5 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_last); if (unlikely((__pyx_t_5 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->__pyx_base.rsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self->record), __pyx_t_5, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_v_rsq = __pyx_t_3; + __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":140 + * return True + * rsq = self.record.rsq(last) + * if rsq > 1 - self.thresh: # <<<<<<<<<<<<<< + * self.record.stopping_condition = MAXRSQ + * return True + */ + __pyx_t_3 = PyFloat_FromDouble((1.0 - __pyx_v_self->thresh)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyObject_RichCompare(__pyx_v_rsq, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_4) { + + /* "sklearn/earth/_forward.pyx":141 + * rsq = self.record.rsq(last) + * if rsq > 1 - self.thresh: + * self.record.stopping_condition = MAXRSQ # <<<<<<<<<<<<<< + * return True + * previous_rsq = self.record.rsq(last - 1) + */ + __pyx_v_self->record->stopping_condition = __pyx_e_7sklearn_5earth_8_forward_MAXRSQ; + + /* "sklearn/earth/_forward.pyx":142 + * if rsq > 1 - self.thresh: + * self.record.stopping_condition = MAXRSQ + * return True # <<<<<<<<<<<<<< + * previous_rsq = self.record.rsq(last - 1) + * if rsq - previous_rsq < self.thresh: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + goto __pyx_L4; + } + __pyx_L4:; + + /* "sklearn/earth/_forward.pyx":143 + * self.record.stopping_condition = MAXRSQ + * return True + * previous_rsq = self.record.rsq(last - 1) # <<<<<<<<<<<<<< + * if rsq - previous_rsq < self.thresh: + * self.record.stopping_condition = NOIMPRV + */ + __pyx_t_1 = PyNumber_Subtract(__pyx_v_last, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_5 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->__pyx_base.rsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self->record), __pyx_t_5, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_previous_rsq = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":144 + * return True + * previous_rsq = self.record.rsq(last - 1) + * if rsq - previous_rsq < self.thresh: # <<<<<<<<<<<<<< + * self.record.stopping_condition = NOIMPRV + * return True + */ + __pyx_t_1 = PyNumber_Subtract(__pyx_v_rsq, __pyx_v_previous_rsq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->thresh); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_4) { + + /* "sklearn/earth/_forward.pyx":145 + * previous_rsq = self.record.rsq(last - 1) + * if rsq - previous_rsq < self.thresh: + * self.record.stopping_condition = NOIMPRV # <<<<<<<<<<<<<< + * return True + * if self.record.grsq(last) < -10: + */ + __pyx_v_self->record->stopping_condition = __pyx_e_7sklearn_5earth_8_forward_NOIMPRV; + + /* "sklearn/earth/_forward.pyx":146 + * if rsq - previous_rsq < self.thresh: + * self.record.stopping_condition = NOIMPRV + * return True # <<<<<<<<<<<<<< + * if self.record.grsq(last) < -10: + * self.record.stopping_condition = LOWGRSQ + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "sklearn/earth/_forward.pyx":147 + * self.record.stopping_condition = NOIMPRV + * return True + * if self.record.grsq(last) < -10: # <<<<<<<<<<<<<< + * self.record.stopping_condition = LOWGRSQ + * return True + */ + __pyx_t_5 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_last); if (unlikely((__pyx_t_5 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->__pyx_base.grsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self->record), __pyx_t_5, 0) < -10.0) != 0); + if (__pyx_t_4) { + + /* "sklearn/earth/_forward.pyx":148 + * return True + * if self.record.grsq(last) < -10: + * self.record.stopping_condition = LOWGRSQ # <<<<<<<<<<<<<< + * return True + * if self.record.iterations[last].no_further_candidates(): + */ + __pyx_v_self->record->stopping_condition = __pyx_e_7sklearn_5earth_8_forward_LOWGRSQ; + + /* "sklearn/earth/_forward.pyx":149 + * if self.record.grsq(last) < -10: + * self.record.stopping_condition = LOWGRSQ + * return True # <<<<<<<<<<<<<< + * if self.record.iterations[last].no_further_candidates(): + * self.record.stopping_condition = NOCAND + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + goto __pyx_L6; + } + __pyx_L6:; + + /* "sklearn/earth/_forward.pyx":150 + * self.record.stopping_condition = LOWGRSQ + * return True + * if self.record.iterations[last].no_further_candidates(): # <<<<<<<<<<<<<< + * self.record.stopping_condition = NOCAND + * return True + */ + if (unlikely(((PyObject *)__pyx_v_self->record->__pyx_base.iterations) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->record->__pyx_base.iterations), __pyx_v_last); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_4) { + + /* "sklearn/earth/_forward.pyx":151 + * return True + * if self.record.iterations[last].no_further_candidates(): + * self.record.stopping_condition = NOCAND # <<<<<<<<<<<<<< + * return True + * return False + */ + __pyx_v_self->record->stopping_condition = __pyx_e_7sklearn_5earth_8_forward_NOCAND; + + /* "sklearn/earth/_forward.pyx":152 + * if self.record.iterations[last].no_further_candidates(): + * self.record.stopping_condition = NOCAND + * return True # <<<<<<<<<<<<<< + * return False + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + goto __pyx_L7; + } + __pyx_L7:; + + /* "sklearn/earth/_forward.pyx":153 + * self.record.stopping_condition = NOCAND + * return True + * return False # <<<<<<<<<<<<<< + * + * cpdef int orthonormal_update(ForwardPasser self, INDEX_t k): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.stop_check", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_last); + __Pyx_XDECREF(__pyx_v_rsq); + __Pyx_XDECREF(__pyx_v_previous_rsq); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":155 + * return False + * + * cpdef int orthonormal_update(ForwardPasser self, INDEX_t k): # <<<<<<<<<<<<<< + * '''Orthogonalize and normalize column k of B_orth against all previous columns of B_orth.''' + * # Currently implemented using modified Gram-Schmidt process + */ + +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_11orthonormal_update(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static int __pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_orthonormal_update(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k, int __pyx_skip_dispatch) { + PyArrayObject *__pyx_v_B_orth = 0; + PyArrayObject *__pyx_v_c = 0; + PyArrayObject *__pyx_v_y = 0; + PyArrayObject *__pyx_v_norms = 0; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_j; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_nrm; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_nrm0; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_dot_prod; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B_orth; + __Pyx_Buffer __pyx_pybuffer_B_orth; + __Pyx_LocalBuf_ND __pyx_pybuffernd_c; + __Pyx_Buffer __pyx_pybuffer_c; + __Pyx_LocalBuf_ND __pyx_pybuffernd_norms; + __Pyx_Buffer __pyx_pybuffer_norms; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyArrayObject *__pyx_t_5 = NULL; + PyArrayObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + PyArrayObject *__pyx_t_8 = NULL; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_9; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_10; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_11; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_12; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_13; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_14; + int __pyx_t_15; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_16; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_17; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_18; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_19; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_20; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_21; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_22; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_23; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_24; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_25; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_26; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_27; + int __pyx_t_28; + int __pyx_t_29; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_30; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_31; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_32; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_33; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_34; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_35; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_36; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_37; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_38; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_39; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_40; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("orthonormal_update", 0); + __pyx_pybuffer_B_orth.pybuffer.buf = NULL; + __pyx_pybuffer_B_orth.refcount = 0; + __pyx_pybuffernd_B_orth.data = NULL; + __pyx_pybuffernd_B_orth.rcbuffer = &__pyx_pybuffer_B_orth; + __pyx_pybuffer_c.pybuffer.buf = NULL; + __pyx_pybuffer_c.refcount = 0; + __pyx_pybuffernd_c.data = NULL; + __pyx_pybuffernd_c.rcbuffer = &__pyx_pybuffer_c; + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_norms.pybuffer.buf = NULL; + __pyx_pybuffer_norms.refcount = 0; + __pyx_pybuffernd_norms.data = NULL; + __pyx_pybuffernd_norms.rcbuffer = &__pyx_pybuffer_norms; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__orthonormal_update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_11orthonormal_update)) { + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_forward.pyx":160 + * # TODO: Optimize - replace some for loops with calls to blas + * + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + */ + __pyx_t_5 = ((PyArrayObject *)__pyx_v_self->B_orth); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + __pyx_v_B_orth = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B_orth.diminfo[0].strides = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B_orth.diminfo[0].shape = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B_orth.diminfo[1].strides = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B_orth.diminfo[1].shape = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B_orth))); + __pyx_v_B_orth = ((PyArrayObject *)__pyx_v_self->B_orth); + + /* "sklearn/earth/_forward.pyx":161 + * + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] norms = self.norms + */ + __pyx_t_6 = ((PyArrayObject *)__pyx_v_self->c); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_c.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_c = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_c.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_c.diminfo[0].strides = __pyx_pybuffernd_c.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_c.diminfo[0].shape = __pyx_pybuffernd_c.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_6 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->c))); + __pyx_v_c = ((PyArrayObject *)__pyx_v_self->c); + + /* "sklearn/earth/_forward.pyx":162 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] norms = self.norms + * + */ + __pyx_t_7 = ((PyArrayObject *)__pyx_v_self->y); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_y = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_7 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->y))); + __pyx_v_y = ((PyArrayObject *)__pyx_v_self->y); + + /* "sklearn/earth/_forward.pyx":163 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] norms = self.norms # <<<<<<<<<<<<<< + * + * cdef INDEX_t i + */ + __pyx_t_8 = ((PyArrayObject *)__pyx_v_self->norms); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_norms.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_norms = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_norms.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_norms.diminfo[0].strides = __pyx_pybuffernd_norms.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_norms.diminfo[0].shape = __pyx_pybuffernd_norms.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_8 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->norms))); + __pyx_v_norms = ((PyArrayObject *)__pyx_v_self->norms); + + /* "sklearn/earth/_forward.pyx":172 + * + * # Get the original norm + * nrm0 = 0.0 # <<<<<<<<<<<<<< + * for i in range(self.m): + * nrm0 += B_orth[i, k] * B_orth[i, k] + */ + __pyx_v_nrm0 = 0.0; + + /* "sklearn/earth/_forward.pyx":173 + * # Get the original norm + * nrm0 = 0.0 + * for i in range(self.m): # <<<<<<<<<<<<<< + * nrm0 += B_orth[i, k] * B_orth[i, k] + * nrm0 = sqrt(nrm0) + */ + __pyx_t_9 = __pyx_v_self->m; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_i = __pyx_t_10; + + /* "sklearn/earth/_forward.pyx":174 + * nrm0 = 0.0 + * for i in range(self.m): + * nrm0 += B_orth[i, k] * B_orth[i, k] # <<<<<<<<<<<<<< + * nrm0 = sqrt(nrm0) + * + */ + __pyx_t_11 = __pyx_v_i; + __pyx_t_12 = __pyx_v_k; + __pyx_t_13 = __pyx_v_i; + __pyx_t_14 = __pyx_v_k; + __pyx_v_nrm0 = (__pyx_v_nrm0 + ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_B_orth.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_B_orth.diminfo[1].strides)))); + } + + /* "sklearn/earth/_forward.pyx":175 + * for i in range(self.m): + * nrm0 += B_orth[i, k] * B_orth[i, k] + * nrm0 = sqrt(nrm0) # <<<<<<<<<<<<<< + * + * # Orthogonalize + */ + __pyx_v_nrm0 = sqrt(__pyx_v_nrm0); + + /* "sklearn/earth/_forward.pyx":178 + * + * # Orthogonalize + * if k > 0: # <<<<<<<<<<<<<< + * for i in range(k): + * dot_prod = 0.0 + */ + __pyx_t_15 = ((__pyx_v_k > 0) != 0); + if (__pyx_t_15) { + + /* "sklearn/earth/_forward.pyx":179 + * # Orthogonalize + * if k > 0: + * for i in range(k): # <<<<<<<<<<<<<< + * dot_prod = 0.0 + * for j in range(self.m): + */ + __pyx_t_9 = __pyx_v_k; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_i = __pyx_t_10; + + /* "sklearn/earth/_forward.pyx":180 + * if k > 0: + * for i in range(k): + * dot_prod = 0.0 # <<<<<<<<<<<<<< + * for j in range(self.m): + * dot_prod += B_orth[j, k] * B_orth[j, i] + */ + __pyx_v_dot_prod = 0.0; + + /* "sklearn/earth/_forward.pyx":181 + * for i in range(k): + * dot_prod = 0.0 + * for j in range(self.m): # <<<<<<<<<<<<<< + * dot_prod += B_orth[j, k] * B_orth[j, i] + * for j in range(self.m): + */ + __pyx_t_16 = __pyx_v_self->m; + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + __pyx_v_j = __pyx_t_17; + + /* "sklearn/earth/_forward.pyx":182 + * dot_prod = 0.0 + * for j in range(self.m): + * dot_prod += B_orth[j, k] * B_orth[j, i] # <<<<<<<<<<<<<< + * for j in range(self.m): + * B_orth[j, k] -= B_orth[j, i] * dot_prod + */ + __pyx_t_18 = __pyx_v_j; + __pyx_t_19 = __pyx_v_k; + __pyx_t_20 = __pyx_v_j; + __pyx_t_21 = __pyx_v_i; + __pyx_v_dot_prod = (__pyx_v_dot_prod + ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_B_orth.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_B_orth.diminfo[1].strides)))); + } + + /* "sklearn/earth/_forward.pyx":183 + * for j in range(self.m): + * dot_prod += B_orth[j, k] * B_orth[j, i] + * for j in range(self.m): # <<<<<<<<<<<<<< + * B_orth[j, k] -= B_orth[j, i] * dot_prod + * + */ + __pyx_t_16 = __pyx_v_self->m; + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + __pyx_v_j = __pyx_t_17; + + /* "sklearn/earth/_forward.pyx":184 + * dot_prod += B_orth[j, k] * B_orth[j, i] + * for j in range(self.m): + * B_orth[j, k] -= B_orth[j, i] * dot_prod # <<<<<<<<<<<<<< + * + * # Normalize + */ + __pyx_t_22 = __pyx_v_j; + __pyx_t_23 = __pyx_v_i; + __pyx_t_24 = __pyx_v_j; + __pyx_t_25 = __pyx_v_k; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_B_orth.diminfo[1].strides) -= ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_B_orth.diminfo[1].strides)) * __pyx_v_dot_prod); + } + } + goto __pyx_L5; + } + __pyx_L5:; + + /* "sklearn/earth/_forward.pyx":187 + * + * # Normalize + * nrm = 0.0 # <<<<<<<<<<<<<< + * for i in range(self.m): + * nrm += B_orth[i, k] * B_orth[i, k] + */ + __pyx_v_nrm = 0.0; + + /* "sklearn/earth/_forward.pyx":188 + * # Normalize + * nrm = 0.0 + * for i in range(self.m): # <<<<<<<<<<<<<< + * nrm += B_orth[i, k] * B_orth[i, k] + * nrm = sqrt(nrm) + */ + __pyx_t_9 = __pyx_v_self->m; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_i = __pyx_t_10; + + /* "sklearn/earth/_forward.pyx":189 + * nrm = 0.0 + * for i in range(self.m): + * nrm += B_orth[i, k] * B_orth[i, k] # <<<<<<<<<<<<<< + * nrm = sqrt(nrm) + * norms[k] = nrm + */ + __pyx_t_16 = __pyx_v_i; + __pyx_t_17 = __pyx_v_k; + __pyx_t_26 = __pyx_v_i; + __pyx_t_27 = __pyx_v_k; + __pyx_v_nrm = (__pyx_v_nrm + ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_B_orth.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_B_orth.diminfo[1].strides)))); + } + + /* "sklearn/earth/_forward.pyx":190 + * for i in range(self.m): + * nrm += B_orth[i, k] * B_orth[i, k] + * nrm = sqrt(nrm) # <<<<<<<<<<<<<< + * norms[k] = nrm + * + */ + __pyx_v_nrm = sqrt(__pyx_v_nrm); + + /* "sklearn/earth/_forward.pyx":191 + * nrm += B_orth[i, k] * B_orth[i, k] + * nrm = sqrt(nrm) + * norms[k] = nrm # <<<<<<<<<<<<<< + * + * if nrm0 <= self.zero_tol or nrm / nrm0 <= self.zero_tol: + */ + __pyx_t_9 = __pyx_v_k; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_norms.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_norms.diminfo[0].strides) = __pyx_v_nrm; + + /* "sklearn/earth/_forward.pyx":193 + * norms[k] = nrm + * + * if nrm0 <= self.zero_tol or nrm / nrm0 <= self.zero_tol: # <<<<<<<<<<<<<< + * for i in range(self.m): + * B_orth[i, k] = 0.0 + */ + __pyx_t_15 = ((__pyx_v_nrm0 <= __pyx_v_self->zero_tol) != 0); + if (!__pyx_t_15) { + __pyx_t_28 = (((__pyx_v_nrm / __pyx_v_nrm0) <= __pyx_v_self->zero_tol) != 0); + __pyx_t_29 = __pyx_t_28; + } else { + __pyx_t_29 = __pyx_t_15; + } + if (__pyx_t_29) { + + /* "sklearn/earth/_forward.pyx":194 + * + * if nrm0 <= self.zero_tol or nrm / nrm0 <= self.zero_tol: + * for i in range(self.m): # <<<<<<<<<<<<<< + * B_orth[i, k] = 0.0 + * c[k] = 0.0 + */ + __pyx_t_10 = __pyx_v_self->m; + for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_10; __pyx_t_30+=1) { + __pyx_v_i = __pyx_t_30; + + /* "sklearn/earth/_forward.pyx":195 + * if nrm0 <= self.zero_tol or nrm / nrm0 <= self.zero_tol: + * for i in range(self.m): + * B_orth[i, k] = 0.0 # <<<<<<<<<<<<<< + * c[k] = 0.0 + * # The new column is in the column space of the previous columns + */ + __pyx_t_31 = __pyx_v_i; + __pyx_t_32 = __pyx_v_k; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_B_orth.diminfo[1].strides) = 0.0; + } + + /* "sklearn/earth/_forward.pyx":196 + * for i in range(self.m): + * B_orth[i, k] = 0.0 + * c[k] = 0.0 # <<<<<<<<<<<<<< + * # The new column is in the column space of the previous columns + * return 1 + */ + __pyx_t_10 = __pyx_v_k; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_c.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_c.diminfo[0].strides) = 0.0; + + /* "sklearn/earth/_forward.pyx":198 + * c[k] = 0.0 + * # The new column is in the column space of the previous columns + * return 1 # <<<<<<<<<<<<<< + * for i in range(self.m): + * B_orth[i, k] /= nrm + */ + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L14; + } + __pyx_L14:; + + /* "sklearn/earth/_forward.pyx":199 + * # The new column is in the column space of the previous columns + * return 1 + * for i in range(self.m): # <<<<<<<<<<<<<< + * B_orth[i, k] /= nrm + * + */ + __pyx_t_30 = __pyx_v_self->m; + for (__pyx_t_33 = 0; __pyx_t_33 < __pyx_t_30; __pyx_t_33+=1) { + __pyx_v_i = __pyx_t_33; + + /* "sklearn/earth/_forward.pyx":200 + * return 1 + * for i in range(self.m): + * B_orth[i, k] /= nrm # <<<<<<<<<<<<<< + * + * # Update c + */ + __pyx_t_34 = __pyx_v_i; + __pyx_t_35 = __pyx_v_k; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_B_orth.diminfo[1].strides) /= __pyx_v_nrm; + } + + /* "sklearn/earth/_forward.pyx":203 + * + * # Update c + * c[k] = 0.0 # <<<<<<<<<<<<<< + * for i in range(self.m): + * c[k] += B_orth[i, k] * y[i] + */ + __pyx_t_30 = __pyx_v_k; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_c.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_c.diminfo[0].strides) = 0.0; + + /* "sklearn/earth/_forward.pyx":204 + * # Update c + * c[k] = 0.0 + * for i in range(self.m): # <<<<<<<<<<<<<< + * c[k] += B_orth[i, k] * y[i] + * self.c_squared += c[k] ** 2 + */ + __pyx_t_33 = __pyx_v_self->m; + for (__pyx_t_36 = 0; __pyx_t_36 < __pyx_t_33; __pyx_t_36+=1) { + __pyx_v_i = __pyx_t_36; + + /* "sklearn/earth/_forward.pyx":205 + * c[k] = 0.0 + * for i in range(self.m): + * c[k] += B_orth[i, k] * y[i] # <<<<<<<<<<<<<< + * self.c_squared += c[k] ** 2 + * + */ + __pyx_t_37 = __pyx_v_i; + __pyx_t_38 = __pyx_v_k; + __pyx_t_39 = __pyx_v_i; + __pyx_t_40 = __pyx_v_k; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_c.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_c.diminfo[0].strides) += ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_38, __pyx_pybuffernd_B_orth.diminfo[1].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_y.diminfo[0].strides))); + } + + /* "sklearn/earth/_forward.pyx":206 + * for i in range(self.m): + * c[k] += B_orth[i, k] * y[i] + * self.c_squared += c[k] ** 2 # <<<<<<<<<<<<<< + * + * return 0 # No problems + */ + __pyx_t_33 = __pyx_v_k; + __pyx_v_self->c_squared = (__pyx_v_self->c_squared + pow((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_c.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_c.diminfo[0].strides)), 2.0)); + + /* "sklearn/earth/_forward.pyx":208 + * self.c_squared += c[k] ** 2 + * + * return 0 # No problems # <<<<<<<<<<<<<< + * + * cpdef orthonormal_downdate(ForwardPasser self, INDEX_t k): + */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_c.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_norms.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_WriteUnraisable("sklearn.earth._forward.ForwardPasser.orthonormal_update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_c.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_norms.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_B_orth); + __Pyx_XDECREF((PyObject *)__pyx_v_c); + __Pyx_XDECREF((PyObject *)__pyx_v_y); + __Pyx_XDECREF((PyObject *)__pyx_v_norms); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_11orthonormal_update(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static char __pyx_doc_7sklearn_5earth_8_forward_13ForwardPasser_10orthonormal_update[] = "Orthogonalize and normalize column k of B_orth against all previous columns of B_orth."; +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_11orthonormal_update(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("orthonormal_update (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_k); if (unlikely((__pyx_v_k == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.orthonormal_update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_10orthonormal_update(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_8_forward_INDEX_t)__pyx_v_k)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":155 + * return False + * + * cpdef int orthonormal_update(ForwardPasser self, INDEX_t k): # <<<<<<<<<<<<<< + * '''Orthogonalize and normalize column k of B_orth against all previous columns of B_orth.''' + * # Currently implemented using modified Gram-Schmidt process + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_10orthonormal_update(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("orthonormal_update", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_update(__pyx_v_self, __pyx_v_k, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.orthonormal_update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":210 + * return 0 # No problems + * + * cpdef orthonormal_downdate(ForwardPasser self, INDEX_t k): # <<<<<<<<<<<<<< + * ''' + * Undo the effects of the last orthonormal update. You can only undo the last orthonormal update this way. + */ + +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_13orthonormal_downdate(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_orthonormal_downdate(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("orthonormal_downdate", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_13orthonormal_downdate)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_forward.pyx":217 + * can simply be ignored until they are overwritten). + * ''' + * self.c_squared -= self.c[k] ** 2 # <<<<<<<<<<<<<< + * + * def trace(self): + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->c_squared); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->c), __pyx_v_k, sizeof(__pyx_t_7sklearn_5earth_8_forward_INDEX_t)+1, __Pyx_PyInt_to_py_npy_ulonglong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Power(__pyx_t_2, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_InPlaceSubtract(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_self->c_squared = __pyx_t_4; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.orthonormal_downdate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_13orthonormal_downdate(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static char __pyx_doc_7sklearn_5earth_8_forward_13ForwardPasser_12orthonormal_downdate[] = "\n Undo the effects of the last orthonormal update. You can only undo the last orthonormal update this way.\n There will be no warning of any kind if you mess this up. You'll just get wrong answers.\n In reality, all this does is downdate c_squared (the elements of c and B_orth are left alone, since they\n can simply be ignored until they are overwritten).\n "; +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_13orthonormal_downdate(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("orthonormal_downdate (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_k); if (unlikely((__pyx_v_k == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.orthonormal_downdate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_12orthonormal_downdate(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_8_forward_INDEX_t)__pyx_v_k)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":210 + * return 0 # No problems + * + * cpdef orthonormal_downdate(ForwardPasser self, INDEX_t k): # <<<<<<<<<<<<<< + * ''' + * Undo the effects of the last orthonormal update. You can only undo the last orthonormal update this way. + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_12orthonormal_downdate(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("orthonormal_downdate", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_downdate(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.orthonormal_downdate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_15trace(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_15trace(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("trace (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_14trace(((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":219 + * self.c_squared -= self.c[k] ** 2 + * + * def trace(self): # <<<<<<<<<<<<<< + * return self.record + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_forward_13ForwardPasser_14trace(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("trace", 0); + + /* "sklearn/earth/_forward.pyx":220 + * + * def trace(self): + * return self.record # <<<<<<<<<<<<<< + * + * cdef next_pair(ForwardPasser self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->record)); + __pyx_r = ((PyObject *)__pyx_v_self->record); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":222 + * return self.record + * + * cdef next_pair(ForwardPasser self): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef INDEX_t parent_idx + */ + +static PyObject *__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_next_pair(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self) { + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_variable; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_parent_idx; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_parent_degree; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent = 0; + PyArrayObject *__pyx_v_candidates_idx = 0; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_knot; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_mse; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_knot_idx; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_knot_choice; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_mse_choice; + int __pyx_v_knot_idx_choice; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_parent_idx_choice; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_parent_choice = 0; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_variable_choice; + int __pyx_v_first; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_bf1 = 0; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *__pyx_v_bf2 = 0; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_endspan; + int __pyx_v_linear_dependence; + int __pyx_v_dependent; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_gcv_factor_k_plus_1; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_gcv_factor_k_plus_2; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_gcv_; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_mse_; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_i; + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_B = 0; + PyArrayObject *__pyx_v_B_orth = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_y = 0; + PyArrayObject *__pyx_v_linear_variables = 0; + PyArrayObject *__pyx_v_sorting = 0; + PyArrayObject *__pyx_v_sample_weight = 0; + PyObject *__pyx_v_label = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B_orth; + __Pyx_Buffer __pyx_pybuffer_B_orth; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_candidates_idx; + __Pyx_Buffer __pyx_pybuffer_candidates_idx; + __Pyx_LocalBuf_ND __pyx_pybuffernd_linear_variables; + __Pyx_Buffer __pyx_pybuffer_linear_variables; + __Pyx_LocalBuf_ND __pyx_pybuffernd_sample_weight; + __Pyx_Buffer __pyx_pybuffer_sample_weight; + __Pyx_LocalBuf_ND __pyx_pybuffernd_sorting; + __Pyx_Buffer __pyx_pybuffer_sorting; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyArrayObject *__pyx_t_3 = NULL; + PyArrayObject *__pyx_t_4 = NULL; + PyArrayObject *__pyx_t_5 = NULL; + PyArrayObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + PyArrayObject *__pyx_t_8 = NULL; + PyArrayObject *__pyx_t_9 = NULL; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_12; + int __pyx_t_13; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_14; + PyObject *__pyx_t_15 = NULL; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_16; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_17; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_18; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_19; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_20; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_21; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_22; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_23; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_24; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_25; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_26; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_27; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_28; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_29; + PyObject *__pyx_t_30 = NULL; + PyObject *__pyx_t_31 = NULL; + PyObject *__pyx_t_32 = NULL; + PyObject *__pyx_t_33 = NULL; + int __pyx_t_34; + Py_ssize_t __pyx_t_35; + PyObject *__pyx_t_36 = NULL; + int __pyx_t_37; + PyObject *__pyx_t_38 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("next_pair", 0); + __pyx_pybuffer_candidates_idx.pybuffer.buf = NULL; + __pyx_pybuffer_candidates_idx.refcount = 0; + __pyx_pybuffernd_candidates_idx.data = NULL; + __pyx_pybuffernd_candidates_idx.rcbuffer = &__pyx_pybuffer_candidates_idx; + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_B_orth.pybuffer.buf = NULL; + __pyx_pybuffer_B_orth.refcount = 0; + __pyx_pybuffernd_B_orth.data = NULL; + __pyx_pybuffernd_B_orth.rcbuffer = &__pyx_pybuffer_B_orth; + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_linear_variables.pybuffer.buf = NULL; + __pyx_pybuffer_linear_variables.refcount = 0; + __pyx_pybuffernd_linear_variables.data = NULL; + __pyx_pybuffernd_linear_variables.rcbuffer = &__pyx_pybuffer_linear_variables; + __pyx_pybuffer_sorting.pybuffer.buf = NULL; + __pyx_pybuffer_sorting.refcount = 0; + __pyx_pybuffernd_sorting.data = NULL; + __pyx_pybuffernd_sorting.rcbuffer = &__pyx_pybuffer_sorting; + __pyx_pybuffer_sample_weight.pybuffer.buf = NULL; + __pyx_pybuffer_sample_weight.refcount = 0; + __pyx_pybuffernd_sample_weight.data = NULL; + __pyx_pybuffernd_sample_weight.rcbuffer = &__pyx_pybuffer_sample_weight; + + /* "sklearn/earth/_forward.pyx":238 + * cdef BasisFunction parent_choice + * cdef INDEX_t variable_choice + * cdef bint first = True # <<<<<<<<<<<<<< + * cdef BasisFunction bf1 + * cdef BasisFunction bf2 + */ + __pyx_v_first = 1; + + /* "sklearn/earth/_forward.pyx":241 + * cdef BasisFunction bf1 + * cdef BasisFunction bf2 + * cdef INDEX_t k = len(self.basis) # <<<<<<<<<<<<<< + * cdef INDEX_t endspan + * cdef bint linear_dependence + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->basis); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_k = __pyx_t_2; + + /* "sklearn/earth/_forward.pyx":245 + * cdef bint linear_dependence + * cdef bint dependent + * cdef FLOAT_t gcv_factor_k_plus_1 = gcv_adjust(k + 1, self.m, self.penalty) # <<<<<<<<<<<<<< + * cdef FLOAT_t gcv_factor_k_plus_2 = gcv_adjust(k + 2, self.m, self.penalty) + * cdef FLOAT_t gcv_ + */ + __pyx_v_gcv_factor_k_plus_1 = __pyx_f_7sklearn_5earth_5_util_gcv_adjust((__pyx_v_k + 1), __pyx_v_self->m, __pyx_v_self->penalty, 0); + + /* "sklearn/earth/_forward.pyx":246 + * cdef bint dependent + * cdef FLOAT_t gcv_factor_k_plus_1 = gcv_adjust(k + 1, self.m, self.penalty) + * cdef FLOAT_t gcv_factor_k_plus_2 = gcv_adjust(k + 2, self.m, self.penalty) # <<<<<<<<<<<<<< + * cdef FLOAT_t gcv_ + * cdef FLOAT_t mse_ + */ + __pyx_v_gcv_factor_k_plus_2 = __pyx_f_7sklearn_5earth_5_util_gcv_adjust((__pyx_v_k + 2), __pyx_v_self->m, __pyx_v_self->penalty, 0); + + /* "sklearn/earth/_forward.pyx":251 + * cdef INDEX_t i + * + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + */ + __pyx_t_3 = ((PyArrayObject *)__pyx_v_self->X); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_X.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_3 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->X))); + __pyx_v_X = ((PyArrayObject *)__pyx_v_self->X); + + /* "sklearn/earth/_forward.pyx":252 + * + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + */ + __pyx_t_4 = ((PyArrayObject *)__pyx_v_self->B); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + __pyx_v_B = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_4 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B))); + __pyx_v_B = ((PyArrayObject *)__pyx_v_self->B); + + /* "sklearn/earth/_forward.pyx":253 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + */ + __pyx_t_5 = ((PyArrayObject *)__pyx_v_self->B_orth); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + __pyx_v_B_orth = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B_orth.diminfo[0].strides = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B_orth.diminfo[0].shape = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B_orth.diminfo[1].strides = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B_orth.diminfo[1].shape = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B_orth))); + __pyx_v_B_orth = ((PyArrayObject *)__pyx_v_self->B_orth); + + /* "sklearn/earth/_forward.pyx":254 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y # <<<<<<<<<<<<<< + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + * cdef cnp.ndarray[INT_t, ndim = 1] sorting = self.sorting + */ + __pyx_t_6 = ((PyArrayObject *)__pyx_v_self->y); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_y = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_6 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->y))); + __pyx_v_y = ((PyArrayObject *)__pyx_v_self->y); + + /* "sklearn/earth/_forward.pyx":255 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables # <<<<<<<<<<<<<< + * cdef cnp.ndarray[INT_t, ndim = 1] sorting = self.sorting + * cdef cnp.ndarray[FLOAT_t, ndim = 1] sample_weight = self.sample_weight + */ + __pyx_t_7 = ((PyArrayObject *)__pyx_v_self->linear_variables); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_linear_variables.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_linear_variables = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_linear_variables.diminfo[0].strides = __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_linear_variables.diminfo[0].shape = __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_7 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->linear_variables))); + __pyx_v_linear_variables = ((PyArrayObject *)__pyx_v_self->linear_variables); + + /* "sklearn/earth/_forward.pyx":256 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + * cdef cnp.ndarray[INT_t, ndim = 1] sorting = self.sorting # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] sample_weight = self.sample_weight + * + */ + __pyx_t_8 = ((PyArrayObject *)__pyx_v_self->sorting); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sorting.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_sorting = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_sorting.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_sorting.diminfo[0].strides = __pyx_pybuffernd_sorting.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sorting.diminfo[0].shape = __pyx_pybuffernd_sorting.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_8 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->sorting))); + __pyx_v_sorting = ((PyArrayObject *)__pyx_v_self->sorting); + + /* "sklearn/earth/_forward.pyx":257 + * cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + * cdef cnp.ndarray[INT_t, ndim = 1] sorting = self.sorting + * cdef cnp.ndarray[FLOAT_t, ndim = 1] sample_weight = self.sample_weight # <<<<<<<<<<<<<< + * + * if self.endspan < 0: + */ + __pyx_t_9 = ((PyArrayObject *)__pyx_v_self->sample_weight); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sample_weight.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_sample_weight = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_sample_weight.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_sample_weight.diminfo[0].strides = __pyx_pybuffernd_sample_weight.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sample_weight.diminfo[0].shape = __pyx_pybuffernd_sample_weight.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_9 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->sample_weight))); + __pyx_v_sample_weight = ((PyArrayObject *)__pyx_v_self->sample_weight); + + /* "sklearn/earth/_forward.pyx":259 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] sample_weight = self.sample_weight + * + * if self.endspan < 0: # <<<<<<<<<<<<<< + * endspan = round(3 - log2(self.endspan_alpha / self.n)) + * else: + */ + __pyx_t_10 = ((__pyx_v_self->endspan < 0) != 0); + if (__pyx_t_10) { + + /* "sklearn/earth/_forward.pyx":260 + * + * if self.endspan < 0: + * endspan = round(3 - log2(self.endspan_alpha / self.n)) # <<<<<<<<<<<<<< + * else: + * endspan = self.endspan + */ + __pyx_t_1 = PyFloat_FromDouble((3.0 - __pyx_f_7sklearn_5earth_5_util_log2((__pyx_v_self->endspan_alpha / __pyx_v_self->n)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_builtin_round, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; + __pyx_t_12 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_12 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_endspan = __pyx_t_12; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":262 + * endspan = round(3 - log2(self.endspan_alpha / self.n)) + * else: + * endspan = self.endspan # <<<<<<<<<<<<<< + * + * # Iterate over variables + */ + __pyx_t_13 = __pyx_v_self->endspan; + __pyx_v_endspan = __pyx_t_13; + } + __pyx_L3:; + + /* "sklearn/earth/_forward.pyx":265 + * + * # Iterate over variables + * for variable in range(self.n): # <<<<<<<<<<<<<< + * + * # Sort the data + */ + __pyx_t_12 = __pyx_v_self->n; + for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_12; __pyx_t_14+=1) { + __pyx_v_variable = __pyx_t_14; + + /* "sklearn/earth/_forward.pyx":269 + * # Sort the data + * # TODO: eliminate Python call / data copy + * sorting[:] = np.argsort(X[:, variable])[::-1] # <<<<<<<<<<<<<< + * + * # Iterate over parents + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__argsort); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(__pyx_k_slice_11); + PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_k_slice_11); + __Pyx_GIVEREF(__pyx_k_slice_11); + PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_X), ((PyObject *)__pyx_t_15)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __pyx_t_15 = PyObject_GetItem(__pyx_t_1, __pyx_k_slice_12); if (!__pyx_t_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__Pyx_PyObject_SetSlice(((PyObject *)__pyx_v_sorting), __pyx_t_15, 0, 0, NULL, NULL, &__pyx_k_slice_13, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + + /* "sklearn/earth/_forward.pyx":272 + * + * # Iterate over parents + * for parent_idx in range(k): # <<<<<<<<<<<<<< + * linear_dependence = False + * + */ + __pyx_t_16 = __pyx_v_k; + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + __pyx_v_parent_idx = __pyx_t_17; + + /* "sklearn/earth/_forward.pyx":273 + * # Iterate over parents + * for parent_idx in range(k): + * linear_dependence = False # <<<<<<<<<<<<<< + * + * parent = self.basis.get(parent_idx) + */ + __pyx_v_linear_dependence = 0; + + /* "sklearn/earth/_forward.pyx":275 + * linear_dependence = False + * + * parent = self.basis.get(parent_idx) # <<<<<<<<<<<<<< + * if self.max_degree >= 0: + * parent_degree = parent.degree() + */ + __pyx_t_15 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->get(__pyx_v_self->basis, __pyx_v_parent_idx, 0)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_XDECREF_SET(__pyx_v_parent, ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_15)); + __pyx_t_15 = 0; + + /* "sklearn/earth/_forward.pyx":276 + * + * parent = self.basis.get(parent_idx) + * if self.max_degree >= 0: # <<<<<<<<<<<<<< + * parent_degree = parent.degree() + * if parent_degree >= self.max_degree: + */ + __pyx_t_10 = ((__pyx_v_self->max_degree >= 0) != 0); + if (__pyx_t_10) { + + /* "sklearn/earth/_forward.pyx":277 + * parent = self.basis.get(parent_idx) + * if self.max_degree >= 0: + * parent_degree = parent.degree() # <<<<<<<<<<<<<< + * if parent_degree >= self.max_degree: + * continue + */ + __pyx_v_parent_degree = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_parent->__pyx_vtab)->degree(__pyx_v_parent, 0); + + /* "sklearn/earth/_forward.pyx":278 + * if self.max_degree >= 0: + * parent_degree = parent.degree() + * if parent_degree >= self.max_degree: # <<<<<<<<<<<<<< + * continue + * if not parent.is_splittable(): + */ + __pyx_t_10 = ((__pyx_v_parent_degree >= __pyx_v_self->max_degree) != 0); + if (__pyx_t_10) { + + /* "sklearn/earth/_forward.pyx":279 + * parent_degree = parent.degree() + * if parent_degree >= self.max_degree: + * continue # <<<<<<<<<<<<<< + * if not parent.is_splittable(): + * continue + */ + goto __pyx_L6_continue; + goto __pyx_L9; + } + __pyx_L9:; + goto __pyx_L8; + } + __pyx_L8:; + + /* "sklearn/earth/_forward.pyx":280 + * if parent_degree >= self.max_degree: + * continue + * if not parent.is_splittable(): # <<<<<<<<<<<<<< + * continue + * + */ + __pyx_t_10 = ((!(((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_parent->__pyx_vtab)->is_splittable(__pyx_v_parent, 0) != 0)) != 0); + if (__pyx_t_10) { + + /* "sklearn/earth/_forward.pyx":281 + * continue + * if not parent.is_splittable(): + * continue # <<<<<<<<<<<<<< + * + * # Add the linear term to B + */ + goto __pyx_L6_continue; + goto __pyx_L10; + } + __pyx_L10:; + + /* "sklearn/earth/_forward.pyx":284 + * + * # Add the linear term to B + * for i in range(self.m): # <<<<<<<<<<<<<< + * B[i, k] = B[i, parent_idx] * X[i, variable] + * + */ + __pyx_t_18 = __pyx_v_self->m; + for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { + __pyx_v_i = __pyx_t_19; + + /* "sklearn/earth/_forward.pyx":285 + * # Add the linear term to B + * for i in range(self.m): + * B[i, k] = B[i, parent_idx] * X[i, variable] # <<<<<<<<<<<<<< + * + * # Orthonormalize + */ + __pyx_t_20 = __pyx_v_i; + __pyx_t_21 = __pyx_v_parent_idx; + __pyx_t_22 = __pyx_v_i; + __pyx_t_23 = __pyx_v_variable; + __pyx_t_24 = __pyx_v_i; + __pyx_t_25 = __pyx_v_k; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_B.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_B.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_B.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_B.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_X.diminfo[1].strides))); + } + + /* "sklearn/earth/_forward.pyx":288 + * + * # Orthonormalize + * for i in range(self.m): # <<<<<<<<<<<<<< + * B_orth[i, k] = B[i, k] + * linear_dependence = self.orthonormal_update(k) + */ + __pyx_t_18 = __pyx_v_self->m; + for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { + __pyx_v_i = __pyx_t_19; + + /* "sklearn/earth/_forward.pyx":289 + * # Orthonormalize + * for i in range(self.m): + * B_orth[i, k] = B[i, k] # <<<<<<<<<<<<<< + * linear_dependence = self.orthonormal_update(k) + * + */ + __pyx_t_26 = __pyx_v_i; + __pyx_t_27 = __pyx_v_k; + __pyx_t_28 = __pyx_v_i; + __pyx_t_29 = __pyx_v_k; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_B_orth.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_B.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_B.diminfo[1].strides)); + } + + /* "sklearn/earth/_forward.pyx":290 + * for i in range(self.m): + * B_orth[i, k] = B[i, k] + * linear_dependence = self.orthonormal_update(k) # <<<<<<<<<<<<<< + * + * # If a new hinge function does not improve the gcv over the linear term + */ + __pyx_v_linear_dependence = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_update(__pyx_v_self, __pyx_v_k, 0); + + /* "sklearn/earth/_forward.pyx":297 + * # with another term never increases, but the gcv may because it penalizes + * # additional terms. + * mse_ = (self.y_squared - self.c_squared) / self.m # <<<<<<<<<<<<<< + * gcv_ = gcv_factor_k_plus_1 * \ + * (self.y_squared - self.c_squared) / self.m + */ + __pyx_v_mse_ = ((__pyx_v_self->y_squared - __pyx_v_self->c_squared) / __pyx_v_self->m); + + /* "sklearn/earth/_forward.pyx":299 + * mse_ = (self.y_squared - self.c_squared) / self.m + * gcv_ = gcv_factor_k_plus_1 * \ + * (self.y_squared - self.c_squared) / self.m # <<<<<<<<<<<<<< + * + * if linear_variables[variable]: + */ + __pyx_v_gcv_ = ((__pyx_v_gcv_factor_k_plus_1 * (__pyx_v_self->y_squared - __pyx_v_self->c_squared)) / __pyx_v_self->m); + + /* "sklearn/earth/_forward.pyx":301 + * (self.y_squared - self.c_squared) / self.m + * + * if linear_variables[variable]: # <<<<<<<<<<<<<< + * mse = mse_ + * knot_idx = -1 + */ + __pyx_t_18 = __pyx_v_variable; + __pyx_t_10 = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_linear_variables.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_linear_variables.diminfo[0].strides)) != 0); + if (__pyx_t_10) { + + /* "sklearn/earth/_forward.pyx":302 + * + * if linear_variables[variable]: + * mse = mse_ # <<<<<<<<<<<<<< + * knot_idx = -1 + * else: + */ + __pyx_v_mse = __pyx_v_mse_; + + /* "sklearn/earth/_forward.pyx":303 + * if linear_variables[variable]: + * mse = mse_ + * knot_idx = -1 # <<<<<<<<<<<<<< + * else: + * + */ + __pyx_v_knot_idx = -1; + goto __pyx_L15; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":307 + * + * # Find the valid knot candidates + * candidates_idx = parent.valid_knots(B[sorting, parent_idx], X[ # <<<<<<<<<<<<<< + * sorting, variable], variable, self.check_every, endspan, self.minspan, self.minspan_alpha, self.n, self.mwork) + * + */ + __pyx_t_15 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_parent_idx); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_sorting)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_sorting)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_sorting)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_t_15 = 0; + __pyx_t_15 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_1)); if (!__pyx_t_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_forward.pyx":308 + * # Find the valid knot candidates + * candidates_idx = parent.valid_knots(B[sorting, parent_idx], X[ + * sorting, variable], variable, self.check_every, endspan, self.minspan, self.minspan_alpha, self.n, self.mwork) # <<<<<<<<<<<<<< + * + * if len(candidates_idx) > 0: + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_INCREF(((PyObject *)__pyx_v_sorting)); + PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_v_sorting)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_sorting)); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_X), ((PyObject *)__pyx_t_11)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = ((PyObject *)__pyx_v_self->mwork); + __Pyx_INCREF(__pyx_t_11); + __pyx_t_30 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_parent->__pyx_vtab)->valid_knots(__pyx_v_parent, ((PyArrayObject *)__pyx_t_15), ((PyArrayObject *)__pyx_t_1), __pyx_v_variable, __pyx_v_self->check_every, __pyx_v_endspan, __pyx_v_self->minspan, __pyx_v_self->minspan_alpha, __pyx_v_self->n, ((PyArrayObject *)__pyx_t_11), 0)); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_candidates_idx.rcbuffer->pybuffer); + __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_candidates_idx.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_30), &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_13 < 0)) { + PyErr_Fetch(&__pyx_t_31, &__pyx_t_32, &__pyx_t_33); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_candidates_idx.rcbuffer->pybuffer, (PyObject*)__pyx_v_candidates_idx, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_31); Py_XDECREF(__pyx_t_32); Py_XDECREF(__pyx_t_33); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_31, __pyx_t_32, __pyx_t_33); + } + } + __pyx_pybuffernd_candidates_idx.diminfo[0].strides = __pyx_pybuffernd_candidates_idx.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_candidates_idx.diminfo[0].shape = __pyx_pybuffernd_candidates_idx.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_XDECREF_SET(__pyx_v_candidates_idx, ((PyArrayObject *)__pyx_t_30)); + __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":310 + * sorting, variable], variable, self.check_every, endspan, self.minspan, self.minspan_alpha, self.n, self.mwork) + * + * if len(candidates_idx) > 0: # <<<<<<<<<<<<<< + * # Choose the best candidate (if no candidate is an + * # improvement on the linear term in terms of gcv, knot_idx + */ + __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_candidates_idx)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((__pyx_t_2 > 0) != 0); + if (__pyx_t_10) { + + /* "sklearn/earth/_forward.pyx":317 + * # Find the best knot location for this parent and + * # variable combination + * self.best_knot(parent_idx, variable, k, candidates_idx, sorting, & mse, & knot, & knot_idx) # <<<<<<<<<<<<<< + * + * # If the hinge function does not decrease the gcv then + */ + __pyx_t_30 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->best_knot(__pyx_v_self, __pyx_v_parent_idx, __pyx_v_variable, __pyx_v_k, ((PyArrayObject *)__pyx_v_candidates_idx), ((PyArrayObject *)__pyx_v_sorting), (&__pyx_v_mse), (&__pyx_v_knot), (&__pyx_v_knot_idx)); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":321 + * # If the hinge function does not decrease the gcv then + * # just keep the linear term (if allow_linear is True) + * if self.allow_linear and (gcv_factor_k_plus_2 * mse >= gcv_): # <<<<<<<<<<<<<< + * mse = mse_ + * knot_idx = -1 + */ + if ((__pyx_v_self->allow_linear != 0)) { + __pyx_t_10 = (((__pyx_v_gcv_factor_k_plus_2 * __pyx_v_mse) >= __pyx_v_gcv_) != 0); + __pyx_t_34 = __pyx_t_10; + } else { + __pyx_t_34 = (__pyx_v_self->allow_linear != 0); + } + if (__pyx_t_34) { + + /* "sklearn/earth/_forward.pyx":322 + * # just keep the linear term (if allow_linear is True) + * if self.allow_linear and (gcv_factor_k_plus_2 * mse >= gcv_): + * mse = mse_ # <<<<<<<<<<<<<< + * knot_idx = -1 + * + */ + __pyx_v_mse = __pyx_v_mse_; + + /* "sklearn/earth/_forward.pyx":323 + * if self.allow_linear and (gcv_factor_k_plus_2 * mse >= gcv_): + * mse = mse_ + * knot_idx = -1 # <<<<<<<<<<<<<< + * + * else: + */ + __pyx_v_knot_idx = -1; + goto __pyx_L17; + } + __pyx_L17:; + goto __pyx_L16; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":328 + * # Do an orthonormal downdate and skip to the next + * # iteration + * self.orthonormal_downdate(k) # <<<<<<<<<<<<<< + * continue + * + */ + __pyx_t_30 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_downdate(__pyx_v_self, __pyx_v_k, 0); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":329 + * # iteration + * self.orthonormal_downdate(k) + * continue # <<<<<<<<<<<<<< + * + * # Do an orthonormal downdate + */ + goto __pyx_L6_continue; + } + __pyx_L16:; + } + __pyx_L15:; + + /* "sklearn/earth/_forward.pyx":332 + * + * # Do an orthonormal downdate + * self.orthonormal_downdate(k) # <<<<<<<<<<<<<< + * + * # Update the choices + */ + __pyx_t_30 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_downdate(__pyx_v_self, __pyx_v_k, 0); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":335 + * + * # Update the choices + * if first: # <<<<<<<<<<<<<< + * knot_choice = knot + * mse_choice = mse + */ + __pyx_t_34 = (__pyx_v_first != 0); + if (__pyx_t_34) { + + /* "sklearn/earth/_forward.pyx":336 + * # Update the choices + * if first: + * knot_choice = knot # <<<<<<<<<<<<<< + * mse_choice = mse + * knot_idx_choice = knot_idx + */ + __pyx_v_knot_choice = __pyx_v_knot; + + /* "sklearn/earth/_forward.pyx":337 + * if first: + * knot_choice = knot + * mse_choice = mse # <<<<<<<<<<<<<< + * knot_idx_choice = knot_idx + * parent_idx_choice = parent_idx + */ + __pyx_v_mse_choice = __pyx_v_mse; + + /* "sklearn/earth/_forward.pyx":338 + * knot_choice = knot + * mse_choice = mse + * knot_idx_choice = knot_idx # <<<<<<<<<<<<<< + * parent_idx_choice = parent_idx + * parent_choice = parent + */ + __pyx_v_knot_idx_choice = __pyx_v_knot_idx; + + /* "sklearn/earth/_forward.pyx":339 + * mse_choice = mse + * knot_idx_choice = knot_idx + * parent_idx_choice = parent_idx # <<<<<<<<<<<<<< + * parent_choice = parent + * variable_choice = variable + */ + __pyx_v_parent_idx_choice = __pyx_v_parent_idx; + + /* "sklearn/earth/_forward.pyx":340 + * knot_idx_choice = knot_idx + * parent_idx_choice = parent_idx + * parent_choice = parent # <<<<<<<<<<<<<< + * variable_choice = variable + * first = False + */ + __Pyx_INCREF(((PyObject *)__pyx_v_parent)); + __Pyx_XDECREF_SET(__pyx_v_parent_choice, __pyx_v_parent); + + /* "sklearn/earth/_forward.pyx":341 + * parent_idx_choice = parent_idx + * parent_choice = parent + * variable_choice = variable # <<<<<<<<<<<<<< + * first = False + * dependent = linear_dependence + */ + __pyx_v_variable_choice = __pyx_v_variable; + + /* "sklearn/earth/_forward.pyx":342 + * parent_choice = parent + * variable_choice = variable + * first = False # <<<<<<<<<<<<<< + * dependent = linear_dependence + * if mse < mse_choice: + */ + __pyx_v_first = 0; + + /* "sklearn/earth/_forward.pyx":343 + * variable_choice = variable + * first = False + * dependent = linear_dependence # <<<<<<<<<<<<<< + * if mse < mse_choice: + * knot_choice = knot + */ + __pyx_v_dependent = __pyx_v_linear_dependence; + goto __pyx_L18; + } + __pyx_L18:; + + /* "sklearn/earth/_forward.pyx":344 + * first = False + * dependent = linear_dependence + * if mse < mse_choice: # <<<<<<<<<<<<<< + * knot_choice = knot + * mse_choice = mse + */ + __pyx_t_34 = ((__pyx_v_mse < __pyx_v_mse_choice) != 0); + if (__pyx_t_34) { + + /* "sklearn/earth/_forward.pyx":345 + * dependent = linear_dependence + * if mse < mse_choice: + * knot_choice = knot # <<<<<<<<<<<<<< + * mse_choice = mse + * knot_idx_choice = knot_idx + */ + __pyx_v_knot_choice = __pyx_v_knot; + + /* "sklearn/earth/_forward.pyx":346 + * if mse < mse_choice: + * knot_choice = knot + * mse_choice = mse # <<<<<<<<<<<<<< + * knot_idx_choice = knot_idx + * parent_idx_choice = parent_idx + */ + __pyx_v_mse_choice = __pyx_v_mse; + + /* "sklearn/earth/_forward.pyx":347 + * knot_choice = knot + * mse_choice = mse + * knot_idx_choice = knot_idx # <<<<<<<<<<<<<< + * parent_idx_choice = parent_idx + * parent_choice = parent + */ + __pyx_v_knot_idx_choice = __pyx_v_knot_idx; + + /* "sklearn/earth/_forward.pyx":348 + * mse_choice = mse + * knot_idx_choice = knot_idx + * parent_idx_choice = parent_idx # <<<<<<<<<<<<<< + * parent_choice = parent + * variable_choice = variable + */ + __pyx_v_parent_idx_choice = __pyx_v_parent_idx; + + /* "sklearn/earth/_forward.pyx":349 + * knot_idx_choice = knot_idx + * parent_idx_choice = parent_idx + * parent_choice = parent # <<<<<<<<<<<<<< + * variable_choice = variable + * dependent = linear_dependence + */ + __Pyx_INCREF(((PyObject *)__pyx_v_parent)); + __Pyx_XDECREF_SET(__pyx_v_parent_choice, __pyx_v_parent); + + /* "sklearn/earth/_forward.pyx":350 + * parent_idx_choice = parent_idx + * parent_choice = parent + * variable_choice = variable # <<<<<<<<<<<<<< + * dependent = linear_dependence + * + */ + __pyx_v_variable_choice = __pyx_v_variable; + + /* "sklearn/earth/_forward.pyx":351 + * parent_choice = parent + * variable_choice = variable + * dependent = linear_dependence # <<<<<<<<<<<<<< + * + * # Make sure at least one candidate was checked + */ + __pyx_v_dependent = __pyx_v_linear_dependence; + goto __pyx_L19; + } + __pyx_L19:; + __pyx_L6_continue:; + } + } + + /* "sklearn/earth/_forward.pyx":354 + * + * # Make sure at least one candidate was checked + * if first: # <<<<<<<<<<<<<< + * self.record[len(self.record) - 1].set_no_candidates(True) + * return + */ + __pyx_t_34 = (__pyx_v_first != 0); + if (__pyx_t_34) { + + /* "sklearn/earth/_forward.pyx":355 + * # Make sure at least one candidate was checked + * if first: + * self.record[len(self.record) - 1].set_no_candidates(True) # <<<<<<<<<<<<<< + * return + * + */ + __pyx_t_30 = ((PyObject *)__pyx_v_self->record); + __Pyx_INCREF(__pyx_t_30); + __pyx_t_2 = PyObject_Length(__pyx_t_30); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + __pyx_t_35 = (__pyx_t_2 - 1); + __pyx_t_30 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->record), __pyx_t_35, sizeof(Py_ssize_t), PyInt_FromSsize_t, 0, 0, 0); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_n_s__set_no_candidates); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + __pyx_t_30 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_30); + __Pyx_GIVEREF(__pyx_t_30); + __pyx_t_30 = 0; + __pyx_t_30 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":356 + * if first: + * self.record[len(self.record) - 1].set_no_candidates(True) + * return # <<<<<<<<<<<<<< + * + * # Add the new basis functions + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + goto __pyx_L20; + } + __pyx_L20:; + + /* "sklearn/earth/_forward.pyx":359 + * + * # Add the new basis functions + * parent = self.basis.get(parent_idx) # <<<<<<<<<<<<<< + * label = self.xlabels[variable_choice] + * if knot_idx_choice != -1: + */ + __pyx_t_30 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->get(__pyx_v_self->basis, __pyx_v_parent_idx, 0)); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_XDECREF_SET(__pyx_v_parent, ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_30)); + __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":360 + * # Add the new basis functions + * parent = self.basis.get(parent_idx) + * label = self.xlabels[variable_choice] # <<<<<<<<<<<<<< + * if knot_idx_choice != -1: + * # Add the new basis functions + */ + if (unlikely(((PyObject *)__pyx_v_self->xlabels) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_30 = PyList_GET_ITEM(__pyx_v_self->xlabels, __pyx_v_variable_choice); + __Pyx_INCREF(__pyx_t_30); + __pyx_v_label = __pyx_t_30; + __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":361 + * parent = self.basis.get(parent_idx) + * label = self.xlabels[variable_choice] + * if knot_idx_choice != -1: # <<<<<<<<<<<<<< + * # Add the new basis functions + * bf1 = HingeBasisFunction( + */ + __pyx_t_34 = ((__pyx_v_knot_idx_choice != -1) != 0); + if (__pyx_t_34) { + + /* "sklearn/earth/_forward.pyx":364 + * # Add the new basis functions + * bf1 = HingeBasisFunction( + * parent_choice, knot_choice, knot_idx_choice, variable_choice, False, label) # <<<<<<<<<<<<<< + * bf2 = HingeBasisFunction( + * parent_choice, knot_choice, knot_idx_choice, variable_choice, True, label) + */ + if (unlikely(!__pyx_v_parent_choice)) { __Pyx_RaiseUnboundLocalError("parent_choice"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_30 = PyFloat_FromDouble(__pyx_v_knot_choice); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_1 = PyInt_FromLong(__pyx_v_knot_idx_choice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable_choice); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_15 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_36 = PyTuple_New(6); if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_36); + __Pyx_INCREF(((PyObject *)__pyx_v_parent_choice)); + PyTuple_SET_ITEM(__pyx_t_36, 0, ((PyObject *)__pyx_v_parent_choice)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_choice)); + PyTuple_SET_ITEM(__pyx_t_36, 1, __pyx_t_30); + __Pyx_GIVEREF(__pyx_t_30); + PyTuple_SET_ITEM(__pyx_t_36, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_36, 3, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_36, 4, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + __Pyx_INCREF(__pyx_v_label); + PyTuple_SET_ITEM(__pyx_t_36, 5, __pyx_v_label); + __Pyx_GIVEREF(__pyx_v_label); + __pyx_t_30 = 0; + __pyx_t_1 = 0; + __pyx_t_11 = 0; + __pyx_t_15 = 0; + __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction)), ((PyObject *)__pyx_t_36), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_36)); __pyx_t_36 = 0; + __pyx_v_bf1 = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_15); + __pyx_t_15 = 0; + + /* "sklearn/earth/_forward.pyx":366 + * parent_choice, knot_choice, knot_idx_choice, variable_choice, False, label) + * bf2 = HingeBasisFunction( + * parent_choice, knot_choice, knot_idx_choice, variable_choice, True, label) # <<<<<<<<<<<<<< + * bf1.apply(X, B[:, k]) + * apply_weights_slice(B, sample_weight, k) + */ + __pyx_t_15 = PyFloat_FromDouble(__pyx_v_knot_choice); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_36 = PyInt_FromLong(__pyx_v_knot_idx_choice); if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_36); + __pyx_t_11 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable_choice); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_30 = PyTuple_New(6); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_INCREF(((PyObject *)__pyx_v_parent_choice)); + PyTuple_SET_ITEM(__pyx_t_30, 0, ((PyObject *)__pyx_v_parent_choice)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_choice)); + PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + PyTuple_SET_ITEM(__pyx_t_30, 2, __pyx_t_36); + __Pyx_GIVEREF(__pyx_t_36); + PyTuple_SET_ITEM(__pyx_t_30, 3, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_30, 4, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_label); + PyTuple_SET_ITEM(__pyx_t_30, 5, __pyx_v_label); + __Pyx_GIVEREF(__pyx_v_label); + __pyx_t_15 = 0; + __pyx_t_36 = 0; + __pyx_t_11 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction)), ((PyObject *)__pyx_t_30), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0; + __pyx_v_bf2 = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":367 + * bf2 = HingeBasisFunction( + * parent_choice, knot_choice, knot_idx_choice, variable_choice, True, label) + * bf1.apply(X, B[:, k]) # <<<<<<<<<<<<<< + * apply_weights_slice(B, sample_weight, k) + * bf2.apply(X, B[:, k + 1]) + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_30 = PyTuple_New(2); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_INCREF(__pyx_k_slice_14); + PyTuple_SET_ITEM(__pyx_t_30, 0, __pyx_k_slice_14); + __Pyx_GIVEREF(__pyx_k_slice_14); + PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_30)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_30 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf1->__pyx_vtab)->apply(__pyx_v_bf1, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_t_1), 0, NULL); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":368 + * parent_choice, knot_choice, knot_idx_choice, variable_choice, True, label) + * bf1.apply(X, B[:, k]) + * apply_weights_slice(B, sample_weight, k) # <<<<<<<<<<<<<< + * bf2.apply(X, B[:, k + 1]) + * apply_weights_slice(B, sample_weight, k + 1) + */ + __pyx_t_30 = __pyx_f_7sklearn_5earth_5_util_apply_weights_slice(((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_sample_weight), __pyx_v_k, 0); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":369 + * bf1.apply(X, B[:, k]) + * apply_weights_slice(B, sample_weight, k) + * bf2.apply(X, B[:, k + 1]) # <<<<<<<<<<<<<< + * apply_weights_slice(B, sample_weight, k + 1) + * self.basis.append(bf1) + */ + __pyx_t_30 = __Pyx_PyInt_to_py_npy_ulonglong((__pyx_v_k + 1)); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_k_slice_15); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_k_slice_15); + __Pyx_GIVEREF(__pyx_k_slice_15); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_30); + __Pyx_GIVEREF(__pyx_t_30); + __pyx_t_30 = 0; + __pyx_t_30 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_1)); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_30) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_30, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf2->__pyx_vtab)->apply(__pyx_v_bf2, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_t_30), 0, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":370 + * apply_weights_slice(B, sample_weight, k) + * bf2.apply(X, B[:, k + 1]) + * apply_weights_slice(B, sample_weight, k + 1) # <<<<<<<<<<<<<< + * self.basis.append(bf1) + * self.basis.append(bf2) + */ + __pyx_t_1 = __pyx_f_7sklearn_5earth_5_util_apply_weights_slice(((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_sample_weight), (__pyx_v_k + 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":371 + * bf2.apply(X, B[:, k + 1]) + * apply_weights_slice(B, sample_weight, k + 1) + * self.basis.append(bf1) # <<<<<<<<<<<<<< + * self.basis.append(bf2) + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->append(__pyx_v_self->basis, __pyx_v_bf1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":372 + * apply_weights_slice(B, sample_weight, k + 1) + * self.basis.append(bf1) + * self.basis.append(bf2) # <<<<<<<<<<<<<< + * + * # Orthogonalize the new basis + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->append(__pyx_v_self->basis, __pyx_v_bf2, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":375 + * + * # Orthogonalize the new basis + * B_orth[:, k] = B[:, k] # <<<<<<<<<<<<<< + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_30 = PyTuple_New(2); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_INCREF(__pyx_k_slice_16); + PyTuple_SET_ITEM(__pyx_t_30, 0, __pyx_k_slice_16); + __Pyx_GIVEREF(__pyx_k_slice_16); + PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_30)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0; + __pyx_t_30 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_INCREF(__pyx_k_slice_17); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_k_slice_17); + __Pyx_GIVEREF(__pyx_k_slice_17); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_30); + __Pyx_GIVEREF(__pyx_t_30); + __pyx_t_30 = 0; + if (PyObject_SetItem(((PyObject *)__pyx_v_B_orth), ((PyObject *)__pyx_t_11), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":376 + * # Orthogonalize the new basis + * B_orth[:, k] = B[:, k] + * if self.orthonormal_update(k) == 1: # <<<<<<<<<<<<<< + * bf1.make_unsplittable() + * B_orth[:, k + 1] = B[:, k + 1] + */ + __pyx_t_34 = ((((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_update(__pyx_v_self, __pyx_v_k, 0) == 1) != 0); + if (__pyx_t_34) { + + /* "sklearn/earth/_forward.pyx":377 + * B_orth[:, k] = B[:, k] + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() # <<<<<<<<<<<<<< + * B_orth[:, k + 1] = B[:, k + 1] + * if self.orthonormal_update(k + 1) == 1: + */ + ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf1->__pyx_vtab)->make_unsplittable(__pyx_v_bf1, 0); + goto __pyx_L22; + } + __pyx_L22:; + + /* "sklearn/earth/_forward.pyx":378 + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() + * B_orth[:, k + 1] = B[:, k + 1] # <<<<<<<<<<<<<< + * if self.orthonormal_update(k + 1) == 1: + * bf2.make_unsplittable() + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong((__pyx_v_k + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_INCREF(__pyx_k_slice_18); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_k_slice_18); + __Pyx_GIVEREF(__pyx_k_slice_18); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_11)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyInt_to_py_npy_ulonglong((__pyx_v_k + 1)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_30 = PyTuple_New(2); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_INCREF(__pyx_k_slice_19); + PyTuple_SET_ITEM(__pyx_t_30, 0, __pyx_k_slice_19); + __Pyx_GIVEREF(__pyx_k_slice_19); + PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_11 = 0; + if (PyObject_SetItem(((PyObject *)__pyx_v_B_orth), ((PyObject *)__pyx_t_30), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":379 + * bf1.make_unsplittable() + * B_orth[:, k + 1] = B[:, k + 1] + * if self.orthonormal_update(k + 1) == 1: # <<<<<<<<<<<<<< + * bf2.make_unsplittable() + * elif not dependent and knot_idx_choice == -1: + */ + __pyx_t_34 = ((((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_update(__pyx_v_self, (__pyx_v_k + 1), 0) == 1) != 0); + if (__pyx_t_34) { + + /* "sklearn/earth/_forward.pyx":380 + * B_orth[:, k + 1] = B[:, k + 1] + * if self.orthonormal_update(k + 1) == 1: + * bf2.make_unsplittable() # <<<<<<<<<<<<<< + * elif not dependent and knot_idx_choice == -1: + * # In this case, only add the linear basis function + */ + ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf2->__pyx_vtab)->make_unsplittable(__pyx_v_bf2, 0); + goto __pyx_L23; + } + __pyx_L23:; + goto __pyx_L21; + } + + /* "sklearn/earth/_forward.pyx":381 + * if self.orthonormal_update(k + 1) == 1: + * bf2.make_unsplittable() + * elif not dependent and knot_idx_choice == -1: # <<<<<<<<<<<<<< + * # In this case, only add the linear basis function + * bf1 = LinearBasisFunction(parent_choice, variable_choice, label) + */ + __pyx_t_34 = ((!(__pyx_v_dependent != 0)) != 0); + if (__pyx_t_34) { + __pyx_t_10 = ((__pyx_v_knot_idx_choice == -1) != 0); + __pyx_t_37 = __pyx_t_10; + } else { + __pyx_t_37 = __pyx_t_34; + } + if (__pyx_t_37) { + + /* "sklearn/earth/_forward.pyx":383 + * elif not dependent and knot_idx_choice == -1: + * # In this case, only add the linear basis function + * bf1 = LinearBasisFunction(parent_choice, variable_choice, label) # <<<<<<<<<<<<<< + * bf1.apply(X, B[:, k]) + * apply_weights_slice(B, sample_weight, k) + */ + if (unlikely(!__pyx_v_parent_choice)) { __Pyx_RaiseUnboundLocalError("parent_choice"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable_choice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_30 = PyTuple_New(3); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_INCREF(((PyObject *)__pyx_v_parent_choice)); + PyTuple_SET_ITEM(__pyx_t_30, 0, ((PyObject *)__pyx_v_parent_choice)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_choice)); + PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_label); + PyTuple_SET_ITEM(__pyx_t_30, 2, __pyx_v_label); + __Pyx_GIVEREF(__pyx_v_label); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction)), ((PyObject *)__pyx_t_30), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0; + __pyx_v_bf1 = ((struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":384 + * # In this case, only add the linear basis function + * bf1 = LinearBasisFunction(parent_choice, variable_choice, label) + * bf1.apply(X, B[:, k]) # <<<<<<<<<<<<<< + * apply_weights_slice(B, sample_weight, k) + * self.basis.append(bf1) + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_30 = PyTuple_New(2); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_INCREF(__pyx_k_slice_20); + PyTuple_SET_ITEM(__pyx_t_30, 0, __pyx_k_slice_20); + __Pyx_GIVEREF(__pyx_k_slice_20); + PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_30)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_30 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf1->__pyx_vtab)->apply(__pyx_v_bf1, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_t_1), 0, NULL); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":385 + * bf1 = LinearBasisFunction(parent_choice, variable_choice, label) + * bf1.apply(X, B[:, k]) + * apply_weights_slice(B, sample_weight, k) # <<<<<<<<<<<<<< + * self.basis.append(bf1) + * + */ + __pyx_t_30 = __pyx_f_7sklearn_5earth_5_util_apply_weights_slice(((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_sample_weight), __pyx_v_k, 0); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":386 + * bf1.apply(X, B[:, k]) + * apply_weights_slice(B, sample_weight, k) + * self.basis.append(bf1) # <<<<<<<<<<<<<< + * + * # Orthogonalize the new basis + */ + __pyx_t_30 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->append(__pyx_v_self->basis, __pyx_v_bf1, 0); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":389 + * + * # Orthogonalize the new basis + * B_orth[:, k] = B[:, k] # <<<<<<<<<<<<<< + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() + */ + __pyx_t_30 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_k_slice_21); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_k_slice_21); + __Pyx_GIVEREF(__pyx_k_slice_21); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_30); + __Pyx_GIVEREF(__pyx_t_30); + __pyx_t_30 = 0; + __pyx_t_30 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_1)); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_INCREF(__pyx_k_slice_22); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_k_slice_22); + __Pyx_GIVEREF(__pyx_k_slice_22); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + if (PyObject_SetItem(((PyObject *)__pyx_v_B_orth), ((PyObject *)__pyx_t_11), __pyx_t_30) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":390 + * # Orthogonalize the new basis + * B_orth[:, k] = B[:, k] + * if self.orthonormal_update(k) == 1: # <<<<<<<<<<<<<< + * bf1.make_unsplittable() + * else: # dependent and knot_idx_choice == -1 + */ + __pyx_t_37 = ((((struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *)__pyx_v_self->__pyx_vtab)->orthonormal_update(__pyx_v_self, __pyx_v_k, 0) == 1) != 0); + if (__pyx_t_37) { + + /* "sklearn/earth/_forward.pyx":391 + * B_orth[:, k] = B[:, k] + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() # <<<<<<<<<<<<<< + * else: # dependent and knot_idx_choice == -1 + * # In this case there were no acceptable choices remaining, so end + */ + ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *)__pyx_v_bf1->__pyx_vtab)->make_unsplittable(__pyx_v_bf1, 0); + goto __pyx_L24; + } + __pyx_L24:; + goto __pyx_L21; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":395 + * # In this case there were no acceptable choices remaining, so end + * # the forward pass + * self.record[len(self.record) - 1].set_no_candidates(True) # <<<<<<<<<<<<<< + * return + * + */ + __pyx_t_30 = ((PyObject *)__pyx_v_self->record); + __Pyx_INCREF(__pyx_t_30); + __pyx_t_35 = PyObject_Length(__pyx_t_30); if (unlikely(__pyx_t_35 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + __pyx_t_2 = (__pyx_t_35 - 1); + __pyx_t_30 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->record), __pyx_t_2, sizeof(Py_ssize_t), PyInt_FromSsize_t, 0, 0, 0); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_n_s__set_no_candidates); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + __pyx_t_30 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_30); + __Pyx_GIVEREF(__pyx_t_30); + __pyx_t_30 = 0; + __pyx_t_30 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; + + /* "sklearn/earth/_forward.pyx":396 + * # the forward pass + * self.record[len(self.record) - 1].set_no_candidates(True) + * return # <<<<<<<<<<<<<< + * + * # Update the build record + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + } + __pyx_L21:; + + /* "sklearn/earth/_forward.pyx":400 + * # Update the build record + * self.record.append(ForwardPassIteration( + * parent_idx_choice, variable_choice, knot_idx_choice, mse_choice, len(self.basis))) # <<<<<<<<<<<<<< + * + * cdef best_knot(ForwardPasser self, INDEX_t parent, INDEX_t variable, INDEX_t k, cnp.ndarray[INT_t, ndim=1] candidates, cnp.ndarray[INT_t, ndim=1] order, FLOAT_t * mse, FLOAT_t * knot, INDEX_t * knot_idx): + */ + __pyx_t_30 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_parent_idx_choice); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_30); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_variable_choice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyInt_FromLong(__pyx_v_knot_idx_choice); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_36 = PyFloat_FromDouble(__pyx_v_mse_choice); if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_36); + __pyx_t_15 = ((PyObject *)__pyx_v_self->basis); + __Pyx_INCREF(__pyx_t_15); + __pyx_t_2 = PyObject_Length(__pyx_t_15); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_38 = PyTuple_New(5); if (unlikely(!__pyx_t_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_38); + PyTuple_SET_ITEM(__pyx_t_38, 0, __pyx_t_30); + __Pyx_GIVEREF(__pyx_t_30); + PyTuple_SET_ITEM(__pyx_t_38, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_38, 2, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_38, 3, __pyx_t_36); + __Pyx_GIVEREF(__pyx_t_36); + PyTuple_SET_ITEM(__pyx_t_38, 4, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_t_30 = 0; + __pyx_t_1 = 0; + __pyx_t_11 = 0; + __pyx_t_36 = 0; + __pyx_t_15 = 0; + __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration)), ((PyObject *)__pyx_t_38), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_38)); __pyx_t_38 = 0; + __pyx_t_38 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->__pyx_base.append(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self->record), ((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_t_15), 0); if (unlikely(!__pyx_t_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_38); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_30); + __Pyx_XDECREF(__pyx_t_36); + __Pyx_XDECREF(__pyx_t_38); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_candidates_idx.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_linear_variables.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sample_weight.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorting.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.next_pair", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_candidates_idx.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_linear_variables.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sample_weight.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorting.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_parent); + __Pyx_XDECREF((PyObject *)__pyx_v_candidates_idx); + __Pyx_XDECREF((PyObject *)__pyx_v_parent_choice); + __Pyx_XDECREF((PyObject *)__pyx_v_bf1); + __Pyx_XDECREF((PyObject *)__pyx_v_bf2); + __Pyx_XDECREF((PyObject *)__pyx_v_X); + __Pyx_XDECREF((PyObject *)__pyx_v_B); + __Pyx_XDECREF((PyObject *)__pyx_v_B_orth); + __Pyx_XDECREF((PyObject *)__pyx_v_y); + __Pyx_XDECREF((PyObject *)__pyx_v_linear_variables); + __Pyx_XDECREF((PyObject *)__pyx_v_sorting); + __Pyx_XDECREF((PyObject *)__pyx_v_sample_weight); + __Pyx_XDECREF(__pyx_v_label); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_forward.pyx":402 + * parent_idx_choice, variable_choice, knot_idx_choice, mse_choice, len(self.basis))) + * + * cdef best_knot(ForwardPasser self, INDEX_t parent, INDEX_t variable, INDEX_t k, cnp.ndarray[INT_t, ndim=1] candidates, cnp.ndarray[INT_t, ndim=1] order, FLOAT_t * mse, FLOAT_t * knot, INDEX_t * knot_idx): # <<<<<<<<<<<<<< + * ''' + * Find the best knot location (in terms of squared error). + */ + +static PyObject *__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_best_knot(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *__pyx_v_self, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_parent, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_variable, __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_k, PyArrayObject *__pyx_v_candidates, PyArrayObject *__pyx_v_order, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *__pyx_v_mse, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *__pyx_v_knot, __pyx_t_7sklearn_5earth_8_forward_INDEX_t *__pyx_v_knot_idx) { + PyArrayObject *__pyx_v_b = 0; + PyArrayObject *__pyx_v_b_parent = 0; + PyArrayObject *__pyx_v_u = 0; + PyArrayObject *__pyx_v_B_orth = 0; + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_y = 0; + PyArrayObject *__pyx_v_c = 0; + PyArrayObject *__pyx_v_B_orth_times_parent_cum = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_B = 0; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_num_candidates; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_h; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_j; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_i_; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_j_; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_u_end; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_c_end; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_z_end_squared; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_candidate_idx; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_last_candidate_idx; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_last_last_candidate_idx; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_v_best_candidate_idx; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_candidate; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_last_candidate; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_best_candidate; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_best_z_end_squared; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_y_cum; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_b_times_parent_cum; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_diff; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_delta_b_squared; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_delta_c_end; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_delta_u_end; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_parent_squared_cum; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_parent_times_y_cum; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_u_dot_c; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_u_dot_u; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_float_tmp; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_delta_b_j; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_v_z_denom; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B_orth; + __Pyx_Buffer __pyx_pybuffer_B_orth; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B_orth_times_parent_cum; + __Pyx_Buffer __pyx_pybuffer_B_orth_times_parent_cum; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b; + __Pyx_Buffer __pyx_pybuffer_b; + __Pyx_LocalBuf_ND __pyx_pybuffernd_b_parent; + __Pyx_Buffer __pyx_pybuffer_b_parent; + __Pyx_LocalBuf_ND __pyx_pybuffernd_c; + __Pyx_Buffer __pyx_pybuffer_c; + __Pyx_LocalBuf_ND __pyx_pybuffernd_candidates; + __Pyx_Buffer __pyx_pybuffer_candidates; + __Pyx_LocalBuf_ND __pyx_pybuffernd_order; + __Pyx_Buffer __pyx_pybuffer_order; + __Pyx_LocalBuf_ND __pyx_pybuffernd_u; + __Pyx_Buffer __pyx_pybuffer_u; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyArrayObject *__pyx_t_3 = NULL; + PyArrayObject *__pyx_t_4 = NULL; + PyArrayObject *__pyx_t_5 = NULL; + PyArrayObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + PyArrayObject *__pyx_t_8 = NULL; + PyArrayObject *__pyx_t_9 = NULL; + long __pyx_t_10; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_11; + __pyx_t_7sklearn_5earth_8_forward_INT_t __pyx_t_12; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_13; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_14; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_15; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_16; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_17; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_18; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_19; + int __pyx_t_20; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_21; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_22; + PyObject *__pyx_t_23 = NULL; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_24; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_25; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_26; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_27; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_28; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_29; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_30; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_31; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t __pyx_t_32; + long __pyx_t_33; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_34; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_35; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_36; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_37; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_38; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_39; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_40; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_41; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_42; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_43; + __pyx_t_7sklearn_5earth_8_forward_INT_t __pyx_t_44; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_45; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_46; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_47; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_48; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_49; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_50; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_51; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_52; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_53; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_54; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_55; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_56; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_57; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_58; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_59; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_60; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_61; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_62; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_63; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_64; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_65; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_66; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_67; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_68; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_69; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_70; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_71; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_72; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_73; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_74; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t __pyx_t_75; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("best_knot", 0); + __pyx_pybuffer_b.pybuffer.buf = NULL; + __pyx_pybuffer_b.refcount = 0; + __pyx_pybuffernd_b.data = NULL; + __pyx_pybuffernd_b.rcbuffer = &__pyx_pybuffer_b; + __pyx_pybuffer_b_parent.pybuffer.buf = NULL; + __pyx_pybuffer_b_parent.refcount = 0; + __pyx_pybuffernd_b_parent.data = NULL; + __pyx_pybuffernd_b_parent.rcbuffer = &__pyx_pybuffer_b_parent; + __pyx_pybuffer_u.pybuffer.buf = NULL; + __pyx_pybuffer_u.refcount = 0; + __pyx_pybuffernd_u.data = NULL; + __pyx_pybuffernd_u.rcbuffer = &__pyx_pybuffer_u; + __pyx_pybuffer_B_orth.pybuffer.buf = NULL; + __pyx_pybuffer_B_orth.refcount = 0; + __pyx_pybuffernd_B_orth.data = NULL; + __pyx_pybuffernd_B_orth.rcbuffer = &__pyx_pybuffer_B_orth; + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_c.pybuffer.buf = NULL; + __pyx_pybuffer_c.refcount = 0; + __pyx_pybuffernd_c.data = NULL; + __pyx_pybuffernd_c.rcbuffer = &__pyx_pybuffer_c; + __pyx_pybuffer_B_orth_times_parent_cum.pybuffer.buf = NULL; + __pyx_pybuffer_B_orth_times_parent_cum.refcount = 0; + __pyx_pybuffernd_B_orth_times_parent_cum.data = NULL; + __pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer = &__pyx_pybuffer_B_orth_times_parent_cum; + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_candidates.pybuffer.buf = NULL; + __pyx_pybuffer_candidates.refcount = 0; + __pyx_pybuffernd_candidates.data = NULL; + __pyx_pybuffernd_candidates.rcbuffer = &__pyx_pybuffer_candidates; + __pyx_pybuffer_order.pybuffer.buf = NULL; + __pyx_pybuffer_order.refcount = 0; + __pyx_pybuffernd_order.data = NULL; + __pyx_pybuffernd_order.rcbuffer = &__pyx_pybuffer_order; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_candidates.rcbuffer->pybuffer, (PyObject*)__pyx_v_candidates, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_candidates.diminfo[0].strides = __pyx_pybuffernd_candidates.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_candidates.diminfo[0].shape = __pyx_pybuffernd_candidates.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_v_order, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_order.diminfo[0].strides = __pyx_pybuffernd_order.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_order.diminfo[0].shape = __pyx_pybuffernd_order.rcbuffer->pybuffer.shape[0]; + + /* "sklearn/earth/_forward.pyx":413 + * ''' + * + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b = self.B[:, k + 1] # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b_parent = self.B[:, parent] + * cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong((__pyx_v_k + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_k_slice_23); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_k_slice_23); + __Pyx_GIVEREF(__pyx_k_slice_23); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->B), ((PyObject *)__pyx_t_2)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = __pyx_t_1; + __Pyx_INCREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_2), &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_b = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_b.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_b.diminfo[0].strides = __pyx_pybuffernd_b.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b.diminfo[0].shape = __pyx_pybuffernd_b.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_v_b = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":414 + * + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b = self.B[:, k + 1] + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b_parent = self.B[:, parent] # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + */ + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_parent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_k_slice_24); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_k_slice_24); + __Pyx_GIVEREF(__pyx_k_slice_24); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->B), ((PyObject *)__pyx_t_1)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __pyx_t_2; + __Pyx_INCREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_b_parent.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_b_parent = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_b_parent.diminfo[0].strides = __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_b_parent.diminfo[0].shape = __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_v_b_parent = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":415 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b = self.B[:, k + 1] + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b_parent = self.B[:, parent] + * cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + */ + __pyx_t_3 = ((PyArrayObject *)__pyx_v_self->u); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_u.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_u = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_u.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_u.diminfo[0].strides = __pyx_pybuffernd_u.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_u.diminfo[0].shape = __pyx_pybuffernd_u.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_3 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->u))); + __pyx_v_u = ((PyArrayObject *)__pyx_v_self->u); + + /* "sklearn/earth/_forward.pyx":416 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b_parent = self.B[:, parent] + * cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + */ + __pyx_t_4 = ((PyArrayObject *)__pyx_v_self->B_orth); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_B_orth = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B_orth.diminfo[0].strides = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B_orth.diminfo[0].shape = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B_orth.diminfo[1].strides = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B_orth.diminfo[1].shape = __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_4 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B_orth))); + __pyx_v_B_orth = ((PyArrayObject *)__pyx_v_self->B_orth); + + /* "sklearn/earth/_forward.pyx":417 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + */ + __pyx_t_5 = ((PyArrayObject *)__pyx_v_self->X); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_X.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->X))); + __pyx_v_X = ((PyArrayObject *)__pyx_v_self->X); + + /* "sklearn/earth/_forward.pyx":418 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + * cdef cnp.ndarray[FLOAT_t, ndim = 1] B_orth_times_parent_cum = self.B_orth_times_parent_cum + */ + __pyx_t_6 = ((PyArrayObject *)__pyx_v_self->y); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_y = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_6 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->y))); + __pyx_v_y = ((PyArrayObject *)__pyx_v_self->y); + + /* "sklearn/earth/_forward.pyx":419 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] B_orth_times_parent_cum = self.B_orth_times_parent_cum + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + */ + __pyx_t_7 = ((PyArrayObject *)__pyx_v_self->c); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_c.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_c = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_c.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_c.diminfo[0].strides = __pyx_pybuffernd_c.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_c.diminfo[0].shape = __pyx_pybuffernd_c.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_7 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->c))); + __pyx_v_c = ((PyArrayObject *)__pyx_v_self->c); + + /* "sklearn/earth/_forward.pyx":420 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + * cdef cnp.ndarray[FLOAT_t, ndim = 1] B_orth_times_parent_cum = self.B_orth_times_parent_cum # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * + */ + __pyx_t_8 = ((PyArrayObject *)__pyx_v_self->B_orth_times_parent_cum); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_B_orth_times_parent_cum = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B_orth_times_parent_cum.diminfo[0].strides = __pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B_orth_times_parent_cum.diminfo[0].shape = __pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_8 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B_orth_times_parent_cum))); + __pyx_v_B_orth_times_parent_cum = ((PyArrayObject *)__pyx_v_self->B_orth_times_parent_cum); + + /* "sklearn/earth/_forward.pyx":421 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + * cdef cnp.ndarray[FLOAT_t, ndim = 1] B_orth_times_parent_cum = self.B_orth_times_parent_cum + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B # <<<<<<<<<<<<<< + * + * cdef INDEX_t num_candidates = candidates.shape[0] + */ + __pyx_t_9 = ((PyArrayObject *)__pyx_v_self->B); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_forward_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_B = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_9 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B))); + __pyx_v_B = ((PyArrayObject *)__pyx_v_self->B); + + /* "sklearn/earth/_forward.pyx":423 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * + * cdef INDEX_t num_candidates = candidates.shape[0] # <<<<<<<<<<<<<< + * + * cdef INDEX_t h + */ + __pyx_v_num_candidates = (__pyx_v_candidates->dimensions[0]); + + /* "sklearn/earth/_forward.pyx":457 + * + * # Compute the initial basis function + * candidate_idx = candidates[0] # <<<<<<<<<<<<<< + * candidate = X[order[candidate_idx], variable] + * for i in range(self.m): # TODO: Vectorize? + */ + __pyx_t_10 = 0; + __pyx_v_candidate_idx = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_candidates.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_candidates.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":458 + * # Compute the initial basis function + * candidate_idx = candidates[0] + * candidate = X[order[candidate_idx], variable] # <<<<<<<<<<<<<< + * for i in range(self.m): # TODO: Vectorize? + * b[i] = 0 + */ + __pyx_t_11 = __pyx_v_candidate_idx; + __pyx_t_12 = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_order.diminfo[0].strides)); + __pyx_t_13 = __pyx_v_variable; + __pyx_v_candidate = (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_X.diminfo[1].strides)); + + /* "sklearn/earth/_forward.pyx":459 + * candidate_idx = candidates[0] + * candidate = X[order[candidate_idx], variable] + * for i in range(self.m): # TODO: Vectorize? # <<<<<<<<<<<<<< + * b[i] = 0 + * for i_ in range(self.m): + */ + __pyx_t_14 = __pyx_v_self->m; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_i = __pyx_t_15; + + /* "sklearn/earth/_forward.pyx":460 + * candidate = X[order[candidate_idx], variable] + * for i in range(self.m): # TODO: Vectorize? + * b[i] = 0 # <<<<<<<<<<<<<< + * for i_ in range(self.m): + * i = order[i_] + */ + __pyx_t_16 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_b.diminfo[0].strides) = 0.0; + } + + /* "sklearn/earth/_forward.pyx":461 + * for i in range(self.m): # TODO: Vectorize? + * b[i] = 0 + * for i_ in range(self.m): # <<<<<<<<<<<<<< + * i = order[i_] + * float_tmp = X[i, variable] - candidate + */ + __pyx_t_14 = __pyx_v_self->m; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_i_ = __pyx_t_15; + + /* "sklearn/earth/_forward.pyx":462 + * b[i] = 0 + * for i_ in range(self.m): + * i = order[i_] # <<<<<<<<<<<<<< + * float_tmp = X[i, variable] - candidate + * if float_tmp > 0: + */ + __pyx_t_17 = __pyx_v_i_; + __pyx_v_i = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_order.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":463 + * for i_ in range(self.m): + * i = order[i_] + * float_tmp = X[i, variable] - candidate # <<<<<<<<<<<<<< + * if float_tmp > 0: + * b[i] = b_parent[i] * float_tmp + */ + __pyx_t_18 = __pyx_v_i; + __pyx_t_19 = __pyx_v_variable; + __pyx_v_float_tmp = ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_X.diminfo[1].strides)) - __pyx_v_candidate); + + /* "sklearn/earth/_forward.pyx":464 + * i = order[i_] + * float_tmp = X[i, variable] - candidate + * if float_tmp > 0: # <<<<<<<<<<<<<< + * b[i] = b_parent[i] * float_tmp + * else: + */ + __pyx_t_20 = ((__pyx_v_float_tmp > 0.0) != 0); + if (__pyx_t_20) { + + /* "sklearn/earth/_forward.pyx":465 + * float_tmp = X[i, variable] - candidate + * if float_tmp > 0: + * b[i] = b_parent[i] * float_tmp # <<<<<<<<<<<<<< + * else: + * break + */ + __pyx_t_21 = __pyx_v_i; + __pyx_t_22 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_b.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_b_parent.diminfo[0].strides)) * __pyx_v_float_tmp); + goto __pyx_L7; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":467 + * b[i] = b_parent[i] * float_tmp + * else: + * break # <<<<<<<<<<<<<< + * + * # Compute the initial covariance column, u (not including the final + */ + goto __pyx_L6_break; + } + __pyx_L7:; + } + __pyx_L6_break:; + + /* "sklearn/earth/_forward.pyx":471 + * # Compute the initial covariance column, u (not including the final + * # element) + * u[0:k + 1] = np.dot(b, B_orth[:, 0:k + 1]) # <<<<<<<<<<<<<< + * + * # Compute the new last elements of c and u + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__dot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong((__pyx_v_k + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_23 = PySlice_New(__pyx_int_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_23); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_k_slice_25); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_k_slice_25); + __Pyx_GIVEREF(__pyx_k_slice_25); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_23); + __Pyx_GIVEREF(__pyx_t_23); + __pyx_t_23 = 0; + __pyx_t_23 = PyObject_GetItem(((PyObject *)__pyx_v_B_orth), ((PyObject *)__pyx_t_1)); if (!__pyx_t_23) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_23); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_b)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_b)); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_23); + __Pyx_GIVEREF(__pyx_t_23); + __pyx_t_23 = 0; + __pyx_t_23 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_23); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (__Pyx_PyObject_SetSlice(((PyObject *)__pyx_v_u), __pyx_t_23, 0, (__pyx_v_k + 1), NULL, NULL, NULL, 1, 1, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0; + + /* "sklearn/earth/_forward.pyx":474 + * + * # Compute the new last elements of c and u + * c_end = 0.0 # <<<<<<<<<<<<<< + * u_end = 0.0 + * for i in range(self.m): + */ + __pyx_v_c_end = 0.0; + + /* "sklearn/earth/_forward.pyx":475 + * # Compute the new last elements of c and u + * c_end = 0.0 + * u_end = 0.0 # <<<<<<<<<<<<<< + * for i in range(self.m): + * u_end += b[i] * b[i] + */ + __pyx_v_u_end = 0.0; + + /* "sklearn/earth/_forward.pyx":476 + * c_end = 0.0 + * u_end = 0.0 + * for i in range(self.m): # <<<<<<<<<<<<<< + * u_end += b[i] * b[i] + * c_end += b[i] * y[i] + */ + __pyx_t_14 = __pyx_v_self->m; + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_i = __pyx_t_15; + + /* "sklearn/earth/_forward.pyx":477 + * u_end = 0.0 + * for i in range(self.m): + * u_end += b[i] * b[i] # <<<<<<<<<<<<<< + * c_end += b[i] * y[i] + * + */ + __pyx_t_24 = __pyx_v_i; + __pyx_t_25 = __pyx_v_i; + __pyx_v_u_end = (__pyx_v_u_end + ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_b.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_b.diminfo[0].strides)))); + + /* "sklearn/earth/_forward.pyx":478 + * for i in range(self.m): + * u_end += b[i] * b[i] + * c_end += b[i] * y[i] # <<<<<<<<<<<<<< + * + * # Compute the last element of z (the others are identical to c) + */ + __pyx_t_26 = __pyx_v_i; + __pyx_t_27 = __pyx_v_i; + __pyx_v_c_end = (__pyx_v_c_end + ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_b.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_y.diminfo[0].strides)))); + } + + /* "sklearn/earth/_forward.pyx":481 + * + * # Compute the last element of z (the others are identical to c) + * u_dot_c = 0.0 # <<<<<<<<<<<<<< + * u_dot_u = 0.0 + * for i in range(k + 1): + */ + __pyx_v_u_dot_c = 0.0; + + /* "sklearn/earth/_forward.pyx":482 + * # Compute the last element of z (the others are identical to c) + * u_dot_c = 0.0 + * u_dot_u = 0.0 # <<<<<<<<<<<<<< + * for i in range(k + 1): + * u_dot_u += u[i] * u[i] + */ + __pyx_v_u_dot_u = 0.0; + + /* "sklearn/earth/_forward.pyx":483 + * u_dot_c = 0.0 + * u_dot_u = 0.0 + * for i in range(k + 1): # <<<<<<<<<<<<<< + * u_dot_u += u[i] * u[i] + * u_dot_c += u[i] * c[i] + */ + __pyx_t_14 = (__pyx_v_k + 1); + for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { + __pyx_v_i = __pyx_t_15; + + /* "sklearn/earth/_forward.pyx":484 + * u_dot_u = 0.0 + * for i in range(k + 1): + * u_dot_u += u[i] * u[i] # <<<<<<<<<<<<<< + * u_dot_c += u[i] * c[i] + * z_denom = u_end - u_dot_u + */ + __pyx_t_28 = __pyx_v_i; + __pyx_t_29 = __pyx_v_i; + __pyx_v_u_dot_u = (__pyx_v_u_dot_u + ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_u.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_u.diminfo[0].strides)))); + + /* "sklearn/earth/_forward.pyx":485 + * for i in range(k + 1): + * u_dot_u += u[i] * u[i] + * u_dot_c += u[i] * c[i] # <<<<<<<<<<<<<< + * z_denom = u_end - u_dot_u + * if z_denom <= self.zero_tol: + */ + __pyx_t_30 = __pyx_v_i; + __pyx_t_31 = __pyx_v_i; + __pyx_v_u_dot_c = (__pyx_v_u_dot_c + ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_u.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_c.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_c.diminfo[0].strides)))); + } + + /* "sklearn/earth/_forward.pyx":486 + * u_dot_u += u[i] * u[i] + * u_dot_c += u[i] * c[i] + * z_denom = u_end - u_dot_u # <<<<<<<<<<<<<< + * if z_denom <= self.zero_tol: + * z_end_squared = np.nan + */ + __pyx_v_z_denom = (__pyx_v_u_end - __pyx_v_u_dot_u); + + /* "sklearn/earth/_forward.pyx":487 + * u_dot_c += u[i] * c[i] + * z_denom = u_end - u_dot_u + * if z_denom <= self.zero_tol: # <<<<<<<<<<<<<< + * z_end_squared = np.nan + * else: + */ + __pyx_t_20 = ((__pyx_v_z_denom <= __pyx_v_self->zero_tol) != 0); + if (__pyx_t_20) { + + /* "sklearn/earth/_forward.pyx":488 + * z_denom = u_end - u_dot_u + * if z_denom <= self.zero_tol: + * z_end_squared = np.nan # <<<<<<<<<<<<<< + * else: + * z_end_squared = ((c_end - u_dot_c) ** 2) / z_denom + */ + __pyx_t_23 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_23); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_n_s__nan); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0; + __pyx_t_32 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_32 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_z_end_squared = __pyx_t_32; + goto __pyx_L12; + } + /*else*/ { + + /* "sklearn/earth/_forward.pyx":490 + * z_end_squared = np.nan + * else: + * z_end_squared = ((c_end - u_dot_c) ** 2) / z_denom # <<<<<<<<<<<<<< + * + * # Minimizing the norm is actually equivalent to maximizing z_end_squared + */ + __pyx_v_z_end_squared = (pow((__pyx_v_c_end - __pyx_v_u_dot_c), 2.0) / __pyx_v_z_denom); + } + __pyx_L12:; + + /* "sklearn/earth/_forward.pyx":494 + * # Minimizing the norm is actually equivalent to maximizing z_end_squared + * # Store z_end_squared and the current candidate as the best knot choice + * best_z_end_squared = z_end_squared # <<<<<<<<<<<<<< + * best_candidate_idx = candidate_idx + * best_candidate = candidate + */ + __pyx_v_best_z_end_squared = __pyx_v_z_end_squared; + + /* "sklearn/earth/_forward.pyx":495 + * # Store z_end_squared and the current candidate as the best knot choice + * best_z_end_squared = z_end_squared + * best_candidate_idx = candidate_idx # <<<<<<<<<<<<<< + * best_candidate = candidate + * + */ + __pyx_v_best_candidate_idx = __pyx_v_candidate_idx; + + /* "sklearn/earth/_forward.pyx":496 + * best_z_end_squared = z_end_squared + * best_candidate_idx = candidate_idx + * best_candidate = candidate # <<<<<<<<<<<<<< + * + * # Initialize the accumulators + */ + __pyx_v_best_candidate = __pyx_v_candidate; + + /* "sklearn/earth/_forward.pyx":499 + * + * # Initialize the accumulators + * i = order[0] # <<<<<<<<<<<<<< + * last_candidate_idx = 0 + * y_cum = y[i] + */ + __pyx_t_33 = 0; + __pyx_v_i = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_order.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":500 + * # Initialize the accumulators + * i = order[0] + * last_candidate_idx = 0 # <<<<<<<<<<<<<< + * y_cum = y[i] + * B_orth_times_parent_cum[0:k + 1] = B_orth[i, 0:k + 1] * b_parent[i] + */ + __pyx_v_last_candidate_idx = 0; + + /* "sklearn/earth/_forward.pyx":501 + * i = order[0] + * last_candidate_idx = 0 + * y_cum = y[i] # <<<<<<<<<<<<<< + * B_orth_times_parent_cum[0:k + 1] = B_orth[i, 0:k + 1] * b_parent[i] + * b_times_parent_cum = b[i] * b_parent[i] + */ + __pyx_t_14 = __pyx_v_i; + __pyx_v_y_cum = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_y.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":502 + * last_candidate_idx = 0 + * y_cum = y[i] + * B_orth_times_parent_cum[0:k + 1] = B_orth[i, 0:k + 1] * b_parent[i] # <<<<<<<<<<<<<< + * b_times_parent_cum = b[i] * b_parent[i] + * parent_squared_cum = b_parent[i] ** 2 + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_23 = __Pyx_PyInt_to_py_npy_ulonglong((__pyx_v_k + 1)); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_23); + __pyx_t_2 = PySlice_New(__pyx_int_0, __pyx_t_23, Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0; + __pyx_t_23 = PyTuple_New(2); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_23); + PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_B_orth), ((PyObject *)__pyx_t_23)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_23)); __pyx_t_23 = 0; + __pyx_t_15 = __pyx_v_i; + __pyx_t_23 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_b_parent.diminfo[0].strides))); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_23); + __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_t_23); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0; + if (__Pyx_PyObject_SetSlice(((PyObject *)__pyx_v_B_orth_times_parent_cum), __pyx_t_1, 0, (__pyx_v_k + 1), NULL, NULL, NULL, 1, 1, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_forward.pyx":503 + * y_cum = y[i] + * B_orth_times_parent_cum[0:k + 1] = B_orth[i, 0:k + 1] * b_parent[i] + * b_times_parent_cum = b[i] * b_parent[i] # <<<<<<<<<<<<<< + * parent_squared_cum = b_parent[i] ** 2 + * parent_times_y_cum = b_parent[i] * y[i] + */ + __pyx_t_34 = __pyx_v_i; + __pyx_t_35 = __pyx_v_i; + __pyx_v_b_times_parent_cum = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_b.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_b_parent.diminfo[0].strides))); + + /* "sklearn/earth/_forward.pyx":504 + * B_orth_times_parent_cum[0:k + 1] = B_orth[i, 0:k + 1] * b_parent[i] + * b_times_parent_cum = b[i] * b_parent[i] + * parent_squared_cum = b_parent[i] ** 2 # <<<<<<<<<<<<<< + * parent_times_y_cum = b_parent[i] * y[i] + * + */ + __pyx_t_36 = __pyx_v_i; + __pyx_v_parent_squared_cum = pow((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_b_parent.diminfo[0].strides)), 2.0); + + /* "sklearn/earth/_forward.pyx":505 + * b_times_parent_cum = b[i] * b_parent[i] + * parent_squared_cum = b_parent[i] ** 2 + * parent_times_y_cum = b_parent[i] * y[i] # <<<<<<<<<<<<<< + * + * # Now loop over the remaining candidates and update z_end_squared for + */ + __pyx_t_37 = __pyx_v_i; + __pyx_t_38 = __pyx_v_i; + __pyx_v_parent_times_y_cum = ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_b_parent.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_y.diminfo[0].strides))); + + /* "sklearn/earth/_forward.pyx":509 + * # Now loop over the remaining candidates and update z_end_squared for + * # each, looking for the greatest value + * for i_ in range(1, num_candidates): # <<<<<<<<<<<<<< + * i = order[i_] + * + */ + __pyx_t_39 = __pyx_v_num_candidates; + for (__pyx_t_40 = 1; __pyx_t_40 < __pyx_t_39; __pyx_t_40+=1) { + __pyx_v_i_ = __pyx_t_40; + + /* "sklearn/earth/_forward.pyx":510 + * # each, looking for the greatest value + * for i_ in range(1, num_candidates): + * i = order[i_] # <<<<<<<<<<<<<< + * + * # Update the candidate + */ + __pyx_t_41 = __pyx_v_i_; + __pyx_v_i = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_order.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":513 + * + * # Update the candidate + * last_last_candidate_idx = last_candidate_idx # <<<<<<<<<<<<<< + * last_candidate_idx = candidate_idx + * last_candidate = candidate + */ + __pyx_v_last_last_candidate_idx = __pyx_v_last_candidate_idx; + + /* "sklearn/earth/_forward.pyx":514 + * # Update the candidate + * last_last_candidate_idx = last_candidate_idx + * last_candidate_idx = candidate_idx # <<<<<<<<<<<<<< + * last_candidate = candidate + * candidate_idx = candidates[i_] + */ + __pyx_v_last_candidate_idx = __pyx_v_candidate_idx; + + /* "sklearn/earth/_forward.pyx":515 + * last_last_candidate_idx = last_candidate_idx + * last_candidate_idx = candidate_idx + * last_candidate = candidate # <<<<<<<<<<<<<< + * candidate_idx = candidates[i_] + * candidate = X[order[candidate_idx], variable] + */ + __pyx_v_last_candidate = __pyx_v_candidate; + + /* "sklearn/earth/_forward.pyx":516 + * last_candidate_idx = candidate_idx + * last_candidate = candidate + * candidate_idx = candidates[i_] # <<<<<<<<<<<<<< + * candidate = X[order[candidate_idx], variable] + * + */ + __pyx_t_42 = __pyx_v_i_; + __pyx_v_candidate_idx = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_candidates.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_candidates.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":517 + * last_candidate = candidate + * candidate_idx = candidates[i_] + * candidate = X[order[candidate_idx], variable] # <<<<<<<<<<<<<< + * + * # Update the accumulators and compute delta_b + */ + __pyx_t_43 = __pyx_v_candidate_idx; + __pyx_t_44 = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_43, __pyx_pybuffernd_order.diminfo[0].strides)); + __pyx_t_45 = __pyx_v_variable; + __pyx_v_candidate = (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_X.diminfo[1].strides)); + + /* "sklearn/earth/_forward.pyx":520 + * + * # Update the accumulators and compute delta_b + * diff = last_candidate - candidate # <<<<<<<<<<<<<< + * delta_c_end = 0.0 + * + */ + __pyx_v_diff = (__pyx_v_last_candidate - __pyx_v_candidate); + + /* "sklearn/earth/_forward.pyx":521 + * # Update the accumulators and compute delta_b + * diff = last_candidate - candidate + * delta_c_end = 0.0 # <<<<<<<<<<<<<< + * + * # What follows is a section of code that has been optimized for speed at the expense of + */ + __pyx_v_delta_c_end = 0.0; + + /* "sklearn/earth/_forward.pyx":553 + * + * # BEGIN HYPER-OPTIMIZED + * delta_b_squared = 0.0 # <<<<<<<<<<<<<< + * delta_c_end = 0.0 + * delta_u_end = 0.0 + */ + __pyx_v_delta_b_squared = 0.0; + + /* "sklearn/earth/_forward.pyx":554 + * # BEGIN HYPER-OPTIMIZED + * delta_b_squared = 0.0 + * delta_c_end = 0.0 # <<<<<<<<<<<<<< + * delta_u_end = 0.0 + * + */ + __pyx_v_delta_c_end = 0.0; + + /* "sklearn/earth/_forward.pyx":555 + * delta_b_squared = 0.0 + * delta_c_end = 0.0 + * delta_u_end = 0.0 # <<<<<<<<<<<<<< + * + * # Update the accumulators + */ + __pyx_v_delta_u_end = 0.0; + + /* "sklearn/earth/_forward.pyx":558 + * + * # Update the accumulators + * for j_ in range(last_last_candidate_idx + 1, last_candidate_idx + 1): # <<<<<<<<<<<<<< + * j = order[j_] + * y_cum += y[j] + */ + __pyx_t_46 = (__pyx_v_last_candidate_idx + 1); + for (__pyx_t_47 = (__pyx_v_last_last_candidate_idx + 1); __pyx_t_47 < __pyx_t_46; __pyx_t_47+=1) { + __pyx_v_j_ = __pyx_t_47; + + /* "sklearn/earth/_forward.pyx":559 + * # Update the accumulators + * for j_ in range(last_last_candidate_idx + 1, last_candidate_idx + 1): + * j = order[j_] # <<<<<<<<<<<<<< + * y_cum += y[j] + * for h in range(k + 1): # TODO: BLAS + */ + __pyx_t_48 = __pyx_v_j_; + __pyx_v_j = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_48, __pyx_pybuffernd_order.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":560 + * for j_ in range(last_last_candidate_idx + 1, last_candidate_idx + 1): + * j = order[j_] + * y_cum += y[j] # <<<<<<<<<<<<<< + * for h in range(k + 1): # TODO: BLAS + * B_orth_times_parent_cum[h] += B_orth[j, h] * b_parent[j] + */ + __pyx_t_49 = __pyx_v_j; + __pyx_v_y_cum = (__pyx_v_y_cum + (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_49, __pyx_pybuffernd_y.diminfo[0].strides))); + + /* "sklearn/earth/_forward.pyx":561 + * j = order[j_] + * y_cum += y[j] + * for h in range(k + 1): # TODO: BLAS # <<<<<<<<<<<<<< + * B_orth_times_parent_cum[h] += B_orth[j, h] * b_parent[j] + * b_times_parent_cum += b[j] * b_parent[j] + */ + __pyx_t_50 = (__pyx_v_k + 1); + for (__pyx_t_51 = 0; __pyx_t_51 < __pyx_t_50; __pyx_t_51+=1) { + __pyx_v_h = __pyx_t_51; + + /* "sklearn/earth/_forward.pyx":562 + * y_cum += y[j] + * for h in range(k + 1): # TODO: BLAS + * B_orth_times_parent_cum[h] += B_orth[j, h] * b_parent[j] # <<<<<<<<<<<<<< + * b_times_parent_cum += b[j] * b_parent[j] + * parent_squared_cum += b_parent[j] ** 2 + */ + __pyx_t_52 = __pyx_v_j; + __pyx_t_53 = __pyx_v_h; + __pyx_t_54 = __pyx_v_j; + __pyx_t_55 = __pyx_v_h; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer.buf, __pyx_t_55, __pyx_pybuffernd_B_orth_times_parent_cum.diminfo[0].strides) += ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_52, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_53, __pyx_pybuffernd_B_orth.diminfo[1].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_54, __pyx_pybuffernd_b_parent.diminfo[0].strides))); + } + + /* "sklearn/earth/_forward.pyx":563 + * for h in range(k + 1): # TODO: BLAS + * B_orth_times_parent_cum[h] += B_orth[j, h] * b_parent[j] + * b_times_parent_cum += b[j] * b_parent[j] # <<<<<<<<<<<<<< + * parent_squared_cum += b_parent[j] ** 2 + * parent_times_y_cum += b_parent[j] * y[j] + */ + __pyx_t_50 = __pyx_v_j; + __pyx_t_51 = __pyx_v_j; + __pyx_v_b_times_parent_cum = (__pyx_v_b_times_parent_cum + ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_50, __pyx_pybuffernd_b.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_51, __pyx_pybuffernd_b_parent.diminfo[0].strides)))); + + /* "sklearn/earth/_forward.pyx":564 + * B_orth_times_parent_cum[h] += B_orth[j, h] * b_parent[j] + * b_times_parent_cum += b[j] * b_parent[j] + * parent_squared_cum += b_parent[j] ** 2 # <<<<<<<<<<<<<< + * parent_times_y_cum += b_parent[j] * y[j] + * delta_c_end += diff * parent_times_y_cum + */ + __pyx_t_56 = __pyx_v_j; + __pyx_v_parent_squared_cum = (__pyx_v_parent_squared_cum + pow((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_56, __pyx_pybuffernd_b_parent.diminfo[0].strides)), 2.0)); + + /* "sklearn/earth/_forward.pyx":565 + * b_times_parent_cum += b[j] * b_parent[j] + * parent_squared_cum += b_parent[j] ** 2 + * parent_times_y_cum += b_parent[j] * y[j] # <<<<<<<<<<<<<< + * delta_c_end += diff * parent_times_y_cum + * delta_u_end += 2 * diff * b_times_parent_cum + */ + __pyx_t_57 = __pyx_v_j; + __pyx_t_58 = __pyx_v_j; + __pyx_v_parent_times_y_cum = (__pyx_v_parent_times_y_cum + ((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_57, __pyx_pybuffernd_b_parent.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_58, __pyx_pybuffernd_y.diminfo[0].strides)))); + } + + /* "sklearn/earth/_forward.pyx":566 + * parent_squared_cum += b_parent[j] ** 2 + * parent_times_y_cum += b_parent[j] * y[j] + * delta_c_end += diff * parent_times_y_cum # <<<<<<<<<<<<<< + * delta_u_end += 2 * diff * b_times_parent_cum + * delta_b_squared = (diff ** 2) * parent_squared_cum + */ + __pyx_v_delta_c_end = (__pyx_v_delta_c_end + (__pyx_v_diff * __pyx_v_parent_times_y_cum)); + + /* "sklearn/earth/_forward.pyx":567 + * parent_times_y_cum += b_parent[j] * y[j] + * delta_c_end += diff * parent_times_y_cum + * delta_u_end += 2 * diff * b_times_parent_cum # <<<<<<<<<<<<<< + * delta_b_squared = (diff ** 2) * parent_squared_cum + * + */ + __pyx_v_delta_u_end = (__pyx_v_delta_u_end + ((2.0 * __pyx_v_diff) * __pyx_v_b_times_parent_cum)); + + /* "sklearn/earth/_forward.pyx":568 + * delta_c_end += diff * parent_times_y_cum + * delta_u_end += 2 * diff * b_times_parent_cum + * delta_b_squared = (diff ** 2) * parent_squared_cum # <<<<<<<<<<<<<< + * + * # Update u and a bunch of other stuff + */ + __pyx_v_delta_b_squared = (pow(__pyx_v_diff, 2.0) * __pyx_v_parent_squared_cum); + + /* "sklearn/earth/_forward.pyx":571 + * + * # Update u and a bunch of other stuff + * for j in range(k + 1): # <<<<<<<<<<<<<< + * float_tmp = diff * B_orth_times_parent_cum[j] + * u_dot_c += float_tmp * c[j] + */ + __pyx_t_46 = (__pyx_v_k + 1); + for (__pyx_t_47 = 0; __pyx_t_47 < __pyx_t_46; __pyx_t_47+=1) { + __pyx_v_j = __pyx_t_47; + + /* "sklearn/earth/_forward.pyx":572 + * # Update u and a bunch of other stuff + * for j in range(k + 1): + * float_tmp = diff * B_orth_times_parent_cum[j] # <<<<<<<<<<<<<< + * u_dot_c += float_tmp * c[j] + * u_dot_u += 2 * u[j] * float_tmp + float_tmp * float_tmp + */ + __pyx_t_59 = __pyx_v_j; + __pyx_v_float_tmp = (__pyx_v_diff * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer.buf, __pyx_t_59, __pyx_pybuffernd_B_orth_times_parent_cum.diminfo[0].strides))); + + /* "sklearn/earth/_forward.pyx":573 + * for j in range(k + 1): + * float_tmp = diff * B_orth_times_parent_cum[j] + * u_dot_c += float_tmp * c[j] # <<<<<<<<<<<<<< + * u_dot_u += 2 * u[j] * float_tmp + float_tmp * float_tmp + * u[j] += float_tmp + */ + __pyx_t_60 = __pyx_v_j; + __pyx_v_u_dot_c = (__pyx_v_u_dot_c + (__pyx_v_float_tmp * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_c.rcbuffer->pybuffer.buf, __pyx_t_60, __pyx_pybuffernd_c.diminfo[0].strides)))); + + /* "sklearn/earth/_forward.pyx":574 + * float_tmp = diff * B_orth_times_parent_cum[j] + * u_dot_c += float_tmp * c[j] + * u_dot_u += 2 * u[j] * float_tmp + float_tmp * float_tmp # <<<<<<<<<<<<<< + * u[j] += float_tmp + * for j_ in range(last_candidate_idx + 1, candidate_idx): + */ + __pyx_t_61 = __pyx_v_j; + __pyx_v_u_dot_u = (__pyx_v_u_dot_u + (((2.0 * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_61, __pyx_pybuffernd_u.diminfo[0].strides))) * __pyx_v_float_tmp) + (__pyx_v_float_tmp * __pyx_v_float_tmp))); + + /* "sklearn/earth/_forward.pyx":575 + * u_dot_c += float_tmp * c[j] + * u_dot_u += 2 * u[j] * float_tmp + float_tmp * float_tmp + * u[j] += float_tmp # <<<<<<<<<<<<<< + * for j_ in range(last_candidate_idx + 1, candidate_idx): + * j = order[j_] + */ + __pyx_t_62 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_62, __pyx_pybuffernd_u.diminfo[0].strides) += __pyx_v_float_tmp; + } + + /* "sklearn/earth/_forward.pyx":576 + * u_dot_u += 2 * u[j] * float_tmp + float_tmp * float_tmp + * u[j] += float_tmp + * for j_ in range(last_candidate_idx + 1, candidate_idx): # <<<<<<<<<<<<<< + * j = order[j_] + * delta_b_j = (X[j, variable] - candidate) * b_parent[j] + */ + __pyx_t_46 = __pyx_v_candidate_idx; + for (__pyx_t_47 = (__pyx_v_last_candidate_idx + 1); __pyx_t_47 < __pyx_t_46; __pyx_t_47+=1) { + __pyx_v_j_ = __pyx_t_47; + + /* "sklearn/earth/_forward.pyx":577 + * u[j] += float_tmp + * for j_ in range(last_candidate_idx + 1, candidate_idx): + * j = order[j_] # <<<<<<<<<<<<<< + * delta_b_j = (X[j, variable] - candidate) * b_parent[j] + * delta_b_squared += delta_b_j ** 2 + */ + __pyx_t_63 = __pyx_v_j_; + __pyx_v_j = (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_INT_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_63, __pyx_pybuffernd_order.diminfo[0].strides)); + + /* "sklearn/earth/_forward.pyx":578 + * for j_ in range(last_candidate_idx + 1, candidate_idx): + * j = order[j_] + * delta_b_j = (X[j, variable] - candidate) * b_parent[j] # <<<<<<<<<<<<<< + * delta_b_squared += delta_b_j ** 2 + * delta_c_end += delta_b_j * y[j] + */ + __pyx_t_64 = __pyx_v_j; + __pyx_t_65 = __pyx_v_variable; + __pyx_t_66 = __pyx_v_j; + __pyx_v_delta_b_j = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_64, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_65, __pyx_pybuffernd_X.diminfo[1].strides)) - __pyx_v_candidate) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b_parent.rcbuffer->pybuffer.buf, __pyx_t_66, __pyx_pybuffernd_b_parent.diminfo[0].strides))); + + /* "sklearn/earth/_forward.pyx":579 + * j = order[j_] + * delta_b_j = (X[j, variable] - candidate) * b_parent[j] + * delta_b_squared += delta_b_j ** 2 # <<<<<<<<<<<<<< + * delta_c_end += delta_b_j * y[j] + * delta_u_end += 2 * delta_b_j * b[j] + */ + __pyx_v_delta_b_squared = (__pyx_v_delta_b_squared + pow(__pyx_v_delta_b_j, 2.0)); + + /* "sklearn/earth/_forward.pyx":580 + * delta_b_j = (X[j, variable] - candidate) * b_parent[j] + * delta_b_squared += delta_b_j ** 2 + * delta_c_end += delta_b_j * y[j] # <<<<<<<<<<<<<< + * delta_u_end += 2 * delta_b_j * b[j] + * for h in range(k + 1): + */ + __pyx_t_67 = __pyx_v_j; + __pyx_v_delta_c_end = (__pyx_v_delta_c_end + (__pyx_v_delta_b_j * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_67, __pyx_pybuffernd_y.diminfo[0].strides)))); + + /* "sklearn/earth/_forward.pyx":581 + * delta_b_squared += delta_b_j ** 2 + * delta_c_end += delta_b_j * y[j] + * delta_u_end += 2 * delta_b_j * b[j] # <<<<<<<<<<<<<< + * for h in range(k + 1): + * float_tmp = delta_b_j * B_orth[j, h] + */ + __pyx_t_68 = __pyx_v_j; + __pyx_v_delta_u_end = (__pyx_v_delta_u_end + ((2.0 * __pyx_v_delta_b_j) * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_68, __pyx_pybuffernd_b.diminfo[0].strides)))); + + /* "sklearn/earth/_forward.pyx":582 + * delta_c_end += delta_b_j * y[j] + * delta_u_end += 2 * delta_b_j * b[j] + * for h in range(k + 1): # <<<<<<<<<<<<<< + * float_tmp = delta_b_j * B_orth[j, h] + * u_dot_c += float_tmp * c[h] + */ + __pyx_t_69 = (__pyx_v_k + 1); + for (__pyx_t_70 = 0; __pyx_t_70 < __pyx_t_69; __pyx_t_70+=1) { + __pyx_v_h = __pyx_t_70; + + /* "sklearn/earth/_forward.pyx":583 + * delta_u_end += 2 * delta_b_j * b[j] + * for h in range(k + 1): + * float_tmp = delta_b_j * B_orth[j, h] # <<<<<<<<<<<<<< + * u_dot_c += float_tmp * c[h] + * u_dot_u += 2 * u[h] * float_tmp + float_tmp * float_tmp + */ + __pyx_t_71 = __pyx_v_j; + __pyx_t_72 = __pyx_v_h; + __pyx_v_float_tmp = (__pyx_v_delta_b_j * (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_B_orth.rcbuffer->pybuffer.buf, __pyx_t_71, __pyx_pybuffernd_B_orth.diminfo[0].strides, __pyx_t_72, __pyx_pybuffernd_B_orth.diminfo[1].strides))); + + /* "sklearn/earth/_forward.pyx":584 + * for h in range(k + 1): + * float_tmp = delta_b_j * B_orth[j, h] + * u_dot_c += float_tmp * c[h] # <<<<<<<<<<<<<< + * u_dot_u += 2 * u[h] * float_tmp + float_tmp * float_tmp + * u[h] += float_tmp + */ + __pyx_t_73 = __pyx_v_h; + __pyx_v_u_dot_c = (__pyx_v_u_dot_c + (__pyx_v_float_tmp * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_c.rcbuffer->pybuffer.buf, __pyx_t_73, __pyx_pybuffernd_c.diminfo[0].strides)))); + + /* "sklearn/earth/_forward.pyx":585 + * float_tmp = delta_b_j * B_orth[j, h] + * u_dot_c += float_tmp * c[h] + * u_dot_u += 2 * u[h] * float_tmp + float_tmp * float_tmp # <<<<<<<<<<<<<< + * u[h] += float_tmp + * b[j] += delta_b_j + */ + __pyx_t_74 = __pyx_v_h; + __pyx_v_u_dot_u = (__pyx_v_u_dot_u + (((2.0 * (*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_74, __pyx_pybuffernd_u.diminfo[0].strides))) * __pyx_v_float_tmp) + (__pyx_v_float_tmp * __pyx_v_float_tmp))); + + /* "sklearn/earth/_forward.pyx":586 + * u_dot_c += float_tmp * c[h] + * u_dot_u += 2 * u[h] * float_tmp + float_tmp * float_tmp + * u[h] += float_tmp # <<<<<<<<<<<<<< + * b[j] += delta_b_j + * + */ + __pyx_t_75 = __pyx_v_h; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_75, __pyx_pybuffernd_u.diminfo[0].strides) += __pyx_v_float_tmp; + } + + /* "sklearn/earth/_forward.pyx":587 + * u_dot_u += 2 * u[h] * float_tmp + float_tmp * float_tmp + * u[h] += float_tmp + * b[j] += delta_b_j # <<<<<<<<<<<<<< + * + * # Update u_end + */ + __pyx_t_69 = __pyx_v_j; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_pybuffernd_b.rcbuffer->pybuffer.buf, __pyx_t_69, __pyx_pybuffernd_b.diminfo[0].strides) += __pyx_v_delta_b_j; + } + + /* "sklearn/earth/_forward.pyx":590 + * + * # Update u_end + * delta_u_end += delta_b_squared # <<<<<<<<<<<<<< + * u_end += delta_u_end + * + */ + __pyx_v_delta_u_end = (__pyx_v_delta_u_end + __pyx_v_delta_b_squared); + + /* "sklearn/earth/_forward.pyx":591 + * # Update u_end + * delta_u_end += delta_b_squared + * u_end += delta_u_end # <<<<<<<<<<<<<< + * + * # Update c_end + */ + __pyx_v_u_end = (__pyx_v_u_end + __pyx_v_delta_u_end); + + /* "sklearn/earth/_forward.pyx":594 + * + * # Update c_end + * c_end += delta_c_end # <<<<<<<<<<<<<< + * + * # Update b_times_parent_cum + */ + __pyx_v_c_end = (__pyx_v_c_end + __pyx_v_delta_c_end); + + /* "sklearn/earth/_forward.pyx":597 + * + * # Update b_times_parent_cum + * b_times_parent_cum += parent_squared_cum * diff # <<<<<<<<<<<<<< + * + * # Compute the new z_end_squared (this is the quantity we're + */ + __pyx_v_b_times_parent_cum = (__pyx_v_b_times_parent_cum + (__pyx_v_parent_squared_cum * __pyx_v_diff)); + + /* "sklearn/earth/_forward.pyx":601 + * # Compute the new z_end_squared (this is the quantity we're + * # optimizing) + * if (u_end - u_dot_u) <= self.zero_tol: # <<<<<<<<<<<<<< + * continue + * z_end_squared = ((c_end - u_dot_c) ** 2) / (u_end - u_dot_u) + */ + __pyx_t_20 = (((__pyx_v_u_end - __pyx_v_u_dot_u) <= __pyx_v_self->zero_tol) != 0); + if (__pyx_t_20) { + + /* "sklearn/earth/_forward.pyx":602 + * # optimizing) + * if (u_end - u_dot_u) <= self.zero_tol: + * continue # <<<<<<<<<<<<<< + * z_end_squared = ((c_end - u_dot_c) ** 2) / (u_end - u_dot_u) + * # END HYPER-OPTIMIZED + */ + goto __pyx_L13_continue; + goto __pyx_L25; + } + __pyx_L25:; + + /* "sklearn/earth/_forward.pyx":603 + * if (u_end - u_dot_u) <= self.zero_tol: + * continue + * z_end_squared = ((c_end - u_dot_c) ** 2) / (u_end - u_dot_u) # <<<<<<<<<<<<<< + * # END HYPER-OPTIMIZED + * + */ + __pyx_v_z_end_squared = (pow((__pyx_v_c_end - __pyx_v_u_dot_c), 2.0) / (__pyx_v_u_end - __pyx_v_u_dot_u)); + + /* "sklearn/earth/_forward.pyx":607 + * + * # Update the best if necessary + * if z_end_squared > best_z_end_squared: # <<<<<<<<<<<<<< + * best_z_end_squared = z_end_squared + * best_candidate_idx = candidate_idx + */ + __pyx_t_20 = ((__pyx_v_z_end_squared > __pyx_v_best_z_end_squared) != 0); + if (__pyx_t_20) { + + /* "sklearn/earth/_forward.pyx":608 + * # Update the best if necessary + * if z_end_squared > best_z_end_squared: + * best_z_end_squared = z_end_squared # <<<<<<<<<<<<<< + * best_candidate_idx = candidate_idx + * best_candidate = candidate + */ + __pyx_v_best_z_end_squared = __pyx_v_z_end_squared; + + /* "sklearn/earth/_forward.pyx":609 + * if z_end_squared > best_z_end_squared: + * best_z_end_squared = z_end_squared + * best_candidate_idx = candidate_idx # <<<<<<<<<<<<<< + * best_candidate = candidate + * + */ + __pyx_v_best_candidate_idx = __pyx_v_candidate_idx; + + /* "sklearn/earth/_forward.pyx":610 + * best_z_end_squared = z_end_squared + * best_candidate_idx = candidate_idx + * best_candidate = candidate # <<<<<<<<<<<<<< + * + * # Compute the mse for the best z_end and set return values + */ + __pyx_v_best_candidate = __pyx_v_candidate; + goto __pyx_L26; + } + __pyx_L26:; + __pyx_L13_continue:; + } + + /* "sklearn/earth/_forward.pyx":613 + * + * # Compute the mse for the best z_end and set return values + * mse[0] = ( # <<<<<<<<<<<<<< + * self.y_squared - self.c_squared - best_z_end_squared) / self.m + * knot[0] = best_candidate + */ + (__pyx_v_mse[0]) = (((__pyx_v_self->y_squared - __pyx_v_self->c_squared) - __pyx_v_best_z_end_squared) / __pyx_v_self->m); + + /* "sklearn/earth/_forward.pyx":615 + * mse[0] = ( + * self.y_squared - self.c_squared - best_z_end_squared) / self.m + * knot[0] = best_candidate # <<<<<<<<<<<<<< + * knot_idx[0] = best_candidate_idx + */ + (__pyx_v_knot[0]) = __pyx_v_best_candidate; + + /* "sklearn/earth/_forward.pyx":616 + * self.y_squared - self.c_squared - best_z_end_squared) / self.m + * knot[0] = best_candidate + * knot_idx[0] = best_candidate_idx # <<<<<<<<<<<<<< + */ + (__pyx_v_knot_idx[0]) = __pyx_v_best_candidate_idx; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_23); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b_parent.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_c.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_candidates.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_u.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._forward.ForwardPasser.best_knot", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B_orth_times_parent_cum.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_b_parent.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_c.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_candidates.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_u.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_b); + __Pyx_XDECREF((PyObject *)__pyx_v_b_parent); + __Pyx_XDECREF((PyObject *)__pyx_v_u); + __Pyx_XDECREF((PyObject *)__pyx_v_B_orth); + __Pyx_XDECREF((PyObject *)__pyx_v_X); + __Pyx_XDECREF((PyObject *)__pyx_v_y); + __Pyx_XDECREF((PyObject *)__pyx_v_c); + __Pyx_XDECREF((PyObject *)__pyx_v_B_orth_times_parent_cum); + __Pyx_XDECREF((PyObject *)__pyx_v_B); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":194 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "numpy.pxd":200 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":203 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":204 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":206 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "numpy.pxd":208 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":209 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + goto __pyx_L4; + } + /*else*/ { + + /* "numpy.pxd":211 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "numpy.pxd":213 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":214 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_27), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "numpy.pxd":217 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_3) { + + /* "numpy.pxd":218 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = __pyx_t_1; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (__pyx_t_2) { + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_29), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "numpy.pxd":221 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "numpy.pxd":222 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "numpy.pxd":223 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_2 = (__pyx_v_copy_shape != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":226 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "numpy.pxd":227 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "numpy.pxd":228 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "numpy.pxd":229 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "numpy.pxd":230 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + goto __pyx_L7; + } + /*else*/ { + + /* "numpy.pxd":232 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "numpy.pxd":233 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L7:; + + /* "numpy.pxd":234 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "numpy.pxd":235 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "numpy.pxd":236 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "numpy.pxd":239 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef list stack + */ + __pyx_v_f = NULL; + + /* "numpy.pxd":240 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef list stack + * cdef int offset + */ + __pyx_t_4 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_4); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":244 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "numpy.pxd":246 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_3; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":248 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + goto __pyx_L10; + } + /*else*/ { + + /* "numpy.pxd":251 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L10:; + + /* "numpy.pxd":253 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":254 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_5 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_5; + + /* "numpy.pxd":255 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_2 = __pyx_t_1; + } + if (!__pyx_t_2) { + + /* "numpy.pxd":256 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_1) { + __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_7 = __pyx_t_3; + } else { + __pyx_t_7 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_7; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_31), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + switch (__pyx_v_t) { + + /* "numpy.pxd":258 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + case NPY_BYTE: + __pyx_v_f = __pyx_k__b; + break; + + /* "numpy.pxd":259 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = __pyx_k__B; + break; + + /* "numpy.pxd":260 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = __pyx_k__h; + break; + + /* "numpy.pxd":261 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = __pyx_k__H; + break; + + /* "numpy.pxd":262 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = __pyx_k__i; + break; + + /* "numpy.pxd":263 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = __pyx_k__I; + break; + + /* "numpy.pxd":264 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = __pyx_k__l; + break; + + /* "numpy.pxd":265 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = __pyx_k__L; + break; + + /* "numpy.pxd":266 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = __pyx_k__q; + break; + + /* "numpy.pxd":267 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = __pyx_k__Q; + break; + + /* "numpy.pxd":268 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = __pyx_k__f; + break; + + /* "numpy.pxd":269 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = __pyx_k__d; + break; + + /* "numpy.pxd":270 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = __pyx_k__g; + break; + + /* "numpy.pxd":271 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = __pyx_k__Zf; + break; + + /* "numpy.pxd":272 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = __pyx_k__Zd; + break; + + /* "numpy.pxd":273 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = __pyx_k__Zg; + break; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = __pyx_k__O; + break; + default: + + /* "numpy.pxd":276 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_32), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + + /* "numpy.pxd":277 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "numpy.pxd":278 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":280 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + __pyx_v_info->format = ((char *)malloc(255)); + + /* "numpy.pxd":281 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "numpy.pxd":282 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "numpy.pxd":285 + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + * &offset) # <<<<<<<<<<<<<< + * f[0] = c'\0' # Terminate format string + * + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_9; + + /* "numpy.pxd":286 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + __pyx_L11:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":288 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "numpy.pxd":289 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":290 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":291 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":292 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + goto __pyx_L4; + } + __pyx_L4:; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":768 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "numpy.pxd":769 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":771 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "numpy.pxd":772 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":774 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "numpy.pxd":775 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":777 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "numpy.pxd":778 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":780 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "numpy.pxd":781 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":783 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + char *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "numpy.pxd":790 + * cdef int delta_offset + * cdef tuple i + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":791 + * cdef tuple i + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "numpy.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) { + PyObject* sequence = ((PyObject *)__pyx_v_fields); + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + } else if (1) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else + { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "numpy.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (__pyx_t_7) { + __pyx_t_8 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_8 = __pyx_t_7; + } + if (!__pyx_t_8) { + + /* "numpy.pxd":802 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + __pyx_t_9 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_10 = __pyx_t_9; + } else { + __pyx_t_10 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_10; + } else { + __pyx_t_7 = __pyx_t_8; + } + if (__pyx_t_7) { + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_35), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "numpy.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!__pyx_t_7) break; + + /* "numpy.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 120; + + /* "numpy.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "numpy.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1); + } + + /* "numpy.pxd":818 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize); + + /* "numpy.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_7 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":821 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_7 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_37), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":826 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 98; + goto __pyx_L13; + } + + /* "numpy.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 66; + goto __pyx_L13; + } + + /* "numpy.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 104; + goto __pyx_L13; + } + + /* "numpy.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 72; + goto __pyx_L13; + } + + /* "numpy.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 105; + goto __pyx_L13; + } + + /* "numpy.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 73; + goto __pyx_L13; + } + + /* "numpy.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 108; + goto __pyx_L13; + } + + /* "numpy.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 76; + goto __pyx_L13; + } + + /* "numpy.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 113; + goto __pyx_L13; + } + + /* "numpy.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 81; + goto __pyx_L13; + } + + /* "numpy.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 102; + goto __pyx_L13; + } + + /* "numpy.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 100; + goto __pyx_L13; + } + + /* "numpy.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 103; + goto __pyx_L13; + } + + /* "numpy.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 102; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 100; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 103; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 79; + goto __pyx_L13; + } + /*else*/ { + + /* "numpy.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_32), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L13:; + + /* "numpy.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_12; + } + __pyx_L11:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "numpy.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":965 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "numpy.pxd":967 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":968 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":970 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + Py_INCREF(__pyx_v_base); + + /* "numpy.pxd":971 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "numpy.pxd":972 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "numpy.pxd":973 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "numpy.pxd":976 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":977 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":979 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser; + +static PyObject *__pyx_tp_new_7sklearn_5earth_8_forward_ForwardPasser(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)o); + p->__pyx_vtab = __pyx_vtabptr_7sklearn_5earth_8_forward_ForwardPasser; + p->xlabels = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->X = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->sample_weight = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->B = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->B_orth = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->c = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->norms = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->u = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->B_orth_times_parent_cum = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->sort_tracker = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->sorting = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->mwork = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->linear_variables = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->record = ((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)Py_None); Py_INCREF(Py_None); + p->basis = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_8_forward_ForwardPasser(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *p = (struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->xlabels); + Py_CLEAR(p->X); + Py_CLEAR(p->y); + Py_CLEAR(p->sample_weight); + Py_CLEAR(p->B); + Py_CLEAR(p->B_orth); + Py_CLEAR(p->c); + Py_CLEAR(p->norms); + Py_CLEAR(p->u); + Py_CLEAR(p->B_orth_times_parent_cum); + Py_CLEAR(p->sort_tracker); + Py_CLEAR(p->sorting); + Py_CLEAR(p->mwork); + Py_CLEAR(p->linear_variables); + Py_CLEAR(p->record); + Py_CLEAR(p->basis); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_8_forward_ForwardPasser(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *p = (struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)o; + if (p->xlabels) { + e = (*v)(p->xlabels, a); if (e) return e; + } + if (p->X) { + e = (*v)(((PyObject*)p->X), a); if (e) return e; + } + if (p->y) { + e = (*v)(((PyObject*)p->y), a); if (e) return e; + } + if (p->sample_weight) { + e = (*v)(((PyObject*)p->sample_weight), a); if (e) return e; + } + if (p->B) { + e = (*v)(((PyObject*)p->B), a); if (e) return e; + } + if (p->B_orth) { + e = (*v)(((PyObject*)p->B_orth), a); if (e) return e; + } + if (p->c) { + e = (*v)(((PyObject*)p->c), a); if (e) return e; + } + if (p->norms) { + e = (*v)(((PyObject*)p->norms), a); if (e) return e; + } + if (p->u) { + e = (*v)(((PyObject*)p->u), a); if (e) return e; + } + if (p->B_orth_times_parent_cum) { + e = (*v)(((PyObject*)p->B_orth_times_parent_cum), a); if (e) return e; + } + if (p->sort_tracker) { + e = (*v)(((PyObject*)p->sort_tracker), a); if (e) return e; + } + if (p->sorting) { + e = (*v)(((PyObject*)p->sorting), a); if (e) return e; + } + if (p->mwork) { + e = (*v)(((PyObject*)p->mwork), a); if (e) return e; + } + if (p->linear_variables) { + e = (*v)(((PyObject*)p->linear_variables), a); if (e) return e; + } + if (p->record) { + e = (*v)(((PyObject*)p->record), a); if (e) return e; + } + if (p->basis) { + e = (*v)(((PyObject*)p->basis), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_8_forward_ForwardPasser(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *p = (struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *)o; + PyObject* tmp; + tmp = ((PyObject*)p->xlabels); + p->xlabels = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->X); + p->X = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->y); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->sample_weight); + p->sample_weight = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->B); + p->B = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->B_orth); + p->B_orth = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->c); + p->c = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->norms); + p->norms = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->u); + p->u = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->B_orth_times_parent_cum); + p->B_orth_times_parent_cum = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->sort_tracker); + p->sort_tracker = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->sorting); + p->sorting = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->mwork); + p->mwork = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->linear_variables); + p->linear_variables = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->record); + p->record = ((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->basis); + p->basis = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_8_forward_ForwardPasser[] = { + {__Pyx_NAMESTR("get_basis"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_3get_basis, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("init_linear_variables"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_5init_linear_variables, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_B_orth"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_7get_B_orth, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("run"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_9run, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("orthonormal_update"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_11orthonormal_update, METH_O, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_8_forward_13ForwardPasser_10orthonormal_update)}, + {__Pyx_NAMESTR("orthonormal_downdate"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_13orthonormal_downdate, METH_O, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_8_forward_13ForwardPasser_12orthonormal_downdate)}, + {__Pyx_NAMESTR("trace"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_15trace, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_8_forward_ForwardPasser = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._forward.ForwardPasser"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_8_forward_ForwardPasser, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_8_forward_ForwardPasser, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_8_forward_ForwardPasser, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_8_forward_ForwardPasser, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_8_forward_13ForwardPasser_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_8_forward_ForwardPasser, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + __Pyx_NAMESTR("_forward"), + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 1}, + {&__pyx_kp_u_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 1, 0, 0}, + {&__pyx_kp_u_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 1, 0, 0}, + {&__pyx_kp_u_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 1, 0, 0}, + {&__pyx_kp_u_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 1, 0, 0}, + {&__pyx_kp_u_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 1, 0, 0}, + {&__pyx_kp_u_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 1, 0, 0}, + {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0}, + {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0}, + {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, + {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0}, + {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0}, + {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0}, + {&__pyx_n_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 1}, + {&__pyx_n_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 1}, + {&__pyx_n_s__C, __pyx_k__C, sizeof(__pyx_k__C), 0, 0, 1, 1}, + {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1}, + {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, + {&__pyx_n_s__X, __pyx_k__X, sizeof(__pyx_k__X), 0, 0, 1, 1}, + {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, + {&__pyx_n_s____len__, __pyx_k____len__, sizeof(__pyx_k____len__), 0, 0, 1, 1}, + {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_capi__, __pyx_k____pyx_capi__, sizeof(__pyx_k____pyx_capi__), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_getbuffer, __pyx_k____pyx_getbuffer, sizeof(__pyx_k____pyx_getbuffer), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_releasebuffer, __pyx_k____pyx_releasebuffer, sizeof(__pyx_k____pyx_releasebuffer), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_vtable__, __pyx_k____pyx_vtable__, sizeof(__pyx_k____pyx_vtable__), 0, 0, 1, 1}, + {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s__allow_linear, __pyx_k__allow_linear, sizeof(__pyx_k__allow_linear), 0, 0, 1, 1}, + {&__pyx_n_s__argsort, __pyx_k__argsort, sizeof(__pyx_k__argsort), 0, 0, 1, 1}, + {&__pyx_n_s__check_every, __pyx_k__check_every, sizeof(__pyx_k__check_every), 0, 0, 1, 1}, + {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1}, + {&__pyx_n_s__dot, __pyx_k__dot, sizeof(__pyx_k__dot), 0, 0, 1, 1}, + {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1}, + {&__pyx_n_s__empty, __pyx_k__empty, sizeof(__pyx_k__empty), 0, 0, 1, 1}, + {&__pyx_n_s__endspan, __pyx_k__endspan, sizeof(__pyx_k__endspan), 0, 0, 1, 1}, + {&__pyx_n_s__endspan_alpha, __pyx_k__endspan_alpha, sizeof(__pyx_k__endspan_alpha), 0, 0, 1, 1}, + {&__pyx_n_s__float, __pyx_k__float, sizeof(__pyx_k__float), 0, 0, 1, 1}, + {&__pyx_n_s__get_basis, __pyx_k__get_basis, sizeof(__pyx_k__get_basis), 0, 0, 1, 1}, + {&__pyx_n_s__get_size, __pyx_k__get_size, sizeof(__pyx_k__get_size), 0, 0, 1, 1}, + {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1}, + {&__pyx_n_s__int, __pyx_k__int, sizeof(__pyx_k__int), 0, 0, 1, 1}, + {&__pyx_n_s__linvars, __pyx_k__linvars, sizeof(__pyx_k__linvars), 0, 0, 1, 1}, + {&__pyx_n_s__max_degree, __pyx_k__max_degree, sizeof(__pyx_k__max_degree), 0, 0, 1, 1}, + {&__pyx_n_s__max_terms, __pyx_k__max_terms, sizeof(__pyx_k__max_terms), 0, 0, 1, 1}, + {&__pyx_n_s__min_search_points, __pyx_k__min_search_points, sizeof(__pyx_k__min_search_points), 0, 0, 1, 1}, + {&__pyx_n_s__minspan, __pyx_k__minspan, sizeof(__pyx_k__minspan), 0, 0, 1, 1}, + {&__pyx_n_s__minspan_alpha, __pyx_k__minspan_alpha, sizeof(__pyx_k__minspan_alpha), 0, 0, 1, 1}, + {&__pyx_n_s__nan, __pyx_k__nan, sizeof(__pyx_k__nan), 0, 0, 1, 1}, + {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, + {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, + {&__pyx_n_s__ones, __pyx_k__ones, sizeof(__pyx_k__ones), 0, 0, 1, 1}, + {&__pyx_n_s__order, __pyx_k__order, sizeof(__pyx_k__order), 0, 0, 1, 1}, + {&__pyx_n_s__orthonormal_update, __pyx_k__orthonormal_update, sizeof(__pyx_k__orthonormal_update), 0, 0, 1, 1}, + {&__pyx_n_s__penalty, __pyx_k__penalty, sizeof(__pyx_k__penalty), 0, 0, 1, 1}, + {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, + {&__pyx_n_s__round, __pyx_k__round, sizeof(__pyx_k__round), 0, 0, 1, 1}, + {&__pyx_n_s__run, __pyx_k__run, sizeof(__pyx_k__run), 0, 0, 1, 1}, + {&__pyx_n_s__sample_weight, __pyx_k__sample_weight, sizeof(__pyx_k__sample_weight), 0, 0, 1, 1}, + {&__pyx_n_s__set_no_candidates, __pyx_k__set_no_candidates, sizeof(__pyx_k__set_no_candidates), 0, 0, 1, 1}, + {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1}, + {&__pyx_n_s__sqrt, __pyx_k__sqrt, sizeof(__pyx_k__sqrt), 0, 0, 1, 1}, + {&__pyx_n_s__stopping_conditions, __pyx_k__stopping_conditions, sizeof(__pyx_k__stopping_conditions), 0, 0, 1, 1}, + {&__pyx_n_s__sum, __pyx_k__sum, sizeof(__pyx_k__sum), 0, 0, 1, 1}, + {&__pyx_n_s__thresh, __pyx_k__thresh, sizeof(__pyx_k__thresh), 0, 0, 1, 1}, + {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1}, + {&__pyx_n_s__xlabels, __pyx_k__xlabels, sizeof(__pyx_k__xlabels), 0, 0, 1, 1}, + {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, + {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s__round); if (!__pyx_builtin_round) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "sklearn/earth/_forward.pyx":69 + * self.B = np.ones( + * shape=(self.m, self.max_terms), order='C', dtype=np.float) + * self.basis.weighted_transform(self.X, self.B[:,0:1], self.sample_weight) # <<<<<<<<<<<<<< + * # An orthogonal matrix with the same column space as B + * self.B_orth = self.B.copy() + */ + __pyx_k_slice_1 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_1); + __Pyx_GIVEREF(__pyx_k_slice_1); + __pyx_k_slice_2 = PySlice_New(__pyx_int_0, __pyx_int_1, Py_None); if (unlikely(!__pyx_k_slice_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_2); + __Pyx_GIVEREF(__pyx_k_slice_2); + __pyx_k_tuple_3 = PyTuple_Pack(2, __pyx_k_slice_1, __pyx_k_slice_2); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_3); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3)); + + /* "sklearn/earth/_forward.pyx":92 + * self.linear_variables[linvar] = 1 + * else: + * raise IndexError( # <<<<<<<<<<<<<< + * 'Unknown variable selected in linvars argument.') + * + */ + __pyx_k_tuple_5 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_5); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); + + /* "sklearn/earth/_forward.pyx":115 + * cdef ConstantBasisFunction root_basis_function = self.basis[0] + * for variable in range(self.n): + * order = np.argsort(X[:, variable])[::-1] # <<<<<<<<<<<<<< + * if root_basis_function.valid_knots(B[order, 0], X[order, variable], + * variable, self.check_every, endspan, + */ + __pyx_k_slice_7 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_7); + __Pyx_GIVEREF(__pyx_k_slice_7); + __pyx_k_slice_8 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_k_slice_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_8); + __Pyx_GIVEREF(__pyx_k_slice_8); + + /* "sklearn/earth/_forward.pyx":269 + * # Sort the data + * # TODO: eliminate Python call / data copy + * sorting[:] = np.argsort(X[:, variable])[::-1] # <<<<<<<<<<<<<< + * + * # Iterate over parents + */ + __pyx_k_slice_11 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_11); + __Pyx_GIVEREF(__pyx_k_slice_11); + __pyx_k_slice_12 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_k_slice_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_12); + __Pyx_GIVEREF(__pyx_k_slice_12); + __pyx_k_slice_13 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_13); + __Pyx_GIVEREF(__pyx_k_slice_13); + + /* "sklearn/earth/_forward.pyx":367 + * bf2 = HingeBasisFunction( + * parent_choice, knot_choice, knot_idx_choice, variable_choice, True, label) + * bf1.apply(X, B[:, k]) # <<<<<<<<<<<<<< + * apply_weights_slice(B, sample_weight, k) + * bf2.apply(X, B[:, k + 1]) + */ + __pyx_k_slice_14 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_14); + __Pyx_GIVEREF(__pyx_k_slice_14); + + /* "sklearn/earth/_forward.pyx":369 + * bf1.apply(X, B[:, k]) + * apply_weights_slice(B, sample_weight, k) + * bf2.apply(X, B[:, k + 1]) # <<<<<<<<<<<<<< + * apply_weights_slice(B, sample_weight, k + 1) + * self.basis.append(bf1) + */ + __pyx_k_slice_15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_15); + __Pyx_GIVEREF(__pyx_k_slice_15); + + /* "sklearn/earth/_forward.pyx":375 + * + * # Orthogonalize the new basis + * B_orth[:, k] = B[:, k] # <<<<<<<<<<<<<< + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() + */ + __pyx_k_slice_16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_16); + __Pyx_GIVEREF(__pyx_k_slice_16); + __pyx_k_slice_17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_17); + __Pyx_GIVEREF(__pyx_k_slice_17); + + /* "sklearn/earth/_forward.pyx":378 + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() + * B_orth[:, k + 1] = B[:, k + 1] # <<<<<<<<<<<<<< + * if self.orthonormal_update(k + 1) == 1: + * bf2.make_unsplittable() + */ + __pyx_k_slice_18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_18); + __Pyx_GIVEREF(__pyx_k_slice_18); + __pyx_k_slice_19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_19); + __Pyx_GIVEREF(__pyx_k_slice_19); + + /* "sklearn/earth/_forward.pyx":384 + * # In this case, only add the linear basis function + * bf1 = LinearBasisFunction(parent_choice, variable_choice, label) + * bf1.apply(X, B[:, k]) # <<<<<<<<<<<<<< + * apply_weights_slice(B, sample_weight, k) + * self.basis.append(bf1) + */ + __pyx_k_slice_20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_20); + __Pyx_GIVEREF(__pyx_k_slice_20); + + /* "sklearn/earth/_forward.pyx":389 + * + * # Orthogonalize the new basis + * B_orth[:, k] = B[:, k] # <<<<<<<<<<<<<< + * if self.orthonormal_update(k) == 1: + * bf1.make_unsplittable() + */ + __pyx_k_slice_21 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_21); + __Pyx_GIVEREF(__pyx_k_slice_21); + __pyx_k_slice_22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_22); + __Pyx_GIVEREF(__pyx_k_slice_22); + + /* "sklearn/earth/_forward.pyx":413 + * ''' + * + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b = self.B[:, k + 1] # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b_parent = self.B[:, parent] + * cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u + */ + __pyx_k_slice_23 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_23); + __Pyx_GIVEREF(__pyx_k_slice_23); + + /* "sklearn/earth/_forward.pyx":414 + * + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b = self.B[:, k + 1] + * cdef cnp.ndarray[FLOAT_t, ndim = 1] b_parent = self.B[:, parent] # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + */ + __pyx_k_slice_24 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_24); + __Pyx_GIVEREF(__pyx_k_slice_24); + + /* "sklearn/earth/_forward.pyx":471 + * # Compute the initial covariance column, u (not including the final + * # element) + * u[0:k + 1] = np.dot(b, B_orth[:, 0:k + 1]) # <<<<<<<<<<<<<< + * + * # Compute the new last elements of c and u + */ + __pyx_k_slice_25 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_25); + __Pyx_GIVEREF(__pyx_k_slice_25); + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_k_tuple_27 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_26)); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_27); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_k_tuple_29 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_28)); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_29); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29)); + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_k_tuple_31 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_30)); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_31); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31)); + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_k_tuple_34 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_33)); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_34); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34)); + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_k_tuple_35 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_30)); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_35); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35)); + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_k_tuple_37 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_36)); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_37); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37)); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_forward(void); /*proto*/ +PyMODINIT_FUNC init_forward(void) +#else +PyMODINIT_FUNC PyInit__forward(void); /*proto*/ +PyMODINIT_FUNC PyInit__forward(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__forward(void)", 0); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __Pyx_CyFunction_USED + if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_forward"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_d); + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "sklearn.earth._forward")) { + if (unlikely(PyDict_SetItemString(modules, "sklearn.earth._forward", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + } + #endif + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + /*--- Initialize various global constants etc. ---*/ + if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if (__pyx_module_is_main_sklearn__earth___forward) { + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + /*--- Builtin init code ---*/ + if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Constants init code ---*/ + if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Global init code ---*/ + __pyx_v_7sklearn_5earth_8_forward_stopping_conditions = ((PyObject*)Py_None); Py_INCREF(Py_None); + /*--- Variable export code ---*/ + if (__Pyx_ExportVoidPtr(__pyx_n_s__stopping_conditions, (void *)&__pyx_v_7sklearn_5earth_8_forward_stopping_conditions, "PyObject *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_7sklearn_5earth_8_forward_ForwardPasser = &__pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.get_basis = (struct __pyx_obj_7sklearn_5earth_6_basis_Basis *(*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_get_basis; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.init_linear_variables = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_init_linear_variables; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.run = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_run; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.stop_check = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_stop_check; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.orthonormal_update = (int (*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_orthonormal_update; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.orthonormal_downdate = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_orthonormal_downdate; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.next_pair = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_next_pair; + __pyx_vtable_7sklearn_5earth_8_forward_ForwardPasser.best_knot = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, PyArrayObject *, PyArrayObject *, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t *))__pyx_f_7sklearn_5earth_8_forward_13ForwardPasser_best_knot; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_8_forward_ForwardPasser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_8_forward_ForwardPasser.tp_dict, __pyx_vtabptr_7sklearn_5earth_8_forward_ForwardPasser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "ForwardPasser", (PyObject *)&__pyx_type_7sklearn_5earth_8_forward_ForwardPasser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_8_forward_ForwardPasser = &__pyx_type_7sklearn_5earth_8_forward_ForwardPasser; + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = __Pyx_ImportType("sklearn.earth._basis", "BasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "ConstantBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "HingeBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "LinearBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_Basis = __Pyx_ImportType("sklearn.earth._basis", "Basis", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_Basis), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_Basis)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_Basis = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_Basis->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_Basis)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_Record = __Pyx_ImportType("sklearn.earth._record", "Record", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_Record), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_Record)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_Record = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_Record->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_Record)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord = __Pyx_ImportType("sklearn.earth._record", "PruningPassRecord", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord = __Pyx_ImportType("sklearn.earth._record", "ForwardPassRecord", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_Iteration = __Pyx_ImportType("sklearn.earth._record", "Iteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_Iteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_Iteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_Iteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_Iteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_Iteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration = __Pyx_ImportType("sklearn.earth._record", "PruningPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration = __Pyx_ImportType("sklearn.earth._record", "FirstPruningPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration = __Pyx_ImportType("sklearn.earth._record", "ForwardPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration = __Pyx_ImportType("sklearn.earth._record", "FirstForwardPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + __pyx_t_1 = __Pyx_ImportModule("sklearn.earth._util"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "log2", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_log2, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_FLOAT_t)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "apply_weights_slice", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_apply_weights_slice, "PyObject *(PyArrayObject *, PyArrayObject *, __pyx_t_7sklearn_5earth_5_util_INDEX_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "apply_weights_1d", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_apply_weights_1d, "PyObject *(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "gcv_adjust", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_gcv_adjust, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; + /*--- Execution code ---*/ + + /* "sklearn/earth/_forward.pyx":12 + * + * from libc.math cimport sqrt, abs, log + * import numpy as np # <<<<<<<<<<<<<< + * cnp.import_array() + * + */ + __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s__np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":13 + * from libc.math cimport sqrt, abs, log + * import numpy as np + * cnp.import_array() # <<<<<<<<<<<<<< + * + * stopping_conditions = { + */ + import_array(); + + /* "sklearn/earth/_forward.pyx":15 + * cnp.import_array() + * + * stopping_conditions = { # <<<<<<<<<<<<<< + * MAXTERMS: "Reached maximum number of terms", + * MAXRSQ: "Achieved RSQ value within threshold of 1", + */ + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + + /* "sklearn/earth/_forward.pyx":16 + * + * stopping_conditions = { + * MAXTERMS: "Reached maximum number of terms", # <<<<<<<<<<<<<< + * MAXRSQ: "Achieved RSQ value within threshold of 1", + * NOIMPRV: "Improvement below threshold", + */ + __pyx_t_3 = PyInt_FromLong(__pyx_e_7sklearn_5earth_8_forward_MAXTERMS); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_kp_s_38)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":17 + * stopping_conditions = { + * MAXTERMS: "Reached maximum number of terms", + * MAXRSQ: "Achieved RSQ value within threshold of 1", # <<<<<<<<<<<<<< + * NOIMPRV: "Improvement below threshold", + * LOWGRSQ: "GRSQ too low", + */ + __pyx_t_3 = PyInt_FromLong(__pyx_e_7sklearn_5earth_8_forward_MAXRSQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_kp_s_39)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":18 + * MAXTERMS: "Reached maximum number of terms", + * MAXRSQ: "Achieved RSQ value within threshold of 1", + * NOIMPRV: "Improvement below threshold", # <<<<<<<<<<<<<< + * LOWGRSQ: "GRSQ too low", + * NOCAND: "No remaining candidate knot locations" + */ + __pyx_t_3 = PyInt_FromLong(__pyx_e_7sklearn_5earth_8_forward_NOIMPRV); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_kp_s_40)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":19 + * MAXRSQ: "Achieved RSQ value within threshold of 1", + * NOIMPRV: "Improvement below threshold", + * LOWGRSQ: "GRSQ too low", # <<<<<<<<<<<<<< + * NOCAND: "No remaining candidate knot locations" + * } + */ + __pyx_t_3 = PyInt_FromLong(__pyx_e_7sklearn_5earth_8_forward_LOWGRSQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_kp_s_41)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "sklearn/earth/_forward.pyx":20 + * NOIMPRV: "Improvement below threshold", + * LOWGRSQ: "GRSQ too low", + * NOCAND: "No remaining candidate knot locations" # <<<<<<<<<<<<<< + * } + * + */ + __pyx_t_3 = PyInt_FromLong(__pyx_e_7sklearn_5earth_8_forward_NOCAND); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_kp_s_42)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XGOTREF(((PyObject *)__pyx_v_7sklearn_5earth_8_forward_stopping_conditions)); + __Pyx_DECREF_SET(__pyx_v_7sklearn_5earth_8_forward_stopping_conditions, ((PyObject*)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = 0; + + /* "sklearn/earth/_forward.pyx":1 + * # distutils: language = c # <<<<<<<<<<<<<< + * # cython: cdivision = True + * # cython: boundscheck = False + */ + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + + /* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + if (__pyx_m) { + __Pyx_AddTraceback("init sklearn.earth._forward", __pyx_clineno, __pyx_lineno, __pyx_filename); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init sklearn.earth._forward"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* Runtime support code */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%s() got an unexpected keyword argument '%s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) /* First char was not a digit */ + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; /* Consume from buffer string */ + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; /* breaks both loops as ctx->enc_count == 0 */ + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; /* empty struct */ + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + if (isspace(*ts)) + continue; + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case 10: + case 13: + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': /* substruct */ + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': /* end of substruct; either repeat or move on */ + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } /* fall through */ + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 's': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + } else { + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + } + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON + result = PyDict_GetItem(__pyx_d, name); + if (result) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + int r; + if (!j) return -1; + r = PyObject_SetItem(o, j, v); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); + if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { + PyObject* old = PyList_GET_ITEM(o, n); + Py_INCREF(v); + PyList_SET_ITEM(o, n, v); + Py_DECREF(old); + return 1; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_ass_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return -1; + } + } + return m->sq_ass_item(o, i, v); + } + } +#else +#if CYTHON_COMPILING_IN_PYPY + if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) { +#else + if (is_list || PySequence_Check(o)) { +#endif + return PySequence_SetItem(o, i, v); + } +#endif + return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); +} + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + #if PY_VERSION_HEX < 0x02050000 + if (PyClass_Check(type)) { + #else + if (PyType_Check(type)) { + #endif +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + #if PY_VERSION_HEX < 0x02050000 + if (PyInstance_Check(type)) { + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + Py_INCREF(type); + } else { + type = 0; + PyErr_SetString(PyExc_TypeError, + "raise: exception must be an old-style class or instance"); + goto raise_error; + } + #else + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + #endif + } + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else /* Python 3+ */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return NULL; + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +static void __Pyx_RaiseBufferFallbackError(void) { + PyErr_Format(PyExc_ValueError, + "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); +} + +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +} + +static CYTHON_INLINE int __Pyx_PyObject_SetSlice( + PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, + int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { +#if CYTHON_COMPILING_IN_CPYTHON + PyMappingMethods* mp; +#if PY_MAJOR_VERSION < 3 + PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; + if (likely(ms && ms->sq_ass_slice)) { + if (!has_cstart) { + if (_py_start && (*_py_start != Py_None)) { + cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); + if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstart = 0; + } + if (!has_cstop) { + if (_py_stop && (*_py_stop != Py_None)) { + cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); + if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstop = PY_SSIZE_T_MAX; + } + if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { + Py_ssize_t l = ms->sq_length(obj); + if (likely(l >= 0)) { + if (cstop < 0) { + cstop += l; + if (cstop < 0) cstop = 0; + } + if (cstart < 0) { + cstart += l; + if (cstart < 0) cstart = 0; + } + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + goto bad; + } + } + return ms->sq_ass_slice(obj, cstart, cstop, value); + } +#endif + mp = Py_TYPE(obj)->tp_as_mapping; + if (likely(mp && mp->mp_ass_subscript)) +#endif + { + int result; + PyObject *py_slice, *py_start, *py_stop; + if (_py_slice) { + py_slice = *_py_slice; + } else { + PyObject* owned_start = NULL; + PyObject* owned_stop = NULL; + if (_py_start) { + py_start = *_py_start; + } else { + if (has_cstart) { + owned_start = py_start = PyInt_FromSsize_t(cstart); + if (unlikely(!py_start)) goto bad; + } else + py_start = Py_None; + } + if (_py_stop) { + py_stop = *_py_stop; + } else { + if (has_cstop) { + owned_stop = py_stop = PyInt_FromSsize_t(cstop); + if (unlikely(!py_stop)) { + Py_XDECREF(owned_start); + goto bad; + } + } else + py_stop = Py_None; + } + py_slice = PySlice_New(py_start, py_stop, Py_None); + Py_XDECREF(owned_start); + Py_XDECREF(owned_stop); + if (unlikely(!py_slice)) goto bad; + } +#if CYTHON_COMPILING_IN_CPYTHON + result = mp->mp_ass_subscript(obj, py_slice, value); +#else + result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice); +#endif + if (!_py_slice) { + Py_DECREF(py_slice); + } + return result; + } + PyErr_Format(PyExc_TypeError, + "'%.200s' object does not support slice %s", + Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion"); +bad: + return -1; +} + +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); +} + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + index, (index == 1) ? "" : "s"); +} + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s____pyx_vtable__, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +static void* __Pyx_GetVtable(PyObject *dict) { + void* ptr; + PyObject *ob = PyObject_GetItem(dict, __pyx_n_s____pyx_vtable__); + if (!ob) + goto bad; +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + ptr = PyCapsule_GetPointer(ob, 0); +#else + ptr = PyCObject_AsVoidPtr(ob); +#endif + if (!ptr && !PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); + Py_DECREF(ob); + return ptr; +bad: + Py_XDECREF(ob); + return NULL; +} + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + #if PY_VERSION_HEX >= 0x02050000 + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; /* try absolute import on failure */ + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } + #else + if (level>0) { + PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); + goto bad; + } + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, NULL); + #endif +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *getbuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_getbuffer); + if (getbuffer_cobj) { + getbufferproc func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj); + Py_DECREF(getbuffer_cobj); + if (!func) + goto fail; + return func(obj, view, flags); + } else { + PyErr_Clear(); + } + } + #endif + PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *releasebuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_releasebuffer); + if (releasebuffer_cobj) { + releasebufferproc func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj); + Py_DECREF(releasebuffer_cobj); + if (!func) + goto fail; + func(obj, view); + return; + } else { + PyErr_Clear(); + } + } + #endif + goto nofail; +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + PyErr_WriteUnraisable(obj); +nofail: + Py_DECREF(obj); + view->obj = NULL; +} +#endif /* PY_MAJOR_VERSION < 3 */ + + + static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject* x) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if (sizeof(npy_ulonglong) == sizeof(char)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedChar(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedChar(x); + } else if (sizeof(npy_ulonglong) == sizeof(short)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedShort(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedShort(x); + } else if (sizeof(npy_ulonglong) == sizeof(int)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedInt(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedInt(x); + } else if (sizeof(npy_ulonglong) == sizeof(long)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLong(x); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLongLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLongLong(x); + } else { + #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); + #else + npy_ulonglong val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } + #endif + return (npy_ulonglong)-1; + } +} + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong val) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(npy_ulonglong) == sizeof(char)) || + (sizeof(npy_ulonglong) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(npy_ulonglong) == sizeof(int)) || + (sizeof(npy_ulonglong) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); + else + return PyLong_FromLongLong((PY_LONG_LONG)val); + } else { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + return _PyLong_FromByteArray(bytes, sizeof(npy_ulonglong), + little, !is_unsigned); + } +} + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { + const unsigned char neg_one = (unsigned char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned char" : + "value too large to convert to unsigned char"); + } + return (unsigned char)-1; + } + return (unsigned char)val; + } + return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { + const unsigned short neg_one = (unsigned short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned short" : + "value too large to convert to unsigned short"); + } + return (unsigned short)-1; + } + return (unsigned short)val; + } + return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { + const unsigned int neg_one = (unsigned int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned int" : + "value too large to convert to unsigned int"); + } + return (unsigned int)-1; + } + return (unsigned int)val; + } + return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { + const char neg_one = (char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to char" : + "value too large to convert to char"); + } + return (char)-1; + } + return (char)val; + } + return (char)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { + const short neg_one = (short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to short" : + "value too large to convert to short"); + } + return (short)-1; + } + return (short)val; + } + return (short)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { + const signed char neg_one = (signed char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed char" : + "value too large to convert to signed char"); + } + return (signed char)-1; + } + return (signed char)val; + } + return (signed char)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { + const signed short neg_one = (signed short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed short" : + "value too large to convert to signed short"); + } + return (signed short)-1; + } + return (signed short)val; + } + return (signed short)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { + const signed int neg_one = (signed int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed int" : + "value too large to convert to signed int"); + } + return (signed int)-1; + } + return (signed int)val; + } + return (signed int)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { + const unsigned long neg_one = (unsigned long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned long)PyLong_AsLong(x); + } + } else { + unsigned long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned long)-1; + val = __Pyx_PyInt_AsUnsignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { + const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + unsigned PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsUnsignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { + const long neg_one = (long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (long)PyLong_AsLong(x); + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (long)-1; + val = __Pyx_PyInt_AsLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { + const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { + const signed long neg_one = (signed long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed long)PyLong_AsLong(x); + } + } else { + signed long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed long)-1; + val = __Pyx_PyInt_AsSignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { + const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + signed PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsSignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + #if PY_VERSION_HEX < 0x02050000 + return PyErr_Warn(NULL, message); + #else + return PyErr_WarnEx(NULL, message, 1); + #endif + } + return 0; +} + +static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) { + PyObject *d; + PyObject *cobj = 0; + d = PyDict_GetItem(__pyx_d, __pyx_n_s____pyx_capi__); + Py_XINCREF(d); + if (!d) { + d = PyDict_New(); + if (!d) + goto bad; + if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s____pyx_capi__, d) < 0) + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) + cobj = PyCapsule_New(p, sig, 0); +#else + cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0); +#endif + if (!cobj) + goto bad; + if (PyDict_SetItem(d, name, cobj) < 0) + goto bad; + Py_DECREF(cobj); + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(cobj); + Py_XDECREF(d); + return -1; +} + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility", + module_name, class_name); + #if PY_VERSION_HEX < 0x02050000 + if (PyErr_Warn(NULL, warning) < 0) goto bad; + #else + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + #endif + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s has the wrong size, try recompiling", + module_name, class_name); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportFunction +#define __PYX_HAVE_RT_ImportFunction +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, funcname); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%s does not export expected C function %s", + PyModule_GetName(module), funcname); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); + goto bad; + } + tmp.p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, desc); + goto bad; + } + tmp.p = PyCObject_AsVoidPtr(cobj);} +#endif + *f = tmp.fp; + if (!(*f)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = (start + end) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, /*int firstlineno,*/ + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_globals = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else /* Python 3+ has unicode identifiers */ + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else /* PY_VERSION_HEX < 0x03030000 */ + if (PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_DATA_SIZE(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ + return PyUnicode_AsUTF8AndSize(o, length); +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ +#endif /* PY_VERSION_HEX < 0x03030000 */ + } else +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (r < 0) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return Py_INCREF(x), x; + m = Py_TYPE(x)->tp_as_number; +#if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%s__ returned non-%s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject* x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { +#if PY_VERSION_HEX < 0x02050000 + if (ival <= LONG_MAX) + return PyInt_FromLong((long)ival); + else { + unsigned char *bytes = (unsigned char *) &ival; + int one = 1; int little = (int)*(unsigned char*)&one; + return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); + } +#else + return PyInt_FromSize_t(ival); +#endif +} +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { + unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); + if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t)-1; + } + return (size_t)val; +} + + +#endif /* Py_PYTHON_H */ diff --git a/sklearn/earth/_forward.pxd b/sklearn/earth/_forward.pxd new file mode 100644 index 0000000000000..bbb6edd56db86 --- /dev/null +++ b/sklearn/earth/_forward.pxd @@ -0,0 +1,78 @@ +cimport numpy as cnp +import numpy as np +ctypedef cnp.float64_t FLOAT_t +ctypedef cnp.intp_t INT_t +ctypedef cnp.ulong_t INDEX_t +ctypedef cnp.uint8_t BOOL_t +from _basis cimport Basis +from _record cimport ForwardPassRecord + +ctypedef enum StoppingCondition: + MAXTERMS = 0, + MAXRSQ = 1, + NOIMPRV = 2, + LOWGRSQ = 3, + NOCAND = 4 + +cdef dict stopping_conditions + +cdef class ForwardPasser: + + # User selected parameters + cdef int endspan + cdef int minspan + cdef FLOAT_t endspan_alpha + cdef FLOAT_t minspan_alpha + cdef int max_terms + cdef bint allow_linear + cdef int max_degree + cdef FLOAT_t thresh + cdef FLOAT_t penalty + cdef int check_every + cdef int min_search_points + cdef list xlabels + cdef FLOAT_t zero_tol + + # Input data + cdef cnp.ndarray X + cdef cnp.ndarray y + cdef cnp.ndarray sample_weight + cdef INDEX_t m + cdef INDEX_t n + cdef FLOAT_t sst + cdef FLOAT_t y_squared + + # Working floating point data + cdef cnp.ndarray B # Data matrix in basis space + cdef cnp.ndarray B_orth # Orthogonalized version of B + cdef cnp.ndarray c + cdef cnp.ndarray norms + cdef cnp.ndarray u + cdef cnp.ndarray B_orth_times_parent_cum + cdef FLOAT_t c_squared + + # Working integer data + cdef cnp.ndarray sort_tracker + cdef cnp.ndarray sorting + cdef cnp.ndarray mwork + cdef cnp.ndarray linear_variables + + # Object construction + cdef ForwardPassRecord record + cdef Basis basis + + cpdef Basis get_basis(ForwardPasser self) + + cpdef init_linear_variables(ForwardPasser self) + + cpdef run(ForwardPasser self) + + cdef stop_check(ForwardPasser self) + + cpdef int orthonormal_update(ForwardPasser self, INDEX_t k) + + cpdef orthonormal_downdate(ForwardPasser self, INDEX_t k) + + cdef next_pair(ForwardPasser self) + + cdef best_knot(ForwardPasser self, INDEX_t parent, INDEX_t variable, INDEX_t k, cnp.ndarray[INT_t, ndim=1] candidates, cnp.ndarray[INT_t, ndim=1] order, FLOAT_t * mse, FLOAT_t * knot, INDEX_t * knot_idx) diff --git a/sklearn/earth/_forward.pyx b/sklearn/earth/_forward.pyx new file mode 100644 index 0000000000000..a22f0d542cd53 --- /dev/null +++ b/sklearn/earth/_forward.pyx @@ -0,0 +1,616 @@ +# distutils: language = c +# cython: cdivision = True +# cython: boundscheck = False +# cython: wraparound = False +# cython: profile = False + +from ._util cimport gcv_adjust, log2, apply_weights_1d, apply_weights_slice +from ._basis cimport Basis, BasisFunction, ConstantBasisFunction, HingeBasisFunction, LinearBasisFunction +from ._record cimport ForwardPassIteration + +from libc.math cimport sqrt, abs, log +import numpy as np +cnp.import_array() + +stopping_conditions = { + MAXTERMS: "Reached maximum number of terms", + MAXRSQ: "Achieved RSQ value within threshold of 1", + NOIMPRV: "Improvement below threshold", + LOWGRSQ: "GRSQ too low", + NOCAND: "No remaining candidate knot locations" +} + +cdef class ForwardPasser: + + def __init__(ForwardPasser self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] sample_weight, **kwargs): + cdef INDEX_t i + self.X = X + self.y = y.copy() + self.sample_weight = sample_weight + apply_weights_1d(self.y, self.sample_weight) + self.m = self.X.shape[0] + self.n = self.X.shape[1] + self.endspan = kwargs['endspan'] if 'endspan' in kwargs else -1 + self.minspan = kwargs['minspan'] if 'minspan' in kwargs else -1 + self.endspan_alpha = kwargs[ + 'endspan_alpha'] if 'endspan_alpha' in kwargs else .05 + self.minspan_alpha = kwargs[ + 'minspan_alpha'] if 'minspan_alpha' in kwargs else .05 + self.max_terms = kwargs[ + 'max_terms'] if 'max_terms' in kwargs else 2 * self.n + 10 + self.allow_linear = kwargs['allow_linear'] if 'allow_linear' in kwargs else True + self.max_degree = kwargs['max_degree'] if 'max_degree' in kwargs else 1 + self.thresh = kwargs['thresh'] if 'thresh' in kwargs else 0.001 + self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + self.check_every = kwargs[ + 'check_every'] if 'check_every' in kwargs else -1 + self.min_search_points = kwargs[ + 'min_search_points'] if 'min_search_points' in kwargs else 100 + self.xlabels = kwargs['xlabels'] if 'xlabels' in kwargs else None + if self.xlabels is None: + self.xlabels = ['x' + str(i) for i in range(self.n)] + if self.check_every < 0: + self.check_every = (self.m / self.min_search_points) if self.m > self.min_search_points else 1 + self.sst = (np.dot(self.y, self.y) - + (np.dot(np.sqrt(self.sample_weight), self.y) / np.sqrt(np.sum(self.sample_weight))) ** 2) / self.m + self.y_squared = np.dot(self.y, self.y) + self.record = ForwardPassRecord( + self.m, self.n, self.penalty, self.sst, self.xlabels) + self.basis = Basis(self.n) + self.basis.append(ConstantBasisFunction()) + + self.sorting = np.empty(shape=self.m, dtype=np.int) + self.mwork = np.empty(shape=self.m, dtype=np.int) + self.u = np.empty(shape=self.max_terms, dtype=float) + self.B_orth_times_parent_cum = np.empty( + shape=self.max_terms, dtype=np.float) + self.B = np.ones( + shape=(self.m, self.max_terms), order='C', dtype=np.float) + self.basis.weighted_transform(self.X, self.B[:,0:1], self.sample_weight) + # An orthogonal matrix with the same column space as B + self.B_orth = self.B.copy() + self.u = np.empty(shape=self.max_terms, dtype=np.float) + self.c = np.empty(shape=self.max_terms, dtype=np.float) + self.norms = np.empty(shape=self.max_terms, dtype=np.float) + self.c_squared = 0.0 + self.sort_tracker = np.empty(shape=self.m, dtype=np.int) + for i in range(self.m): + self.sort_tracker[i] = i + self.zero_tol = 1e-6 + + self.linear_variables = np.zeros(shape=self.n, dtype=np.int) + self.init_linear_variables() + + # Add in user selected linear variables + if 'linvars' in kwargs: + for linvar in kwargs['linvars']: + if linvar in self.xlabels: + self.linear_variables[self.xlabels.index(linvar)] = 1 + elif linvar in range(self.n): + self.linear_variables[linvar] = 1 + else: + raise IndexError( + 'Unknown variable selected in linvars argument.') + + # Initialize B_orth, c, and c_squared (assuming column 0 of B_orth is + # already filled with 1) + self.orthonormal_update(0) + + cpdef Basis get_basis(ForwardPasser self): + return self.basis + + cpdef init_linear_variables(ForwardPasser self): + cdef INDEX_t variable + cdef INDEX_t endspan + cdef cnp.ndarray[INT_t, ndim = 1] order + cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + if self.endspan < 0: + endspan = round(3 - log2(self.endspan_alpha / self.n)) + else: + endspan = self.endspan + cdef ConstantBasisFunction root_basis_function = self.basis[0] + for variable in range(self.n): + order = np.argsort(X[:, variable])[::-1] + if root_basis_function.valid_knots(B[order, 0], X[order, variable], + variable, self.check_every, endspan, + self.minspan, self.minspan_alpha, + self.n, self.mwork).shape[0] == 0: + linear_variables[variable] = 1 + else: + linear_variables[variable] = 0 + + def get_B_orth(ForwardPasser self): + return self.B_orth + + cpdef run(ForwardPasser self): + cdef INDEX_t i + while True: + self.next_pair() + if self.stop_check(): + break + + cdef stop_check(ForwardPasser self): + last = self.record.__len__() - 1 + if self.record.iterations[last].get_size() + 2 > self.max_terms: + self.record.stopping_condition = MAXTERMS + return True + rsq = self.record.rsq(last) + if rsq > 1 - self.thresh: + self.record.stopping_condition = MAXRSQ + return True + previous_rsq = self.record.rsq(last - 1) + if rsq - previous_rsq < self.thresh: + self.record.stopping_condition = NOIMPRV + return True + if self.record.grsq(last) < -10: + self.record.stopping_condition = LOWGRSQ + return True + if self.record.iterations[last].no_further_candidates(): + self.record.stopping_condition = NOCAND + return True + return False + + cpdef int orthonormal_update(ForwardPasser self, INDEX_t k): + '''Orthogonalize and normalize column k of B_orth against all previous columns of B_orth.''' + # Currently implemented using modified Gram-Schmidt process + # TODO: Optimize - replace some for loops with calls to blas + + cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + cdef cnp.ndarray[FLOAT_t, ndim = 1] norms = self.norms + + cdef INDEX_t i + cdef INDEX_t j + cdef FLOAT_t nrm + cdef FLOAT_t nrm0 + cdef FLOAT_t dot_prod + + # Get the original norm + nrm0 = 0.0 + for i in range(self.m): + nrm0 += B_orth[i, k] * B_orth[i, k] + nrm0 = sqrt(nrm0) + + # Orthogonalize + if k > 0: + for i in range(k): + dot_prod = 0.0 + for j in range(self.m): + dot_prod += B_orth[j, k] * B_orth[j, i] + for j in range(self.m): + B_orth[j, k] -= B_orth[j, i] * dot_prod + + # Normalize + nrm = 0.0 + for i in range(self.m): + nrm += B_orth[i, k] * B_orth[i, k] + nrm = sqrt(nrm) + norms[k] = nrm + + if nrm0 <= self.zero_tol or nrm / nrm0 <= self.zero_tol: + for i in range(self.m): + B_orth[i, k] = 0.0 + c[k] = 0.0 + # The new column is in the column space of the previous columns + return 1 + for i in range(self.m): + B_orth[i, k] /= nrm + + # Update c + c[k] = 0.0 + for i in range(self.m): + c[k] += B_orth[i, k] * y[i] + self.c_squared += c[k] ** 2 + + return 0 # No problems + + cpdef orthonormal_downdate(ForwardPasser self, INDEX_t k): + ''' + Undo the effects of the last orthonormal update. You can only undo the last orthonormal update this way. + There will be no warning of any kind if you mess this up. You'll just get wrong answers. + In reality, all this does is downdate c_squared (the elements of c and B_orth are left alone, since they + can simply be ignored until they are overwritten). + ''' + self.c_squared -= self.c[k] ** 2 + + def trace(self): + return self.record + + cdef next_pair(ForwardPasser self): + cdef INDEX_t variable + cdef INDEX_t parent_idx + cdef INDEX_t parent_degree + cdef INDEX_t nonzero_count + cdef BasisFunction parent + cdef cnp.ndarray[INT_t, ndim = 1] candidates_idx + cdef FLOAT_t knot + cdef FLOAT_t mse + cdef INDEX_t knot_idx + cdef FLOAT_t knot_choice + cdef FLOAT_t mse_choice + cdef int knot_idx_choice + cdef INDEX_t parent_idx_choice + cdef BasisFunction parent_choice + cdef INDEX_t variable_choice + cdef bint first = True + cdef BasisFunction bf1 + cdef BasisFunction bf2 + cdef INDEX_t k = len(self.basis) + cdef INDEX_t endspan + cdef bint linear_dependence + cdef bint dependent + cdef FLOAT_t gcv_factor_k_plus_1 = gcv_adjust(k + 1, self.m, self.penalty) + cdef FLOAT_t gcv_factor_k_plus_2 = gcv_adjust(k + 2, self.m, self.penalty) + cdef FLOAT_t gcv_ + cdef FLOAT_t mse_ + cdef INDEX_t i + + cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + cdef cnp.ndarray[INT_t, ndim = 1] linear_variables = self.linear_variables + cdef cnp.ndarray[INT_t, ndim = 1] sorting = self.sorting + cdef cnp.ndarray[FLOAT_t, ndim = 1] sample_weight = self.sample_weight + + if self.endspan < 0: + endspan = round(3 - log2(self.endspan_alpha / self.n)) + else: + endspan = self.endspan + + # Iterate over variables + for variable in range(self.n): + + # Sort the data + # TODO: eliminate Python call / data copy + sorting[:] = np.argsort(X[:, variable])[::-1] + + # Iterate over parents + for parent_idx in range(k): + linear_dependence = False + + parent = self.basis.get(parent_idx) + if self.max_degree >= 0: + parent_degree = parent.degree() + if parent_degree >= self.max_degree: + continue + if not parent.is_splittable(): + continue + + # Add the linear term to B + for i in range(self.m): + B[i, k] = B[i, parent_idx] * X[i, variable] + + # Orthonormalize + for i in range(self.m): + B_orth[i, k] = B[i, k] + linear_dependence = self.orthonormal_update(k) + + # If a new hinge function does not improve the gcv over the linear term + # then just the linear term will be retained (if allow_linear). Calculate the + # gcv with just the linear term in order to compare later. Note that the mse + # with another term never increases, but the gcv may because it penalizes + # additional terms. + mse_ = (self.y_squared - self.c_squared) / self.m + gcv_ = gcv_factor_k_plus_1 * \ + (self.y_squared - self.c_squared) / self.m + + if linear_variables[variable]: + mse = mse_ + knot_idx = -1 + else: + + # Find the valid knot candidates + candidates_idx = parent.valid_knots(B[sorting, parent_idx], X[ + sorting, variable], variable, self.check_every, endspan, self.minspan, self.minspan_alpha, self.n, self.mwork) + + if len(candidates_idx) > 0: + # Choose the best candidate (if no candidate is an + # improvement on the linear term in terms of gcv, knot_idx + # is set to -1 + + # Find the best knot location for this parent and + # variable combination + self.best_knot(parent_idx, variable, k, candidates_idx, sorting, & mse, & knot, & knot_idx) + + # If the hinge function does not decrease the gcv then + # just keep the linear term (if allow_linear is True) + if self.allow_linear and (gcv_factor_k_plus_2 * mse >= gcv_): + mse = mse_ + knot_idx = -1 + + else: + # Do an orthonormal downdate and skip to the next + # iteration + self.orthonormal_downdate(k) + continue + + # Do an orthonormal downdate + self.orthonormal_downdate(k) + + # Update the choices + if first: + knot_choice = knot + mse_choice = mse + knot_idx_choice = knot_idx + parent_idx_choice = parent_idx + parent_choice = parent + variable_choice = variable + first = False + dependent = linear_dependence + if mse < mse_choice: + knot_choice = knot + mse_choice = mse + knot_idx_choice = knot_idx + parent_idx_choice = parent_idx + parent_choice = parent + variable_choice = variable + dependent = linear_dependence + + # Make sure at least one candidate was checked + if first: + self.record[len(self.record) - 1].set_no_candidates(True) + return + + # Add the new basis functions + parent = self.basis.get(parent_idx) + label = self.xlabels[variable_choice] + if knot_idx_choice != -1: + # Add the new basis functions + bf1 = HingeBasisFunction( + parent_choice, knot_choice, knot_idx_choice, variable_choice, False, label) + bf2 = HingeBasisFunction( + parent_choice, knot_choice, knot_idx_choice, variable_choice, True, label) + bf1.apply(X, B[:, k]) + apply_weights_slice(B, sample_weight, k) + bf2.apply(X, B[:, k + 1]) + apply_weights_slice(B, sample_weight, k + 1) + self.basis.append(bf1) + self.basis.append(bf2) + + # Orthogonalize the new basis + B_orth[:, k] = B[:, k] + if self.orthonormal_update(k) == 1: + bf1.make_unsplittable() + B_orth[:, k + 1] = B[:, k + 1] + if self.orthonormal_update(k + 1) == 1: + bf2.make_unsplittable() + elif not dependent and knot_idx_choice == -1: + # In this case, only add the linear basis function + bf1 = LinearBasisFunction(parent_choice, variable_choice, label) + bf1.apply(X, B[:, k]) + apply_weights_slice(B, sample_weight, k) + self.basis.append(bf1) + + # Orthogonalize the new basis + B_orth[:, k] = B[:, k] + if self.orthonormal_update(k) == 1: + bf1.make_unsplittable() + else: # dependent and knot_idx_choice == -1 + # In this case there were no acceptable choices remaining, so end + # the forward pass + self.record[len(self.record) - 1].set_no_candidates(True) + return + + # Update the build record + self.record.append(ForwardPassIteration( + parent_idx_choice, variable_choice, knot_idx_choice, mse_choice, len(self.basis))) + + cdef best_knot(ForwardPasser self, INDEX_t parent, INDEX_t variable, INDEX_t k, cnp.ndarray[INT_t, ndim=1] candidates, cnp.ndarray[INT_t, ndim=1] order, FLOAT_t * mse, FLOAT_t * knot, INDEX_t * knot_idx): + ''' + Find the best knot location (in terms of squared error). + + Assumes: + B[:,k] is the linear term for variable + X[:,variable] is in decreasing order + candidates is in increasing order (it is an array of indices into X[:,variable] + mse is a pointer to the mean squared error of including just the linear term in B[:,k] + ''' + + cdef cnp.ndarray[FLOAT_t, ndim = 1] b = self.B[:, k + 1] + cdef cnp.ndarray[FLOAT_t, ndim = 1] b_parent = self.B[:, parent] + cdef cnp.ndarray[FLOAT_t, ndim = 1] u = self.u + cdef cnp.ndarray[FLOAT_t, ndim = 2] B_orth = self.B_orth + cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + cdef cnp.ndarray[FLOAT_t, ndim = 1] c = self.c + cdef cnp.ndarray[FLOAT_t, ndim = 1] B_orth_times_parent_cum = self.B_orth_times_parent_cum + cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + + cdef INDEX_t num_candidates = candidates.shape[0] + + cdef INDEX_t h + cdef INDEX_t i + cdef INDEX_t j + cdef INDEX_t h_ + cdef INDEX_t i_ + cdef INDEX_t j_ + cdef FLOAT_t u_end + cdef FLOAT_t c_end + cdef FLOAT_t z_end_squared + cdef INDEX_t candidate_idx + cdef INDEX_t last_candidate_idx + cdef INDEX_t last_last_candidate_idx + cdef INDEX_t best_candidate_idx + cdef FLOAT_t candidate + cdef FLOAT_t last_candidate + cdef FLOAT_t best_candidate + cdef FLOAT_t best_z_end_squared + cdef FLOAT_t y_cum + cdef FLOAT_t b_times_parent_cum + cdef FLOAT_t diff + cdef FLOAT_t delta_b_squared + cdef FLOAT_t delta_c_end + cdef FLOAT_t delta_u_end + cdef FLOAT_t parent_squared_cum + cdef FLOAT_t parent_times_y_cum + cdef FLOAT_t u_dot_c + cdef FLOAT_t u_dot_u + cdef FLOAT_t float_tmp + cdef FLOAT_t delta_b_j + cdef FLOAT_t z_denom + + # Compute the initial basis function + candidate_idx = candidates[0] + candidate = X[order[candidate_idx], variable] + for i in range(self.m): # TODO: Vectorize? + b[i] = 0 + for i_ in range(self.m): + i = order[i_] + float_tmp = X[i, variable] - candidate + if float_tmp > 0: + b[i] = b_parent[i] * float_tmp + else: + break + + # Compute the initial covariance column, u (not including the final + # element) + u[0:k + 1] = np.dot(b, B_orth[:, 0:k + 1]) + + # Compute the new last elements of c and u + c_end = 0.0 + u_end = 0.0 + for i in range(self.m): + u_end += b[i] * b[i] + c_end += b[i] * y[i] + + # Compute the last element of z (the others are identical to c) + u_dot_c = 0.0 + u_dot_u = 0.0 + for i in range(k + 1): + u_dot_u += u[i] * u[i] + u_dot_c += u[i] * c[i] + z_denom = u_end - u_dot_u + if z_denom <= self.zero_tol: + z_end_squared = np.nan + else: + z_end_squared = ((c_end - u_dot_c) ** 2) / z_denom + + # Minimizing the norm is actually equivalent to maximizing z_end_squared + # Store z_end_squared and the current candidate as the best knot choice + best_z_end_squared = z_end_squared + best_candidate_idx = candidate_idx + best_candidate = candidate + + # Initialize the accumulators + i = order[0] + last_candidate_idx = 0 + y_cum = y[i] + B_orth_times_parent_cum[0:k + 1] = B_orth[i, 0:k + 1] * b_parent[i] + b_times_parent_cum = b[i] * b_parent[i] + parent_squared_cum = b_parent[i] ** 2 + parent_times_y_cum = b_parent[i] * y[i] + + # Now loop over the remaining candidates and update z_end_squared for + # each, looking for the greatest value + for i_ in range(1, num_candidates): + i = order[i_] + + # Update the candidate + last_last_candidate_idx = last_candidate_idx + last_candidate_idx = candidate_idx + last_candidate = candidate + candidate_idx = candidates[i_] + candidate = X[order[candidate_idx], variable] + + # Update the accumulators and compute delta_b + diff = last_candidate - candidate + delta_c_end = 0.0 + + # What follows is a section of code that has been optimized for speed at the expense of + # some readability. To make it easier to understand this code in the future, I have included a + #"simple" block that implements the same math in a more straightforward (but much less efficient) + # way. The (commented out) code between "BEGIN SIMPLE" and "END SIMPLE" should produce the same + # output as the code between "BEGIN HYPER-OPTIMIZED" and "END + # HYPER-OPTIMIZED". + + # BEGIN SIMPLE +# Calculate delta_b +# for j in range(0,last_candidate_idx+1): +# delta_b[j] = diff +# for j in range(last_candidate_idx+1,candidate_idx): +# float_tmp = (X[j,variable] - candidate) * b_parent[j] +# delta_b[j] = float_tmp +# +# Update u and z_end_squared +# u[0:k+1] += np.dot(delta_b,B_orth[:,0:k+1]) +# u_end += 2*np.dot(delta_b,b) + np.dot(delta_b, delta_b) +# +# Update c_end +# c_end += np.dot(delta_b,y) +# +# Update z_end_squared +# z_end_squared = ((c_end - np.dot(u[0:k+1],c[0:k+1]))**2) / (u_end) +# +# Update b +# b += delta_b + # END SIMPLE + + # BEGIN HYPER-OPTIMIZED + delta_b_squared = 0.0 + delta_c_end = 0.0 + delta_u_end = 0.0 + + # Update the accumulators + for j_ in range(last_last_candidate_idx + 1, last_candidate_idx + 1): + j = order[j_] + y_cum += y[j] + for h in range(k + 1): # TODO: BLAS + B_orth_times_parent_cum[h] += B_orth[j, h] * b_parent[j] + b_times_parent_cum += b[j] * b_parent[j] + parent_squared_cum += b_parent[j] ** 2 + parent_times_y_cum += b_parent[j] * y[j] + delta_c_end += diff * parent_times_y_cum + delta_u_end += 2 * diff * b_times_parent_cum + delta_b_squared = (diff ** 2) * parent_squared_cum + + # Update u and a bunch of other stuff + for j in range(k + 1): + float_tmp = diff * B_orth_times_parent_cum[j] + u_dot_c += float_tmp * c[j] + u_dot_u += 2 * u[j] * float_tmp + float_tmp * float_tmp + u[j] += float_tmp + for j_ in range(last_candidate_idx + 1, candidate_idx): + j = order[j_] + delta_b_j = (X[j, variable] - candidate) * b_parent[j] + delta_b_squared += delta_b_j ** 2 + delta_c_end += delta_b_j * y[j] + delta_u_end += 2 * delta_b_j * b[j] + for h in range(k + 1): + float_tmp = delta_b_j * B_orth[j, h] + u_dot_c += float_tmp * c[h] + u_dot_u += 2 * u[h] * float_tmp + float_tmp * float_tmp + u[h] += float_tmp + b[j] += delta_b_j + + # Update u_end + delta_u_end += delta_b_squared + u_end += delta_u_end + + # Update c_end + c_end += delta_c_end + + # Update b_times_parent_cum + b_times_parent_cum += parent_squared_cum * diff + + # Compute the new z_end_squared (this is the quantity we're + # optimizing) + if (u_end - u_dot_u) <= self.zero_tol: + continue + z_end_squared = ((c_end - u_dot_c) ** 2) / (u_end - u_dot_u) + # END HYPER-OPTIMIZED + + # Update the best if necessary + if z_end_squared > best_z_end_squared: + best_z_end_squared = z_end_squared + best_candidate_idx = candidate_idx + best_candidate = candidate + + # Compute the mse for the best z_end and set return values + mse[0] = ( + self.y_squared - self.c_squared - best_z_end_squared) / self.m + knot[0] = best_candidate + knot_idx[0] = best_candidate_idx diff --git a/sklearn/earth/_forward.pyxdep b/sklearn/earth/_forward.pyxdep new file mode 100644 index 0000000000000..682c8a581bbf2 --- /dev/null +++ b/sklearn/earth/_forward.pyxdep @@ -0,0 +1,3 @@ +_basis +_util +_record diff --git a/sklearn/earth/_pruning.c b/sklearn/earth/_pruning.c new file mode 100644 index 0000000000000..7b145b1d3bf80 --- /dev/null +++ b/sklearn/earth/_pruning.c @@ -0,0 +1,8877 @@ +/* Generated by Cython 0.19.2 on Sat Nov 30 16:32:13 2013 */ + +#define PY_SSIZE_T_CLEAN +#ifndef CYTHON_USE_PYLONG_INTERNALS +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 0 +#else +#include "pyconfig.h" +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 1 +#else +#define CYTHON_USE_PYLONG_INTERNALS 0 +#endif +#endif +#endif +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02040000 + #error Cython requires Python 2.4+. +#else +#include /* For offsetof */ +#ifndef offsetof +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION +#define CYTHON_COMPILING_IN_PYPY 1 +#define CYTHON_COMPILING_IN_CPYTHON 0 +#else +#define CYTHON_COMPILING_IN_PYPY 0 +#define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if PY_VERSION_HEX < 0x02050000 + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ + (PyErr_Format(PyExc_TypeError, \ + "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ + (PyObject*)0)) + #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ + !PyComplex_Check(o)) + #define PyIndex_Check __Pyx_PyIndex_Check + #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) + #define __PYX_BUILD_PY_SSIZE_T "i" +#else + #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" + #define __Pyx_PyIndex_Check PyIndex_Check +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) + #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) + #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + #define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + #define PyType_Modified(t) + typedef struct { + void *buf; + PyObject *obj; + Py_ssize_t len; + Py_ssize_t itemsize; + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; + } Py_buffer; + #define PyBUF_SIMPLE 0 + #define PyBUF_WRITABLE 0x0001 + #define PyBUF_FORMAT 0x0004 + #define PyBUF_ND 0x0008 + #define PyBUF_STRIDES (0x0010 | PyBUF_ND) + #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) + #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) + #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) + #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) + #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) + typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); + typedef void (*releasebufferproc)(PyObject *, Py_buffer *); +#endif +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif +#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 + #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") +#endif +#if PY_MAJOR_VERSION >= 3 + #define Py_TPFLAGS_CHECKTYPES 0 + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_TPFLAGS_HAVE_VERSION_TAG 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PyBytesObject PyStringObject + #define PyBytes_Type PyString_Type + #define PyBytes_Check PyString_Check + #define PyBytes_CheckExact PyString_CheckExact + #define PyBytes_FromString PyString_FromString + #define PyBytes_FromStringAndSize PyString_FromStringAndSize + #define PyBytes_FromFormat PyString_FromFormat + #define PyBytes_DecodeEscape PyString_DecodeEscape + #define PyBytes_AsString PyString_AsString + #define PyBytes_AsStringAndSize PyString_AsStringAndSize + #define PyBytes_Size PyString_Size + #define PyBytes_AS_STRING PyString_AS_STRING + #define PyBytes_GET_SIZE PyString_GET_SIZE + #define PyBytes_Repr PyString_Repr + #define PyBytes_Concat PyString_Concat + #define PyBytes_ConcatAndDel PyString_ConcatAndDel +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ + PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) + #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) + #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) + #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) +#else + #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) + #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) +#else + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_NAMESTR(n) ((char *)(n)) + #define __Pyx_DOCSTR(n) ((char *)(n)) +#else + #define __Pyx_NAMESTR(n) (n) + #define __Pyx_DOCSTR(n) (n) +#endif +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + a quiet NaN. */ + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif + + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) +#define _USE_MATH_DEFINES +#endif +#include +#define __PYX_HAVE__sklearn__earth___pruning +#define __PYX_HAVE_API__sklearn__earth___pruning +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) +#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) +#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return u_end - u - 1; +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + const char* default_encoding_c = PyBytes_AS_STRING(default_encoding); + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (ascii_chars_u == NULL) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + } + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + default_encoding_c = PyBytes_AS_STRING(default_encoding); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(sys); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +#ifdef __GNUC__ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ +#else /* __GNUC__ */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "_pruning.pyx", + "numpy.pxd", + "type.pxd", + "_basis.pxd", + "_record.pxd", +}; +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; /* for error messages only */ + struct __Pyx_StructField_* fields; + size_t size; /* sizeof(type) */ + size_t arraysize[8]; /* length of array in each dimension */ + int ndim; + char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */ + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "numpy.pxd":723 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "numpy.pxd":724 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "numpy.pxd":725 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "numpy.pxd":726 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "numpy.pxd":730 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "numpy.pxd":731 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "numpy.pxd":732 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "numpy.pxd":733 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "numpy.pxd":737 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "numpy.pxd":738 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "numpy.pxd":747 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "numpy.pxd":748 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "numpy.pxd":749 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "numpy.pxd":751 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "numpy.pxd":752 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "numpy.pxd":753 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "numpy.pxd":755 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "numpy.pxd":756 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "numpy.pxd":758 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "numpy.pxd":759 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "numpy.pxd":760 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "_basis.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_6_basis_FLOAT_t; + +/* "_basis.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_6_basis_INT_t; + +/* "_basis.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_6_basis_INDEX_t; + +/* "_basis.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef class BasisFunction: + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_6_basis_BOOL_t; + +/* "_record.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_7_record_FLOAT_t; + +/* "_record.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_7_record_INT_t; + +/* "_record.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * from _basis cimport Basis + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_7_record_INDEX_t; + +/* "_record.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * from _basis cimport Basis + * + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_7_record_BOOL_t; + +/* "_util.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_5_util_FLOAT_t; + +/* "_util.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_5_util_INT_t; + +/* "_util.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_5_util_INDEX_t; + +/* "_util.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef FLOAT_t log2(FLOAT_t x) + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_5_util_BOOL_t; + +/* "sklearn/earth/_pruning.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t; + +/* "sklearn/earth/_pruning.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_8_pruning_INT_t; + +/* "sklearn/earth/_pruning.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * from _basis cimport Basis + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_8_pruning_INDEX_t; + +/* "sklearn/earth/_pruning.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * from _basis cimport Basis + * from _record cimport PruningPassRecord + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_8_pruning_BOOL_t; +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis; +struct __pyx_obj_7sklearn_5earth_7_record_Iteration; +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration; +struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser; +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction; +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction; +struct __pyx_obj_7sklearn_5earth_7_record_Record; +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord; +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord; +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction; +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration; +struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration; +struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration; +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction; + +/* "numpy.pxd":762 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "numpy.pxd":763 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "numpy.pxd":764 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "numpy.pxd":766 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply; + +/* "_basis.pxd":45 + * cpdef INDEX_t degree(BasisFunction self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace) + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":62 + * cpdef BasisFunction get_parent(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":86 + * cpdef INDEX_t get_knot_idx(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cdef class LinearBasisFunction(BasisFunction): + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":98 + * cpdef INDEX_t get_variable(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":101 + * + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A wrapper that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtab; + PyObject *order; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t num_variables; +}; + + +/* "_record.pxd":41 + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition) + * + * cdef class Iteration: # <<<<<<<<<<<<<< + * cdef FLOAT_t mse + * cdef INDEX_t size + */ +struct __pyx_obj_7sklearn_5earth_7_record_Iteration { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *__pyx_vtab; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t mse; + __pyx_t_7sklearn_5earth_7_record_INDEX_t size; +}; + + +/* "_record.pxd":57 + * pass + * + * cdef class ForwardPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t parent + * cdef INDEX_t variable + */ +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t parent; + __pyx_t_7sklearn_5earth_7_record_INDEX_t variable; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t knot; + int code; + int no_candidates; +}; + + +/* "sklearn/earth/_pruning.pxd":9 + * from _record cimport PruningPassRecord + * + * cdef class PruningPasser: # <<<<<<<<<<<<<< + * cdef cnp.ndarray X + * cdef cnp.ndarray B + */ +struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_8_pruning_PruningPasser *__pyx_vtab; + PyArrayObject *X; + PyArrayObject *B; + PyArrayObject *y; + PyArrayObject *weights; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t m; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t n; + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *basis; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t penalty; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t sst; + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *record; +}; + + +/* "_basis.pxd":7 + * ctypedef cnp.uint8_t BOOL_t + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + * + */ +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtab; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *parent; + PyObject *child_map; + PyObject *children; + int pruned; + int prunable; + int splittable; +}; + + +/* "_basis.pxd":50 + * + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(ConstantBasisFunction self) + */ +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; +}; + + +/* "_record.pxd":8 + * from _basis cimport Basis + * + * cdef class Record: # <<<<<<<<<<<<<< + * cdef list iterations + * cdef int num_samples + */ +struct __pyx_obj_7sklearn_5earth_7_record_Record { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *__pyx_vtab; + PyObject *iterations; + int num_samples; + int num_variables; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t penalty; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t sst; +}; + + +/* "_record.pxd":25 + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration) + * + * cdef class PruningPassRecord(Record): # <<<<<<<<<<<<<< + * cdef INDEX_t selected + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord { + struct __pyx_obj_7sklearn_5earth_7_record_Record __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t selected; +}; + + +/* "_record.pxd":34 + * cpdef roll_back(PruningPassRecord self, Basis basis) + * + * cdef class ForwardPassRecord(Record): # <<<<<<<<<<<<<< + * cdef int stopping_condition + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord { + struct __pyx_obj_7sklearn_5earth_7_record_Record __pyx_base; + int stopping_condition; + PyObject *xlabels; +}; + + +/* "_basis.pxd":88 + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef str label + */ +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + PyObject *label; +}; + + +/* "_record.pxd":49 + * cpdef INDEX_t get_size(Iteration self) + * + * cdef class PruningPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t pruned + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t pruned; +}; + + +/* "_record.pxd":54 + * cpdef INDEX_t get_pruned(PruningPassIteration self) + * + * cdef class FirstPruningPassIteration(PruningPassIteration): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration __pyx_base; +}; + + +/* "_record.pxd":68 + * cpdef no_further_candidates(ForwardPassIteration self) + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): # <<<<<<<<<<<<<< + * cpdef INDEX_t get_size(FirstForwardPassIteration self) + */ +struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration __pyx_base; +}; + + +/* "_basis.pxd":65 + * + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef FLOAT_t knot + * cdef INDEX_t knot_idx + */ +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t knot; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t knot_idx; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + int reverse; + PyObject *label; +}; + + + +/* "_record.pxd":41 + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition) + * + * cdef class Iteration: # <<<<<<<<<<<<<< + * cdef FLOAT_t mse + * cdef INDEX_t size + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*get_mse)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_size)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *__pyx_vtabptr_7sklearn_5earth_7_record_Iteration; + + +/* "_record.pxd":49 + * cpdef INDEX_t get_size(Iteration self) + * + * cdef class PruningPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t pruned + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_pruned)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration; + + +/* "_basis.pxd":7 + * ctypedef cnp.uint8_t BOOL_t + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction { + int (*has_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_prunable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_pruned)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_unsplittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*get_children)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *); + PyObject *(*_set_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*_add_child)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*prune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*unprune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*degree)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*apply)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args); + PyArrayObject *(*valid_knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int, int, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + + +/* "_basis.pxd":88 + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef str label + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction; + + +/* "_record.pxd":8 + * from _basis cimport Basis + * + * cdef class Record: # <<<<<<<<<<<<<< + * cdef list iterations + * cdef int num_samples + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record { + PyObject *(*append)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*mse)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*rsq)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*gcv)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*grsq)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *__pyx_vtabptr_7sklearn_5earth_7_record_Record; + + +/* "_record.pxd":34 + * cpdef roll_back(PruningPassRecord self, Basis basis) + * + * cdef class ForwardPassRecord(Record): # <<<<<<<<<<<<<< + * cdef int stopping_condition + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record __pyx_base; + PyObject *(*set_stopping_condition)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *, int, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord; + + +/* "_basis.pxd":65 + * + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef FLOAT_t knot + * cdef INDEX_t knot_idx + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*get_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + int (*get_reverse)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_knot_idx)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction; + + +/* "_basis.pxd":50 + * + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(ConstantBasisFunction self) + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction; + + +/* "sklearn/earth/_pruning.pyx":11 + * import numpy as np + * + * cdef class PruningPasser: # <<<<<<<<<<<<<< + * '''Implements the generic pruning pass as described by Friedman, 1991.''' + * def __init__(PruningPasser self, Basis basis, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights, **kwargs): + */ + +struct __pyx_vtabstruct_7sklearn_5earth_8_pruning_PruningPasser { + PyObject *(*run)(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *(*trace)(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_8_pruning_PruningPasser *__pyx_vtabptr_7sklearn_5earth_8_pruning_PruningPasser; + + +/* "_record.pxd":25 + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration) + * + * cdef class PruningPassRecord(Record): # <<<<<<<<<<<<<< + * cdef INDEX_t selected + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record __pyx_base; + PyObject *(*set_selected)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_selected)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, int __pyx_skip_dispatch); + PyObject *(*roll_back)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord; + + +/* "_record.pxd":57 + * pass + * + * cdef class ForwardPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t parent + * cdef INDEX_t variable + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration __pyx_base; + PyObject *(*set_no_candidates)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int, int __pyx_skip_dispatch); + PyObject *(*no_further_candidates)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration; + + +/* "_basis.pxd":101 + * + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A wrapper that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis { + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_root)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + PyObject *(*append)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*plen)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*weighted_transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtabptr_7sklearn_5earth_6_basis_Basis; + + +/* "_record.pxd":68 + * cpdef no_further_candidates(ForwardPassIteration self) + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): # <<<<<<<<<<<<<< + * cpdef INDEX_t get_size(FirstForwardPassIteration self) + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration; + + +/* "_record.pxd":54 + * cpdef INDEX_t get_pruned(PruningPassIteration self) + * + * cdef class FirstPruningPassIteration(PruningPassIteration): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration; +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); + +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/ + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static CYTHON_INLINE int __Pyx_PyDict_Contains(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) + PyErr_SetObject(PyExc_KeyError, args); + Py_XDECREF(args); + } + return NULL; + } + Py_INCREF(value); + return value; +} +#else + #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#endif + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( + PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** py_start, PyObject** py_stop, PyObject** py_slice, + int has_cstart, int has_cstop, int wraparound); + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ + +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; +static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong); + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject *); + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); + +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); + +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); + +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); + +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); + +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); + +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); + +static int __Pyx_check_binary_version(void); + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/ + +typedef struct { + int code_line; + PyCodeObject* code_object; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'sklearn.earth._basis' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_Basis = 0; + +/* Module declarations from 'sklearn.earth._record' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_Record = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_Iteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration = 0; + +/* Module declarations from 'sklearn.earth._util' */ +static PyObject *(*__pyx_f_7sklearn_5earth_5_util_apply_weights_1d)(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t (*__pyx_f_7sklearn_5earth_5_util_gcv)(__pyx_t_7sklearn_5earth_5_util_FLOAT_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch); /*proto*/ + +/* Module declarations from 'sklearn.earth._pruning' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_8_pruning_PruningPasser = 0; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t = { "FLOAT_t", NULL, sizeof(__pyx_t_7sklearn_5earth_8_pruning_FLOAT_t), { 0 }, 0, 'R', 0, 0 }; +#define __Pyx_MODULE_NAME "sklearn.earth._pruning" +int __pyx_module_is_main_sklearn__earth___pruning = 0; + +/* Implementation of 'sklearn.earth._pruning' */ +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static int __pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser___init__(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_basis, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_weights, PyObject *__pyx_v_kwargs); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser_2run(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser_4trace(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_tp_new_7sklearn_5earth_8_pruning_PruningPasser(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static char __pyx_k_7[] = "ndarray is not C contiguous"; +static char __pyx_k_9[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_11[] = "Non-native byte order not supported"; +static char __pyx_k_13[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_14[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_17[] = "Format string allocated too short."; +static char __pyx_k__B[] = "B"; +static char __pyx_k__H[] = "H"; +static char __pyx_k__I[] = "I"; +static char __pyx_k__L[] = "L"; +static char __pyx_k__O[] = "O"; +static char __pyx_k__Q[] = "Q"; +static char __pyx_k__X[] = "X"; +static char __pyx_k__b[] = "b"; +static char __pyx_k__d[] = "d"; +static char __pyx_k__f[] = "f"; +static char __pyx_k__g[] = "g"; +static char __pyx_k__h[] = "h"; +static char __pyx_k__i[] = "i"; +static char __pyx_k__l[] = "l"; +static char __pyx_k__q[] = "q"; +static char __pyx_k__y[] = "y"; +static char __pyx_k__Zd[] = "Zd"; +static char __pyx_k__Zf[] = "Zf"; +static char __pyx_k__Zg[] = "Zg"; +static char __pyx_k__np[] = "np"; +static char __pyx_k__dot[] = "dot"; +static char __pyx_k__run[] = "run"; +static char __pyx_k__sum[] = "sum"; +static char __pyx_k__copy[] = "copy"; +static char __pyx_k__basis[] = "basis"; +static char __pyx_k__dtype[] = "dtype"; +static char __pyx_k__empty[] = "empty"; +static char __pyx_k__float[] = "float"; +static char __pyx_k__lstsq[] = "lstsq"; +static char __pyx_k__numpy[] = "numpy"; +static char __pyx_k__prune[] = "prune"; +static char __pyx_k__range[] = "range"; +static char __pyx_k__shape[] = "shape"; +static char __pyx_k__trace[] = "trace"; +static char __pyx_k__linalg[] = "linalg"; +static char __pyx_k__average[] = "average"; +static char __pyx_k__penalty[] = "penalty"; +static char __pyx_k__unprune[] = "unprune"; +static char __pyx_k__weights[] = "weights"; +static char __pyx_k____main__[] = "__main__"; +static char __pyx_k____test__[] = "__test__"; +static char __pyx_k__is_pruned[] = "is_pruned"; +static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k____import__[] = "__import__"; +static char __pyx_k__is_prunable[] = "is_prunable"; +static char __pyx_k__RuntimeError[] = "RuntimeError"; +static char __pyx_k____pyx_vtable__[] = "__pyx_vtable__"; +static char __pyx_k____pyx_getbuffer[] = "__pyx_getbuffer"; +static char __pyx_k____pyx_releasebuffer[] = "__pyx_releasebuffer"; +static PyObject *__pyx_kp_u_11; +static PyObject *__pyx_kp_u_13; +static PyObject *__pyx_kp_u_14; +static PyObject *__pyx_kp_u_17; +static PyObject *__pyx_kp_u_7; +static PyObject *__pyx_kp_u_9; +static PyObject *__pyx_n_s__RuntimeError; +static PyObject *__pyx_n_s__ValueError; +static PyObject *__pyx_n_s__X; +static PyObject *__pyx_n_s____import__; +static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____pyx_getbuffer; +static PyObject *__pyx_n_s____pyx_releasebuffer; +static PyObject *__pyx_n_s____pyx_vtable__; +static PyObject *__pyx_n_s____test__; +static PyObject *__pyx_n_s__average; +static PyObject *__pyx_n_s__basis; +static PyObject *__pyx_n_s__copy; +static PyObject *__pyx_n_s__dot; +static PyObject *__pyx_n_s__dtype; +static PyObject *__pyx_n_s__empty; +static PyObject *__pyx_n_s__float; +static PyObject *__pyx_n_s__is_prunable; +static PyObject *__pyx_n_s__is_pruned; +static PyObject *__pyx_n_s__linalg; +static PyObject *__pyx_n_s__lstsq; +static PyObject *__pyx_n_s__np; +static PyObject *__pyx_n_s__numpy; +static PyObject *__pyx_n_s__penalty; +static PyObject *__pyx_n_s__prune; +static PyObject *__pyx_n_s__range; +static PyObject *__pyx_n_s__run; +static PyObject *__pyx_n_s__shape; +static PyObject *__pyx_n_s__sum; +static PyObject *__pyx_n_s__trace; +static PyObject *__pyx_n_s__unprune; +static PyObject *__pyx_n_s__weights; +static PyObject *__pyx_n_s__y; +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_15; +static PyObject *__pyx_k_slice_1; +static PyObject *__pyx_k_slice_2; +static PyObject *__pyx_k_slice_3; +static PyObject *__pyx_k_slice_4; +static PyObject *__pyx_k_slice_5; +static PyObject *__pyx_k_slice_6; +static PyObject *__pyx_k_tuple_8; +static PyObject *__pyx_k_tuple_10; +static PyObject *__pyx_k_tuple_12; +static PyObject *__pyx_k_tuple_15; +static PyObject *__pyx_k_tuple_16; +static PyObject *__pyx_k_tuple_18; + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_basis = 0; + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_y = 0; + PyArrayObject *__pyx_v_weights = 0; + PyObject *__pyx_v_kwargs = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1; + __Pyx_GOTREF(__pyx_v_kwargs); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__basis,&__pyx_n_s__X,&__pyx_n_s__y,&__pyx_n_s__weights,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); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__basis)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weights)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_basis = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)values[0]); + __pyx_v_X = ((PyArrayObject *)values[1]); + __pyx_v_y = ((PyArrayObject *)values[2]); + __pyx_v_weights = ((PyArrayObject *)values[3]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; + __Pyx_AddTraceback("sklearn.earth._pruning.PruningPasser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_basis), __pyx_ptype_7sklearn_5earth_6_basis_Basis, 1, "basis", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weights), __pyx_ptype_5numpy_ndarray, 1, "weights", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser___init__(((struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *)__pyx_v_self), __pyx_v_basis, __pyx_v_X, __pyx_v_y, __pyx_v_weights, __pyx_v_kwargs); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_kwargs); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_pruning.pyx":13 + * cdef class PruningPasser: + * '''Implements the generic pruning pass as described by Friedman, 1991.''' + * def __init__(PruningPasser self, Basis basis, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights, **kwargs): # <<<<<<<<<<<<<< + * self.X = X + * self.m = self.X.shape[0] + */ + +static int __pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser___init__(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_basis, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_weights, PyObject *__pyx_v_kwargs) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + + /* "sklearn/earth/_pruning.pyx":14 + * '''Implements the generic pruning pass as described by Friedman, 1991.''' + * def __init__(PruningPasser self, Basis basis, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights, **kwargs): + * self.X = X # <<<<<<<<<<<<<< + * self.m = self.X.shape[0] + * self.n = self.X.shape[1] + */ + __Pyx_INCREF(((PyObject *)__pyx_v_X)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); + __Pyx_GOTREF(__pyx_v_self->X); + __Pyx_DECREF(((PyObject *)__pyx_v_self->X)); + __pyx_v_self->X = ((PyArrayObject *)__pyx_v_X); + + /* "sklearn/earth/_pruning.pyx":15 + * def __init__(PruningPasser self, Basis basis, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights, **kwargs): + * self.X = X + * self.m = self.X.shape[0] # <<<<<<<<<<<<<< + * self.n = self.X.shape[1] + * self.y = y + */ + __pyx_v_self->m = (__pyx_v_self->X->dimensions[0]); + + /* "sklearn/earth/_pruning.pyx":16 + * self.X = X + * self.m = self.X.shape[0] + * self.n = self.X.shape[1] # <<<<<<<<<<<<<< + * self.y = y + * self.weights = weights + */ + __pyx_v_self->n = (__pyx_v_self->X->dimensions[1]); + + /* "sklearn/earth/_pruning.pyx":17 + * self.m = self.X.shape[0] + * self.n = self.X.shape[1] + * self.y = y # <<<<<<<<<<<<<< + * self.weights = weights + * self.basis = basis + */ + __Pyx_INCREF(((PyObject *)__pyx_v_y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_y)); + __Pyx_GOTREF(__pyx_v_self->y); + __Pyx_DECREF(((PyObject *)__pyx_v_self->y)); + __pyx_v_self->y = ((PyArrayObject *)__pyx_v_y); + + /* "sklearn/earth/_pruning.pyx":18 + * self.n = self.X.shape[1] + * self.y = y + * self.weights = weights # <<<<<<<<<<<<<< + * self.basis = basis + * self.B = np.empty(shape=(self.m, len(self.basis) + 1), dtype=np.float) + */ + __Pyx_INCREF(((PyObject *)__pyx_v_weights)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_weights)); + __Pyx_GOTREF(__pyx_v_self->weights); + __Pyx_DECREF(((PyObject *)__pyx_v_self->weights)); + __pyx_v_self->weights = ((PyArrayObject *)__pyx_v_weights); + + /* "sklearn/earth/_pruning.pyx":19 + * self.y = y + * self.weights = weights + * self.basis = basis # <<<<<<<<<<<<<< + * self.B = np.empty(shape=(self.m, len(self.basis) + 1), dtype=np.float) + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + */ + __Pyx_INCREF(((PyObject *)__pyx_v_basis)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_basis)); + __Pyx_GOTREF(__pyx_v_self->basis); + __Pyx_DECREF(((PyObject *)__pyx_v_self->basis)); + __pyx_v_self->basis = __pyx_v_basis; + + /* "sklearn/earth/_pruning.pyx":20 + * self.weights = weights + * self.basis = basis + * self.B = np.empty(shape=(self.m, len(self.basis) + 1), dtype=np.float) # <<<<<<<<<<<<<< + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + * self.sst = np.sum( + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = ((PyObject *)__pyx_v_self->basis); + __Pyx_INCREF(__pyx_t_4); + __pyx_t_5 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyInt_FromSsize_t((__pyx_t_5 + 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__shape), ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__float); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_v_self->B); + __Pyx_DECREF(((PyObject *)__pyx_v_self->B)); + __pyx_v_self->B = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "sklearn/earth/_pruning.pyx":21 + * self.basis = basis + * self.B = np.empty(shape=(self.m, len(self.basis) + 1), dtype=np.float) + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 # <<<<<<<<<<<<<< + * self.sst = np.sum( + * self.weights * (self.y - np.average(self.y, weights=self.weights)) ** 2) / self.m + */ + __pyx_t_7 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__penalty), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if ((__pyx_t_7 != 0)) { + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__penalty)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_1 = PyFloat_FromDouble(3.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_8 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_self->penalty = __pyx_t_8; + + /* "sklearn/earth/_pruning.pyx":22 + * self.B = np.empty(shape=(self.m, len(self.basis) + 1), dtype=np.float) + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + * self.sst = np.sum( # <<<<<<<<<<<<<< + * self.weights * (self.y - np.average(self.y, weights=self.weights)) ** 2) / self.m + * + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__sum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "sklearn/earth/_pruning.pyx":23 + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + * self.sst = np.sum( + * self.weights * (self.y - np.average(self.y, weights=self.weights)) ** 2) / self.m # <<<<<<<<<<<<<< + * + * cpdef run(PruningPasser self): + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__average); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_self->y)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->y)); + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__weights), ((PyObject *)__pyx_v_self->weights)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __pyx_t_6 = PyNumber_Subtract(((PyObject *)__pyx_v_self->y), __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Power(__pyx_t_6, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyNumber_Multiply(((PyObject *)__pyx_v_self->weights), __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_8 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_pruning.pyx":22 + * self.B = np.empty(shape=(self.m, len(self.basis) + 1), dtype=np.float) + * self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + * self.sst = np.sum( # <<<<<<<<<<<<<< + * self.weights * (self.y - np.average(self.y, weights=self.weights)) ** 2) / self.m + * + */ + __pyx_v_self->sst = __pyx_t_8; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._pruning.PruningPasser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_pruning.pyx":25 + * self.weights * (self.y - np.average(self.y, weights=self.weights)) ** 2) / self.m + * + * cpdef run(PruningPasser self): # <<<<<<<<<<<<<< + * # This is a totally naive implementation and could potentially be made faster + * # through the use of updating algorithms. It is not clear that such + */ + +static PyObject *__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_3run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_8_pruning_13PruningPasser_run(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_v_j; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_v_basis_size; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_v_pruned_basis_size; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t __pyx_v_gcv_; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_v_best_iteration; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_v_best_bf_to_prune; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t __pyx_v_best_gcv; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t __pyx_v_best_iteration_gcv; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t __pyx_v_best_iteration_mse; + PyArrayObject *__pyx_v_B = 0; + PyArrayObject *__pyx_v_X = 0; + PyArrayObject *__pyx_v_y = 0; + PyArrayObject *__pyx_v_weights = 0; + PyArrayObject *__pyx_v_weighted_y = 0; + PyObject *__pyx_v_beta = NULL; + PyObject *__pyx_v_mse = NULL; + int __pyx_v_first; + PyObject *__pyx_v_bf = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_X; + __Pyx_Buffer __pyx_pybuffer_X; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weighted_y; + __Pyx_Buffer __pyx_pybuffer_weighted_y; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyArrayObject *__pyx_t_4 = NULL; + PyArrayObject *__pyx_t_5 = NULL; + PyArrayObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + PyArrayObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *(*__pyx_t_11)(PyObject *); + int __pyx_t_12; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_t_15; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_t_16; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_t_17; + __pyx_t_7sklearn_5earth_8_pruning_INDEX_t __pyx_t_18; + int __pyx_t_19; + __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_t_20; + __pyx_t_7sklearn_5earth_8_pruning_FLOAT_t __pyx_t_21; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("run", 0); + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_X.pybuffer.buf = NULL; + __pyx_pybuffer_X.refcount = 0; + __pyx_pybuffernd_X.data = NULL; + __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + __pyx_pybuffer_weighted_y.pybuffer.buf = NULL; + __pyx_pybuffer_weighted_y.refcount = 0; + __pyx_pybuffernd_weighted_y.data = NULL; + __pyx_pybuffernd_weighted_y.rcbuffer = &__pyx_pybuffer_weighted_y; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__run); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_3run)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_pruning.pyx":32 + * cdef INDEX_t i + * cdef INDEX_t j + * cdef INDEX_t basis_size = len(self.basis) # <<<<<<<<<<<<<< + * cdef INDEX_t pruned_basis_size = self.basis.plen() + * cdef FLOAT_t gcv_ + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->basis); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_basis_size = __pyx_t_3; + + /* "sklearn/earth/_pruning.pyx":33 + * cdef INDEX_t j + * cdef INDEX_t basis_size = len(self.basis) + * cdef INDEX_t pruned_basis_size = self.basis.plen() # <<<<<<<<<<<<<< + * cdef FLOAT_t gcv_ + * cdef INDEX_t best_iteration + */ + __pyx_v_pruned_basis_size = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->plen(__pyx_v_self->basis, 0); + + /* "sklearn/earth/_pruning.pyx":41 + * cdef FLOAT_t best_iteration_mse + * + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + */ + __pyx_t_4 = ((PyArrayObject *)__pyx_v_self->B); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_B = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_B.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_4 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->B))); + __pyx_v_B = ((PyArrayObject *)__pyx_v_self->B); + + /* "sklearn/earth/_pruning.pyx":42 + * + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] weights = self.weights + */ + __pyx_t_5 = ((PyArrayObject *)__pyx_v_self->X); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_X.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->X))); + __pyx_v_X = ((PyArrayObject *)__pyx_v_self->X); + + /* "sklearn/earth/_pruning.pyx":43 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] weights = self.weights + * cdef cnp.ndarray[FLOAT_t, ndim = 1] weighted_y = y.copy() + */ + __pyx_t_6 = ((PyArrayObject *)__pyx_v_self->y); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_y = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_6 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->y))); + __pyx_v_y = ((PyArrayObject *)__pyx_v_self->y); + + /* "sklearn/earth/_pruning.pyx":44 + * cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] weights = self.weights # <<<<<<<<<<<<<< + * cdef cnp.ndarray[FLOAT_t, ndim = 1] weighted_y = y.copy() + * + */ + __pyx_t_7 = ((PyArrayObject *)__pyx_v_self->weights); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_weights = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_weights.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_7 = 0; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self->weights))); + __pyx_v_weights = ((PyArrayObject *)__pyx_v_self->weights); + + /* "sklearn/earth/_pruning.pyx":45 + * cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + * cdef cnp.ndarray[FLOAT_t, ndim = 1] weights = self.weights + * cdef cnp.ndarray[FLOAT_t, ndim = 1] weighted_y = y.copy() # <<<<<<<<<<<<<< + * + * # Initial solution + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weighted_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_8_pruning_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_weighted_y = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_weighted_y.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_weighted_y.diminfo[0].strides = __pyx_pybuffernd_weighted_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weighted_y.diminfo[0].shape = __pyx_pybuffernd_weighted_y.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_8 = 0; + __pyx_v_weighted_y = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_pruning.pyx":48 + * + * # Initial solution + * apply_weights_1d(weighted_y, weights) # <<<<<<<<<<<<<< + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq(B[:, 0:(basis_size)], weighted_y)[0:2] + */ + __pyx_t_2 = __pyx_f_7sklearn_5earth_5_util_apply_weights_1d(((PyArrayObject *)__pyx_v_weighted_y), ((PyArrayObject *)__pyx_v_weights), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_pruning.pyx":49 + * # Initial solution + * apply_weights_1d(weighted_y, weights) + * self.basis.weighted_transform(X, B, weights) # <<<<<<<<<<<<<< + * beta, mse = np.linalg.lstsq(B[:, 0:(basis_size)], weighted_y)[0:2] + * if mse: + */ + __pyx_t_2 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->weighted_transform(__pyx_v_self->basis, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_weights), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_pruning.pyx":50 + * apply_weights_1d(weighted_y, weights) + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq(B[:, 0:(basis_size)], weighted_y)[0:2] # <<<<<<<<<<<<<< + * if mse: + * mse /= self.m + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__linalg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __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__lstsq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_basis_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PySlice_New(__pyx_int_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_k_slice_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_k_slice_1); + __Pyx_GIVEREF(__pyx_k_slice_1); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_1)); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __Pyx_INCREF(((PyObject *)__pyx_v_weighted_y)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_weighted_y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_weighted_y)); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_9, 0, 2, NULL, NULL, &__pyx_k_slice_2, 1, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_9 = PyList_GET_ITEM(sequence, 0); + __pyx_t_2 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; + index = 0; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L3_unpacking_failed; + __Pyx_GOTREF(__pyx_t_9); + index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = NULL; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + goto __pyx_L4_unpacking_done; + __pyx_L3_unpacking_failed:; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_11 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L4_unpacking_done:; + } + __pyx_v_beta = __pyx_t_9; + __pyx_t_9 = 0; + __pyx_v_mse = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_pruning.pyx":51 + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq(B[:, 0:(basis_size)], weighted_y)[0:2] + * if mse: # <<<<<<<<<<<<<< + * mse /= self.m + * else: + */ + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_mse); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_12) { + + /* "sklearn/earth/_pruning.pyx":52 + * beta, mse = np.linalg.lstsq(B[:, 0:(basis_size)], weighted_y)[0:2] + * if mse: + * mse /= self.m # <<<<<<<<<<<<<< + * else: + * mse = (1.0 / self.m) * np.sum( + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_mse, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_mse, __pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L5; + } + /*else*/ { + + /* "sklearn/earth/_pruning.pyx":54 + * mse /= self.m + * else: + * mse = (1.0 / self.m) * np.sum( # <<<<<<<<<<<<<< + * (np.dot(B[:, 0:basis_size], beta) - weighted_y) ** 2) + * + */ + __pyx_t_2 = PyFloat_FromDouble((1.0 / __pyx_v_self->m)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__sum); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_pruning.pyx":55 + * else: + * mse = (1.0 / self.m) * np.sum( + * (np.dot(B[:, 0:basis_size], beta) - weighted_y) ** 2) # <<<<<<<<<<<<<< + * + * # Create the record object + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__dot); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_basis_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_13 = PySlice_New(__pyx_int_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_k_slice_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_k_slice_3); + __Pyx_GIVEREF(__pyx_k_slice_3); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_13 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_1)); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __Pyx_INCREF(__pyx_v_beta); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_beta); + __Pyx_GIVEREF(__pyx_v_beta); + __pyx_t_13 = 0; + __pyx_t_13 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Subtract(__pyx_t_13, ((PyObject *)__pyx_v_weighted_y)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = PyNumber_Power(__pyx_t_1, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_13 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF_SET(__pyx_v_mse, __pyx_t_1); + __pyx_t_1 = 0; + } + __pyx_L5:; + + /* "sklearn/earth/_pruning.pyx":59 + * # Create the record object + * self.record = PruningPassRecord( + * self.m, self.n, self.penalty, self.sst, pruned_basis_size, mse) # <<<<<<<<<<<<<< + * gcv_ = self.record.gcv(0) + * best_gcv = gcv_ + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_13 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->n); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->penalty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = PyFloat_FromDouble(__pyx_v_self->sst); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_pruned_basis_size); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_14 = PyTuple_New(6); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __Pyx_INCREF(__pyx_v_mse); + PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_v_mse); + __Pyx_GIVEREF(__pyx_v_mse); + __pyx_t_1 = 0; + __pyx_t_13 = 0; + __pyx_t_2 = 0; + __pyx_t_9 = 0; + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord)), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; + + /* "sklearn/earth/_pruning.pyx":58 + * + * # Create the record object + * self.record = PruningPassRecord( # <<<<<<<<<<<<<< + * self.m, self.n, self.penalty, self.sst, pruned_basis_size, mse) + * gcv_ = self.record.gcv(0) + */ + __Pyx_GIVEREF(__pyx_t_10); + __Pyx_GOTREF(__pyx_v_self->record); + __Pyx_DECREF(((PyObject *)__pyx_v_self->record)); + __pyx_v_self->record = ((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_t_10); + __pyx_t_10 = 0; + + /* "sklearn/earth/_pruning.pyx":60 + * self.record = PruningPassRecord( + * self.m, self.n, self.penalty, self.sst, pruned_basis_size, mse) + * gcv_ = self.record.gcv(0) # <<<<<<<<<<<<<< + * best_gcv = gcv_ + * best_iteration = 0 + */ + __pyx_v_gcv_ = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->__pyx_base.gcv(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self->record), 0, 0); + + /* "sklearn/earth/_pruning.pyx":61 + * self.m, self.n, self.penalty, self.sst, pruned_basis_size, mse) + * gcv_ = self.record.gcv(0) + * best_gcv = gcv_ # <<<<<<<<<<<<<< + * best_iteration = 0 + * + */ + __pyx_v_best_gcv = __pyx_v_gcv_; + + /* "sklearn/earth/_pruning.pyx":62 + * gcv_ = self.record.gcv(0) + * best_gcv = gcv_ + * best_iteration = 0 # <<<<<<<<<<<<<< + * + * # Prune basis functions sequentially + */ + __pyx_v_best_iteration = 0; + + /* "sklearn/earth/_pruning.pyx":65 + * + * # Prune basis functions sequentially + * for i in range(1, pruned_basis_size): # <<<<<<<<<<<<<< + * first = True + * pruned_basis_size -= 1 + */ + __pyx_t_15 = __pyx_v_pruned_basis_size; + for (__pyx_t_16 = 1; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + __pyx_v_i = __pyx_t_16; + + /* "sklearn/earth/_pruning.pyx":66 + * # Prune basis functions sequentially + * for i in range(1, pruned_basis_size): + * first = True # <<<<<<<<<<<<<< + * pruned_basis_size -= 1 + * + */ + __pyx_v_first = 1; + + /* "sklearn/earth/_pruning.pyx":67 + * for i in range(1, pruned_basis_size): + * first = True + * pruned_basis_size -= 1 # <<<<<<<<<<<<<< + * + * # Find the best basis function to prune + */ + __pyx_v_pruned_basis_size = (__pyx_v_pruned_basis_size - 1); + + /* "sklearn/earth/_pruning.pyx":70 + * + * # Find the best basis function to prune + * for j in range(basis_size): # <<<<<<<<<<<<<< + * bf = self.basis[j] + * if bf.is_pruned(): + */ + __pyx_t_17 = __pyx_v_basis_size; + for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { + __pyx_v_j = __pyx_t_18; + + /* "sklearn/earth/_pruning.pyx":71 + * # Find the best basis function to prune + * for j in range(basis_size): + * bf = self.basis[j] # <<<<<<<<<<<<<< + * if bf.is_pruned(): + * continue + */ + __pyx_t_10 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->basis), __pyx_v_j, sizeof(__pyx_t_7sklearn_5earth_8_pruning_INDEX_t)+1, __Pyx_PyInt_to_py_npy_ulonglong, 0, 0, 0); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_XDECREF_SET(__pyx_v_bf, __pyx_t_10); + __pyx_t_10 = 0; + + /* "sklearn/earth/_pruning.pyx":72 + * for j in range(basis_size): + * bf = self.basis[j] + * if bf.is_pruned(): # <<<<<<<<<<<<<< + * continue + * if not bf.is_prunable(): + */ + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_bf, __pyx_n_s__is_pruned); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_14 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + if (__pyx_t_12) { + + /* "sklearn/earth/_pruning.pyx":73 + * bf = self.basis[j] + * if bf.is_pruned(): + * continue # <<<<<<<<<<<<<< + * if not bf.is_prunable(): + * continue + */ + goto __pyx_L8_continue; + goto __pyx_L10; + } + __pyx_L10:; + + /* "sklearn/earth/_pruning.pyx":74 + * if bf.is_pruned(): + * continue + * if not bf.is_prunable(): # <<<<<<<<<<<<<< + * continue + * bf.prune() + */ + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_bf, __pyx_n_s__is_prunable); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_10 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_19 = ((!__pyx_t_12) != 0); + if (__pyx_t_19) { + + /* "sklearn/earth/_pruning.pyx":75 + * continue + * if not bf.is_prunable(): + * continue # <<<<<<<<<<<<<< + * bf.prune() + * self.basis.weighted_transform(X, B, weights) + */ + goto __pyx_L8_continue; + goto __pyx_L11; + } + __pyx_L11:; + + /* "sklearn/earth/_pruning.pyx":76 + * if not bf.is_prunable(): + * continue + * bf.prune() # <<<<<<<<<<<<<< + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq( + */ + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_bf, __pyx_n_s__prune); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_14 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "sklearn/earth/_pruning.pyx":77 + * continue + * bf.prune() + * self.basis.weighted_transform(X, B, weights) # <<<<<<<<<<<<<< + * beta, mse = np.linalg.lstsq( + * B[:, 0:pruned_basis_size], weighted_y)[0:2] + */ + __pyx_t_14 = ((struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *)__pyx_v_self->basis->__pyx_vtab)->weighted_transform(__pyx_v_self->basis, ((PyArrayObject *)__pyx_v_X), ((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_weights), 0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "sklearn/earth/_pruning.pyx":78 + * bf.prune() + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq( # <<<<<<<<<<<<<< + * B[:, 0:pruned_basis_size], weighted_y)[0:2] + * if mse: + */ + __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s__linalg); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__lstsq); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + + /* "sklearn/earth/_pruning.pyx":79 + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq( + * B[:, 0:pruned_basis_size], weighted_y)[0:2] # <<<<<<<<<<<<<< + * if mse: + * mse /= self.m + */ + __pyx_t_10 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_pruned_basis_size); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PySlice_New(__pyx_int_0, __pyx_t_10, Py_None); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_k_slice_4); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_k_slice_4); + __Pyx_GIVEREF(__pyx_k_slice_4); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_10)); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __Pyx_INCREF(((PyObject *)__pyx_v_weighted_y)); + PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v_weighted_y)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_weighted_y)); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetSlice(__pyx_t_9, 0, 2, NULL, NULL, &__pyx_k_slice_5, 1, 1, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) { + PyObject* sequence = __pyx_t_10; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_14 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_9 = PyList_GET_ITEM(sequence, 0); + __pyx_t_14 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(__pyx_t_14); + #else + __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_14 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + #endif + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_2 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; + index = 0; __pyx_t_9 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_9)) goto __pyx_L12_unpacking_failed; + __Pyx_GOTREF(__pyx_t_9); + index = 1; __pyx_t_14 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_14)) goto __pyx_L12_unpacking_failed; + __Pyx_GOTREF(__pyx_t_14); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = NULL; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L13_unpacking_done; + __pyx_L12_unpacking_failed:; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_11 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L13_unpacking_done:; + } + + /* "sklearn/earth/_pruning.pyx":78 + * bf.prune() + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq( # <<<<<<<<<<<<<< + * B[:, 0:pruned_basis_size], weighted_y)[0:2] + * if mse: + */ + __Pyx_DECREF_SET(__pyx_v_beta, __pyx_t_9); + __pyx_t_9 = 0; + __Pyx_DECREF_SET(__pyx_v_mse, __pyx_t_14); + __pyx_t_14 = 0; + + /* "sklearn/earth/_pruning.pyx":80 + * beta, mse = np.linalg.lstsq( + * B[:, 0:pruned_basis_size], weighted_y)[0:2] + * if mse: # <<<<<<<<<<<<<< + * mse /= self.m + * else: + */ + __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_v_mse); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_19) { + + /* "sklearn/earth/_pruning.pyx":81 + * B[:, 0:pruned_basis_size], weighted_y)[0:2] + * if mse: + * mse /= self.m # <<<<<<<<<<<<<< + * else: + * mse = (1 / float(self.m)) * np.sum( + */ + __pyx_t_10 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->m); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_14 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_mse, __pyx_t_10); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF_SET(__pyx_v_mse, __pyx_t_14); + __pyx_t_14 = 0; + goto __pyx_L14; + } + /*else*/ { + + /* "sklearn/earth/_pruning.pyx":83 + * mse /= self.m + * else: + * mse = (1 / float(self.m)) * np.sum( # <<<<<<<<<<<<<< + * (np.dot(B[:, 0:pruned_basis_size], beta) - weighted_y) ** 2) + * gcv_ = gcv(mse, pruned_basis_size, self.m, self.penalty) + */ + __pyx_t_14 = PyFloat_FromDouble((1.0 / ((double)__pyx_v_self->m))); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__sum); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + + /* "sklearn/earth/_pruning.pyx":84 + * else: + * mse = (1 / float(self.m)) * np.sum( + * (np.dot(B[:, 0:pruned_basis_size], beta) - weighted_y) ** 2) # <<<<<<<<<<<<<< + * gcv_ = gcv(mse, pruned_basis_size, self.m, self.penalty) + * + */ + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__dot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_pruned_basis_size); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_13 = PySlice_New(__pyx_int_0, __pyx_t_10, Py_None); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_k_slice_6); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_k_slice_6); + __Pyx_GIVEREF(__pyx_k_slice_6); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_13 = PyObject_GetItem(((PyObject *)__pyx_v_B), ((PyObject *)__pyx_t_10)); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __Pyx_INCREF(__pyx_v_beta); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_beta); + __Pyx_GIVEREF(__pyx_v_beta); + __pyx_t_13 = 0; + __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = PyNumber_Subtract(__pyx_t_13, ((PyObject *)__pyx_v_weighted_y)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = PyNumber_Power(__pyx_t_10, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_13 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = PyNumber_Multiply(__pyx_t_14, __pyx_t_13); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF_SET(__pyx_v_mse, __pyx_t_10); + __pyx_t_10 = 0; + } + __pyx_L14:; + + /* "sklearn/earth/_pruning.pyx":85 + * mse = (1 / float(self.m)) * np.sum( + * (np.dot(B[:, 0:pruned_basis_size], beta) - weighted_y) ** 2) + * gcv_ = gcv(mse, pruned_basis_size, self.m, self.penalty) # <<<<<<<<<<<<<< + * + * if gcv_ <= best_iteration_gcv or first: + */ + __pyx_t_20 = __pyx_PyFloat_AsDouble(__pyx_v_mse); if (unlikely((__pyx_t_20 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_gcv_ = __pyx_f_7sklearn_5earth_5_util_gcv(__pyx_t_20, __pyx_v_pruned_basis_size, __pyx_v_self->m, __pyx_v_self->penalty, 0); + + /* "sklearn/earth/_pruning.pyx":87 + * gcv_ = gcv(mse, pruned_basis_size, self.m, self.penalty) + * + * if gcv_ <= best_iteration_gcv or first: # <<<<<<<<<<<<<< + * best_iteration_gcv = gcv_ + * best_iteration_mse = mse + */ + __pyx_t_19 = ((__pyx_v_gcv_ <= __pyx_v_best_iteration_gcv) != 0); + if (!__pyx_t_19) { + __pyx_t_12 = (__pyx_v_first != 0); + } else { + __pyx_t_12 = __pyx_t_19; + } + if (__pyx_t_12) { + + /* "sklearn/earth/_pruning.pyx":88 + * + * if gcv_ <= best_iteration_gcv or first: + * best_iteration_gcv = gcv_ # <<<<<<<<<<<<<< + * best_iteration_mse = mse + * best_bf_to_prune = j + */ + __pyx_v_best_iteration_gcv = __pyx_v_gcv_; + + /* "sklearn/earth/_pruning.pyx":89 + * if gcv_ <= best_iteration_gcv or first: + * best_iteration_gcv = gcv_ + * best_iteration_mse = mse # <<<<<<<<<<<<<< + * best_bf_to_prune = j + * first = False + */ + __pyx_t_21 = __pyx_PyFloat_AsDouble(__pyx_v_mse); if (unlikely((__pyx_t_21 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_best_iteration_mse = __pyx_t_21; + + /* "sklearn/earth/_pruning.pyx":90 + * best_iteration_gcv = gcv_ + * best_iteration_mse = mse + * best_bf_to_prune = j # <<<<<<<<<<<<<< + * first = False + * bf.unprune() + */ + __pyx_v_best_bf_to_prune = __pyx_v_j; + + /* "sklearn/earth/_pruning.pyx":91 + * best_iteration_mse = mse + * best_bf_to_prune = j + * first = False # <<<<<<<<<<<<<< + * bf.unprune() + * + */ + __pyx_v_first = 0; + goto __pyx_L15; + } + __pyx_L15:; + + /* "sklearn/earth/_pruning.pyx":92 + * best_bf_to_prune = j + * first = False + * bf.unprune() # <<<<<<<<<<<<<< + * + * # The inner loop found the best basis function to remove for this iteration. + */ + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_bf, __pyx_n_s__unprune); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_13 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_L8_continue:; + } + + /* "sklearn/earth/_pruning.pyx":97 + * # Now check whether this iteration is better than all the previous + * # ones. + * if best_iteration_gcv <= best_gcv: # <<<<<<<<<<<<<< + * best_gcv = best_iteration_gcv + * best_iteration = i + */ + __pyx_t_12 = ((__pyx_v_best_iteration_gcv <= __pyx_v_best_gcv) != 0); + if (__pyx_t_12) { + + /* "sklearn/earth/_pruning.pyx":98 + * # ones. + * if best_iteration_gcv <= best_gcv: + * best_gcv = best_iteration_gcv # <<<<<<<<<<<<<< + * best_iteration = i + * + */ + __pyx_v_best_gcv = __pyx_v_best_iteration_gcv; + + /* "sklearn/earth/_pruning.pyx":99 + * if best_iteration_gcv <= best_gcv: + * best_gcv = best_iteration_gcv + * best_iteration = i # <<<<<<<<<<<<<< + * + * # Update the record and prune the selected basis function + */ + __pyx_v_best_iteration = __pyx_v_i; + goto __pyx_L16; + } + __pyx_L16:; + + /* "sklearn/earth/_pruning.pyx":103 + * # Update the record and prune the selected basis function + * self.record.append(PruningPassIteration( + * best_bf_to_prune, pruned_basis_size, best_iteration_mse)) # <<<<<<<<<<<<<< + * self.basis[best_bf_to_prune].prune() + * + */ + __pyx_t_13 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_best_bf_to_prune); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_10 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_pruned_basis_size); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_14 = PyFloat_FromDouble(__pyx_v_best_iteration_mse); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); + __pyx_t_13 = 0; + __pyx_t_10 = 0; + __pyx_t_14 = 0; + __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration)), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __pyx_t_9 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->__pyx_base.append(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self->record), ((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_t_14), 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "sklearn/earth/_pruning.pyx":104 + * self.record.append(PruningPassIteration( + * best_bf_to_prune, pruned_basis_size, best_iteration_mse)) + * self.basis[best_bf_to_prune].prune() # <<<<<<<<<<<<<< + * + * # Unprune the basis functions pruned after the best iteration + */ + __pyx_t_9 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->basis), __pyx_v_best_bf_to_prune, sizeof(__pyx_t_7sklearn_5earth_8_pruning_INDEX_t)+1, __Pyx_PyInt_to_py_npy_ulonglong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s__prune); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + + /* "sklearn/earth/_pruning.pyx":107 + * + * # Unprune the basis functions pruned after the best iteration + * self.record.set_selected(best_iteration) # <<<<<<<<<<<<<< + * self.record.roll_back(self.basis) + * + */ + __pyx_t_9 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->set_selected(__pyx_v_self->record, __pyx_v_best_iteration, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "sklearn/earth/_pruning.pyx":108 + * # Unprune the basis functions pruned after the best iteration + * self.record.set_selected(best_iteration) + * self.record.roll_back(self.basis) # <<<<<<<<<<<<<< + * + * cpdef PruningPassRecord trace(PruningPasser self): + */ + __pyx_t_9 = ((PyObject *)__pyx_v_self->basis); + __Pyx_INCREF(__pyx_t_9); + __pyx_t_14 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->record->__pyx_base.__pyx_vtab)->roll_back(__pyx_v_self->record, ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_t_9), 0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weighted_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._pruning.PruningPasser.run", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weighted_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_B); + __Pyx_XDECREF((PyObject *)__pyx_v_X); + __Pyx_XDECREF((PyObject *)__pyx_v_y); + __Pyx_XDECREF((PyObject *)__pyx_v_weights); + __Pyx_XDECREF((PyObject *)__pyx_v_weighted_y); + __Pyx_XDECREF(__pyx_v_beta); + __Pyx_XDECREF(__pyx_v_mse); + __Pyx_XDECREF(__pyx_v_bf); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_3run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_3run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("run (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser_2run(((struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_pruning.pyx":25 + * self.weights * (self.y - np.average(self.y, weights=self.weights)) ** 2) / self.m + * + * cpdef run(PruningPasser self): # <<<<<<<<<<<<<< + * # This is a totally naive implementation and could potentially be made faster + * # through the use of updating algorithms. It is not clear that such + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser_2run(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("run", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_8_pruning_PruningPasser *)__pyx_v_self->__pyx_vtab)->run(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._pruning.PruningPasser.run", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_pruning.pyx":110 + * self.record.roll_back(self.basis) + * + * cpdef PruningPassRecord trace(PruningPasser self): # <<<<<<<<<<<<<< + * return self.record + */ + +static PyObject *__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_5trace(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_f_7sklearn_5earth_8_pruning_13PruningPasser_trace(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("trace", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__trace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_5trace)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_pruning.pyx":111 + * + * cpdef PruningPassRecord trace(PruningPasser self): + * return self.record # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_self->record)); + __pyx_r = __pyx_v_self->record; + goto __pyx_L0; + + __pyx_r = ((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._pruning.PruningPasser.trace", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_5trace(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_5trace(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("trace (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser_4trace(((struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_pruning.pyx":110 + * self.record.roll_back(self.basis) + * + * cpdef PruningPassRecord trace(PruningPasser self): # <<<<<<<<<<<<<< + * return self.record + */ + +static PyObject *__pyx_pf_7sklearn_5earth_8_pruning_13PruningPasser_4trace(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("trace", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_5earth_8_pruning_PruningPasser *)__pyx_v_self->__pyx_vtab)->trace(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._pruning.PruningPasser.trace", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":194 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "numpy.pxd":200 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":203 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":204 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":206 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "numpy.pxd":208 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":209 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + goto __pyx_L4; + } + /*else*/ { + + /* "numpy.pxd":211 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "numpy.pxd":213 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":214 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "numpy.pxd":217 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_3) { + + /* "numpy.pxd":218 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = __pyx_t_1; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (__pyx_t_2) { + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "numpy.pxd":221 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "numpy.pxd":222 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "numpy.pxd":223 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_2 = (__pyx_v_copy_shape != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":226 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "numpy.pxd":227 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "numpy.pxd":228 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "numpy.pxd":229 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "numpy.pxd":230 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + goto __pyx_L7; + } + /*else*/ { + + /* "numpy.pxd":232 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "numpy.pxd":233 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L7:; + + /* "numpy.pxd":234 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "numpy.pxd":235 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "numpy.pxd":236 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "numpy.pxd":239 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef list stack + */ + __pyx_v_f = NULL; + + /* "numpy.pxd":240 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef list stack + * cdef int offset + */ + __pyx_t_4 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_4); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":244 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "numpy.pxd":246 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_3; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":248 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + goto __pyx_L10; + } + /*else*/ { + + /* "numpy.pxd":251 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L10:; + + /* "numpy.pxd":253 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":254 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_5 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_5; + + /* "numpy.pxd":255 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_2 = __pyx_t_1; + } + if (!__pyx_t_2) { + + /* "numpy.pxd":256 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_1) { + __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_7 = __pyx_t_3; + } else { + __pyx_t_7 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_7; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + switch (__pyx_v_t) { + + /* "numpy.pxd":258 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + case NPY_BYTE: + __pyx_v_f = __pyx_k__b; + break; + + /* "numpy.pxd":259 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = __pyx_k__B; + break; + + /* "numpy.pxd":260 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = __pyx_k__h; + break; + + /* "numpy.pxd":261 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = __pyx_k__H; + break; + + /* "numpy.pxd":262 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = __pyx_k__i; + break; + + /* "numpy.pxd":263 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = __pyx_k__I; + break; + + /* "numpy.pxd":264 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = __pyx_k__l; + break; + + /* "numpy.pxd":265 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = __pyx_k__L; + break; + + /* "numpy.pxd":266 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = __pyx_k__q; + break; + + /* "numpy.pxd":267 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = __pyx_k__Q; + break; + + /* "numpy.pxd":268 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = __pyx_k__f; + break; + + /* "numpy.pxd":269 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = __pyx_k__d; + break; + + /* "numpy.pxd":270 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = __pyx_k__g; + break; + + /* "numpy.pxd":271 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = __pyx_k__Zf; + break; + + /* "numpy.pxd":272 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = __pyx_k__Zd; + break; + + /* "numpy.pxd":273 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = __pyx_k__Zg; + break; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = __pyx_k__O; + break; + default: + + /* "numpy.pxd":276 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_13), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + + /* "numpy.pxd":277 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "numpy.pxd":278 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":280 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + __pyx_v_info->format = ((char *)malloc(255)); + + /* "numpy.pxd":281 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "numpy.pxd":282 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "numpy.pxd":285 + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + * &offset) # <<<<<<<<<<<<<< + * f[0] = c'\0' # Terminate format string + * + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_9; + + /* "numpy.pxd":286 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + __pyx_L11:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":288 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "numpy.pxd":289 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":290 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":291 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":292 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + goto __pyx_L4; + } + __pyx_L4:; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":768 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "numpy.pxd":769 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":771 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "numpy.pxd":772 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":774 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "numpy.pxd":775 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":777 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "numpy.pxd":778 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":780 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "numpy.pxd":781 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":783 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + char *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "numpy.pxd":790 + * cdef int delta_offset + * cdef tuple i + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":791 + * cdef tuple i + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "numpy.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) { + PyObject* sequence = ((PyObject *)__pyx_v_fields); + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + } else if (1) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else + { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "numpy.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (__pyx_t_7) { + __pyx_t_8 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_8 = __pyx_t_7; + } + if (!__pyx_t_8) { + + /* "numpy.pxd":802 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + __pyx_t_9 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_10 = __pyx_t_9; + } else { + __pyx_t_10 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_10; + } else { + __pyx_t_7 = __pyx_t_8; + } + if (__pyx_t_7) { + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_16), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "numpy.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!__pyx_t_7) break; + + /* "numpy.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 120; + + /* "numpy.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "numpy.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1); + } + + /* "numpy.pxd":818 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize); + + /* "numpy.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_7 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":821 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_7 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":826 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 98; + goto __pyx_L13; + } + + /* "numpy.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 66; + goto __pyx_L13; + } + + /* "numpy.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 104; + goto __pyx_L13; + } + + /* "numpy.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 72; + goto __pyx_L13; + } + + /* "numpy.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 105; + goto __pyx_L13; + } + + /* "numpy.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 73; + goto __pyx_L13; + } + + /* "numpy.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 108; + goto __pyx_L13; + } + + /* "numpy.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 76; + goto __pyx_L13; + } + + /* "numpy.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 113; + goto __pyx_L13; + } + + /* "numpy.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 81; + goto __pyx_L13; + } + + /* "numpy.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 102; + goto __pyx_L13; + } + + /* "numpy.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 100; + goto __pyx_L13; + } + + /* "numpy.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 103; + goto __pyx_L13; + } + + /* "numpy.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 102; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 100; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 103; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 79; + goto __pyx_L13; + } + /*else*/ { + + /* "numpy.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_13), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L13:; + + /* "numpy.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_12; + } + __pyx_L11:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "numpy.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":965 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "numpy.pxd":967 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":968 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":970 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + Py_INCREF(__pyx_v_base); + + /* "numpy.pxd":971 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "numpy.pxd":972 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "numpy.pxd":973 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "numpy.pxd":976 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":977 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":979 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_7sklearn_5earth_8_pruning_PruningPasser __pyx_vtable_7sklearn_5earth_8_pruning_PruningPasser; + +static PyObject *__pyx_tp_new_7sklearn_5earth_8_pruning_PruningPasser(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *)o); + p->__pyx_vtab = __pyx_vtabptr_7sklearn_5earth_8_pruning_PruningPasser; + p->X = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->B = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->basis = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)Py_None); Py_INCREF(Py_None); + p->record = ((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_8_pruning_PruningPasser(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *p = (struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->X); + Py_CLEAR(p->B); + Py_CLEAR(p->y); + Py_CLEAR(p->weights); + Py_CLEAR(p->basis); + Py_CLEAR(p->record); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_8_pruning_PruningPasser(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *p = (struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *)o; + if (p->X) { + e = (*v)(((PyObject*)p->X), a); if (e) return e; + } + if (p->B) { + e = (*v)(((PyObject*)p->B), a); if (e) return e; + } + if (p->y) { + e = (*v)(((PyObject*)p->y), a); if (e) return e; + } + if (p->weights) { + e = (*v)(((PyObject*)p->weights), a); if (e) return e; + } + if (p->basis) { + e = (*v)(((PyObject*)p->basis), a); if (e) return e; + } + if (p->record) { + e = (*v)(((PyObject*)p->record), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_8_pruning_PruningPasser(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *p = (struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *)o; + PyObject* tmp; + tmp = ((PyObject*)p->X); + p->X = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->B); + p->B = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->y); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->weights); + p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->basis); + p->basis = ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->record); + p->record = ((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_8_pruning_PruningPasser[] = { + {__Pyx_NAMESTR("run"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_3run, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("trace"), (PyCFunction)__pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_5trace, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_8_pruning_PruningPasser = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._pruning.PruningPasser"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_8_pruning_PruningPasser, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("Implements the generic pruning pass as described by Friedman, 1991."), /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_8_pruning_PruningPasser, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_8_pruning_PruningPasser, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_8_pruning_PruningPasser, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_8_pruning_13PruningPasser_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_8_pruning_PruningPasser, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + __Pyx_NAMESTR("_pruning"), + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_u_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 1, 0, 0}, + {&__pyx_kp_u_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 1, 0, 0}, + {&__pyx_kp_u_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0, 0}, + {&__pyx_kp_u_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 1, 0, 0}, + {&__pyx_kp_u_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0, 0}, + {&__pyx_kp_u_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 1, 0, 0}, + {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, + {&__pyx_n_s__X, __pyx_k__X, sizeof(__pyx_k__X), 0, 0, 1, 1}, + {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, + {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_getbuffer, __pyx_k____pyx_getbuffer, sizeof(__pyx_k____pyx_getbuffer), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_releasebuffer, __pyx_k____pyx_releasebuffer, sizeof(__pyx_k____pyx_releasebuffer), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_vtable__, __pyx_k____pyx_vtable__, sizeof(__pyx_k____pyx_vtable__), 0, 0, 1, 1}, + {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s__average, __pyx_k__average, sizeof(__pyx_k__average), 0, 0, 1, 1}, + {&__pyx_n_s__basis, __pyx_k__basis, sizeof(__pyx_k__basis), 0, 0, 1, 1}, + {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1}, + {&__pyx_n_s__dot, __pyx_k__dot, sizeof(__pyx_k__dot), 0, 0, 1, 1}, + {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1}, + {&__pyx_n_s__empty, __pyx_k__empty, sizeof(__pyx_k__empty), 0, 0, 1, 1}, + {&__pyx_n_s__float, __pyx_k__float, sizeof(__pyx_k__float), 0, 0, 1, 1}, + {&__pyx_n_s__is_prunable, __pyx_k__is_prunable, sizeof(__pyx_k__is_prunable), 0, 0, 1, 1}, + {&__pyx_n_s__is_pruned, __pyx_k__is_pruned, sizeof(__pyx_k__is_pruned), 0, 0, 1, 1}, + {&__pyx_n_s__linalg, __pyx_k__linalg, sizeof(__pyx_k__linalg), 0, 0, 1, 1}, + {&__pyx_n_s__lstsq, __pyx_k__lstsq, sizeof(__pyx_k__lstsq), 0, 0, 1, 1}, + {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, + {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, + {&__pyx_n_s__penalty, __pyx_k__penalty, sizeof(__pyx_k__penalty), 0, 0, 1, 1}, + {&__pyx_n_s__prune, __pyx_k__prune, sizeof(__pyx_k__prune), 0, 0, 1, 1}, + {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, + {&__pyx_n_s__run, __pyx_k__run, sizeof(__pyx_k__run), 0, 0, 1, 1}, + {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1}, + {&__pyx_n_s__sum, __pyx_k__sum, sizeof(__pyx_k__sum), 0, 0, 1, 1}, + {&__pyx_n_s__trace, __pyx_k__trace, sizeof(__pyx_k__trace), 0, 0, 1, 1}, + {&__pyx_n_s__unprune, __pyx_k__unprune, sizeof(__pyx_k__unprune), 0, 0, 1, 1}, + {&__pyx_n_s__weights, __pyx_k__weights, sizeof(__pyx_k__weights), 0, 0, 1, 1}, + {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "sklearn/earth/_pruning.pyx":50 + * apply_weights_1d(weighted_y, weights) + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq(B[:, 0:(basis_size)], weighted_y)[0:2] # <<<<<<<<<<<<<< + * if mse: + * mse /= self.m + */ + __pyx_k_slice_1 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_1); + __Pyx_GIVEREF(__pyx_k_slice_1); + __pyx_k_slice_2 = PySlice_New(__pyx_int_0, __pyx_int_2, Py_None); if (unlikely(!__pyx_k_slice_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_2); + __Pyx_GIVEREF(__pyx_k_slice_2); + + /* "sklearn/earth/_pruning.pyx":55 + * else: + * mse = (1.0 / self.m) * np.sum( + * (np.dot(B[:, 0:basis_size], beta) - weighted_y) ** 2) # <<<<<<<<<<<<<< + * + * # Create the record object + */ + __pyx_k_slice_3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_3); + __Pyx_GIVEREF(__pyx_k_slice_3); + + /* "sklearn/earth/_pruning.pyx":79 + * self.basis.weighted_transform(X, B, weights) + * beta, mse = np.linalg.lstsq( + * B[:, 0:pruned_basis_size], weighted_y)[0:2] # <<<<<<<<<<<<<< + * if mse: + * mse /= self.m + */ + __pyx_k_slice_4 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_4); + __Pyx_GIVEREF(__pyx_k_slice_4); + __pyx_k_slice_5 = PySlice_New(__pyx_int_0, __pyx_int_2, Py_None); if (unlikely(!__pyx_k_slice_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_5); + __Pyx_GIVEREF(__pyx_k_slice_5); + + /* "sklearn/earth/_pruning.pyx":84 + * else: + * mse = (1 / float(self.m)) * np.sum( + * (np.dot(B[:, 0:pruned_basis_size], beta) - weighted_y) ** 2) # <<<<<<<<<<<<<< + * gcv_ = gcv(mse, pruned_basis_size, self.m, self.penalty) + * + */ + __pyx_k_slice_6 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_slice_6); + __Pyx_GIVEREF(__pyx_k_slice_6); + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_k_tuple_8 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_7)); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_8); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8)); + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_k_tuple_10 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_9)); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_10); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_k_tuple_12 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_11)); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_12); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12)); + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_k_tuple_15 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_14)); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_15); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15)); + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_k_tuple_16 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_11)); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_16); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16)); + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_k_tuple_18 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_17)); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_18); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18)); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_pruning(void); /*proto*/ +PyMODINIT_FUNC init_pruning(void) +#else +PyMODINIT_FUNC PyInit__pruning(void); /*proto*/ +PyMODINIT_FUNC PyInit__pruning(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__pruning(void)", 0); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __Pyx_CyFunction_USED + if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_pruning"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_d); + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "sklearn.earth._pruning")) { + if (unlikely(PyDict_SetItemString(modules, "sklearn.earth._pruning", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + } + #endif + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + /*--- Initialize various global constants etc. ---*/ + if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if (__pyx_module_is_main_sklearn__earth___pruning) { + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + /*--- Builtin init code ---*/ + if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Constants init code ---*/ + if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_7sklearn_5earth_8_pruning_PruningPasser = &__pyx_vtable_7sklearn_5earth_8_pruning_PruningPasser; + __pyx_vtable_7sklearn_5earth_8_pruning_PruningPasser.run = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_8_pruning_13PruningPasser_run; + __pyx_vtable_7sklearn_5earth_8_pruning_PruningPasser.trace = (struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *(*)(struct __pyx_obj_7sklearn_5earth_8_pruning_PruningPasser *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_8_pruning_13PruningPasser_trace; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_8_pruning_PruningPasser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_8_pruning_PruningPasser.tp_dict, __pyx_vtabptr_7sklearn_5earth_8_pruning_PruningPasser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "PruningPasser", (PyObject *)&__pyx_type_7sklearn_5earth_8_pruning_PruningPasser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_8_pruning_PruningPasser = &__pyx_type_7sklearn_5earth_8_pruning_PruningPasser; + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = __Pyx_ImportType("sklearn.earth._basis", "BasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "ConstantBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "HingeBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "LinearBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_Basis = __Pyx_ImportType("sklearn.earth._basis", "Basis", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_Basis), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_Basis)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_Basis = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_Basis->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_Basis)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_Record = __Pyx_ImportType("sklearn.earth._record", "Record", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_Record), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_Record)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_Record = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_Record->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_Record)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord = __Pyx_ImportType("sklearn.earth._record", "PruningPassRecord", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord = __Pyx_ImportType("sklearn.earth._record", "ForwardPassRecord", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_Iteration = __Pyx_ImportType("sklearn.earth._record", "Iteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_Iteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_Iteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_Iteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_Iteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_Iteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration = __Pyx_ImportType("sklearn.earth._record", "PruningPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration = __Pyx_ImportType("sklearn.earth._record", "FirstPruningPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration = __Pyx_ImportType("sklearn.earth._record", "ForwardPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration = __Pyx_ImportType("sklearn.earth._record", "FirstForwardPassIteration", sizeof(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + __pyx_t_1 = __Pyx_ImportModule("sklearn.earth._util"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "apply_weights_1d", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_apply_weights_1d, "PyObject *(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_1, "gcv", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_gcv, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_FLOAT_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; + /*--- Execution code ---*/ + + /* "sklearn/earth/_pruning.pyx":9 + * from ._record cimport PruningPassIteration + * from ._util cimport gcv, apply_weights_1d + * import numpy as np # <<<<<<<<<<<<<< + * + * cdef class PruningPasser: + */ + __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s__np, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_pruning.pyx":1 + * # distutils: language = c # <<<<<<<<<<<<<< + * # cython: cdivision = True + * # cython: boundscheck = False + */ + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + + /* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + if (__pyx_m) { + __Pyx_AddTraceback("init sklearn.earth._pruning", __pyx_clineno, __pyx_lineno, __pyx_filename); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init sklearn.earth._pruning"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* Runtime support code */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%s() got an unexpected keyword argument '%s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) /* First char was not a digit */ + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; /* Consume from buffer string */ + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; /* breaks both loops as ctx->enc_count == 0 */ + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; /* empty struct */ + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + if (isspace(*ts)) + continue; + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case 10: + case 13: + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': /* substruct */ + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': /* end of substruct; either repeat or move on */ + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } /* fall through */ + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 's': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + } else { + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + } + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON + result = PyDict_GetItem(__pyx_d, name); + if (result) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( + PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, + int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { +#if CYTHON_COMPILING_IN_CPYTHON + PyMappingMethods* mp; +#if PY_MAJOR_VERSION < 3 + PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; + if (likely(ms && ms->sq_slice)) { + if (!has_cstart) { + if (_py_start && (*_py_start != Py_None)) { + cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); + if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstart = 0; + } + if (!has_cstop) { + if (_py_stop && (*_py_stop != Py_None)) { + cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); + if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstop = PY_SSIZE_T_MAX; + } + if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { + Py_ssize_t l = ms->sq_length(obj); + if (likely(l >= 0)) { + if (cstop < 0) { + cstop += l; + if (cstop < 0) cstop = 0; + } + if (cstart < 0) { + cstart += l; + if (cstart < 0) cstart = 0; + } + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + goto bad; + } + } + return ms->sq_slice(obj, cstart, cstop); + } +#endif + mp = Py_TYPE(obj)->tp_as_mapping; + if (likely(mp && mp->mp_subscript)) +#endif + { + PyObject* result; + PyObject *py_slice, *py_start, *py_stop; + if (_py_slice) { + py_slice = *_py_slice; + } else { + PyObject* owned_start = NULL; + PyObject* owned_stop = NULL; + if (_py_start) { + py_start = *_py_start; + } else { + if (has_cstart) { + owned_start = py_start = PyInt_FromSsize_t(cstart); + if (unlikely(!py_start)) goto bad; + } else + py_start = Py_None; + } + if (_py_stop) { + py_stop = *_py_stop; + } else { + if (has_cstop) { + owned_stop = py_stop = PyInt_FromSsize_t(cstop); + if (unlikely(!py_stop)) { + Py_XDECREF(owned_start); + goto bad; + } + } else + py_stop = Py_None; + } + py_slice = PySlice_New(py_start, py_stop, Py_None); + Py_XDECREF(owned_start); + Py_XDECREF(owned_stop); + if (unlikely(!py_slice)) goto bad; + } +#if CYTHON_COMPILING_IN_CPYTHON + result = mp->mp_subscript(obj, py_slice); +#else + result = PyObject_GetItem(obj, py_slice); +#endif + if (!_py_slice) { + Py_DECREF(py_slice); + } + return result; + } + PyErr_Format(PyExc_TypeError, + "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); +bad: + return NULL; +} + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + index, (index == 1) ? "" : "s"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return NULL; + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + #if PY_VERSION_HEX < 0x02050000 + if (PyClass_Check(type)) { + #else + if (PyType_Check(type)) { + #endif +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + #if PY_VERSION_HEX < 0x02050000 + if (PyInstance_Check(type)) { + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + Py_INCREF(type); + } else { + type = 0; + PyErr_SetString(PyExc_TypeError, + "raise: exception must be an old-style class or instance"); + goto raise_error; + } + #else + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + #endif + } + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else /* Python 3+ */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s____pyx_vtable__, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +static void* __Pyx_GetVtable(PyObject *dict) { + void* ptr; + PyObject *ob = PyObject_GetItem(dict, __pyx_n_s____pyx_vtable__); + if (!ob) + goto bad; +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + ptr = PyCapsule_GetPointer(ob, 0); +#else + ptr = PyCObject_AsVoidPtr(ob); +#endif + if (!ptr && !PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); + Py_DECREF(ob); + return ptr; +bad: + Py_XDECREF(ob); + return NULL; +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *getbuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_getbuffer); + if (getbuffer_cobj) { + getbufferproc func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj); + Py_DECREF(getbuffer_cobj); + if (!func) + goto fail; + return func(obj, view, flags); + } else { + PyErr_Clear(); + } + } + #endif + PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *releasebuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_releasebuffer); + if (releasebuffer_cobj) { + releasebufferproc func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj); + Py_DECREF(releasebuffer_cobj); + if (!func) + goto fail; + func(obj, view); + return; + } else { + PyErr_Clear(); + } + } + #endif + goto nofail; +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + PyErr_WriteUnraisable(obj); +nofail: + Py_DECREF(obj); + view->obj = NULL; +} +#endif /* PY_MAJOR_VERSION < 3 */ + + + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + #if PY_VERSION_HEX >= 0x02050000 + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; /* try absolute import on failure */ + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } + #else + if (level>0) { + PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); + goto bad; + } + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, NULL); + #endif +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong val) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(npy_ulonglong) == sizeof(char)) || + (sizeof(npy_ulonglong) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(npy_ulonglong) == sizeof(int)) || + (sizeof(npy_ulonglong) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); + else + return PyLong_FromLongLong((PY_LONG_LONG)val); + } else { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + return _PyLong_FromByteArray(bytes, sizeof(npy_ulonglong), + little, !is_unsigned); + } +} + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject* x) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if (sizeof(npy_ulonglong) == sizeof(char)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedChar(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedChar(x); + } else if (sizeof(npy_ulonglong) == sizeof(short)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedShort(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedShort(x); + } else if (sizeof(npy_ulonglong) == sizeof(int)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedInt(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedInt(x); + } else if (sizeof(npy_ulonglong) == sizeof(long)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLong(x); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLongLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLongLong(x); + } else { + #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); + #else + npy_ulonglong val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } + #endif + return (npy_ulonglong)-1; + } +} + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { + const unsigned char neg_one = (unsigned char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned char" : + "value too large to convert to unsigned char"); + } + return (unsigned char)-1; + } + return (unsigned char)val; + } + return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { + const unsigned short neg_one = (unsigned short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned short" : + "value too large to convert to unsigned short"); + } + return (unsigned short)-1; + } + return (unsigned short)val; + } + return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { + const unsigned int neg_one = (unsigned int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned int" : + "value too large to convert to unsigned int"); + } + return (unsigned int)-1; + } + return (unsigned int)val; + } + return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { + const char neg_one = (char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to char" : + "value too large to convert to char"); + } + return (char)-1; + } + return (char)val; + } + return (char)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { + const short neg_one = (short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to short" : + "value too large to convert to short"); + } + return (short)-1; + } + return (short)val; + } + return (short)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { + const signed char neg_one = (signed char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed char" : + "value too large to convert to signed char"); + } + return (signed char)-1; + } + return (signed char)val; + } + return (signed char)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { + const signed short neg_one = (signed short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed short" : + "value too large to convert to signed short"); + } + return (signed short)-1; + } + return (signed short)val; + } + return (signed short)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { + const signed int neg_one = (signed int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed int" : + "value too large to convert to signed int"); + } + return (signed int)-1; + } + return (signed int)val; + } + return (signed int)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { + const unsigned long neg_one = (unsigned long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned long)PyLong_AsLong(x); + } + } else { + unsigned long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned long)-1; + val = __Pyx_PyInt_AsUnsignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { + const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + unsigned PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsUnsignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { + const long neg_one = (long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (long)PyLong_AsLong(x); + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (long)-1; + val = __Pyx_PyInt_AsLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { + const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { + const signed long neg_one = (signed long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed long)PyLong_AsLong(x); + } + } else { + signed long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed long)-1; + val = __Pyx_PyInt_AsSignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { + const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + signed PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsSignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + #if PY_VERSION_HEX < 0x02050000 + return PyErr_Warn(NULL, message); + #else + return PyErr_WarnEx(NULL, message, 1); + #endif + } + return 0; +} + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility", + module_name, class_name); + #if PY_VERSION_HEX < 0x02050000 + if (PyErr_Warn(NULL, warning) < 0) goto bad; + #else + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + #endif + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s has the wrong size, try recompiling", + module_name, class_name); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportFunction +#define __PYX_HAVE_RT_ImportFunction +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, funcname); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%s does not export expected C function %s", + PyModule_GetName(module), funcname); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); + goto bad; + } + tmp.p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, desc); + goto bad; + } + tmp.p = PyCObject_AsVoidPtr(cobj);} +#endif + *f = tmp.fp; + if (!(*f)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = (start + end) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, /*int firstlineno,*/ + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_globals = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else /* Python 3+ has unicode identifiers */ + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else /* PY_VERSION_HEX < 0x03030000 */ + if (PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_DATA_SIZE(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ + return PyUnicode_AsUTF8AndSize(o, length); +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ +#endif /* PY_VERSION_HEX < 0x03030000 */ + } else +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (r < 0) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return Py_INCREF(x), x; + m = Py_TYPE(x)->tp_as_number; +#if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%s__ returned non-%s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject* x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { +#if PY_VERSION_HEX < 0x02050000 + if (ival <= LONG_MAX) + return PyInt_FromLong((long)ival); + else { + unsigned char *bytes = (unsigned char *) &ival; + int one = 1; int little = (int)*(unsigned char*)&one; + return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); + } +#else + return PyInt_FromSize_t(ival); +#endif +} +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { + unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); + if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t)-1; + } + return (size_t)val; +} + + +#endif /* Py_PYTHON_H */ diff --git a/sklearn/earth/_pruning.pxd b/sklearn/earth/_pruning.pxd new file mode 100644 index 0000000000000..86b31942849c4 --- /dev/null +++ b/sklearn/earth/_pruning.pxd @@ -0,0 +1,23 @@ +cimport numpy as cnp +ctypedef cnp.float64_t FLOAT_t +ctypedef cnp.intp_t INT_t +ctypedef cnp.ulong_t INDEX_t +ctypedef cnp.uint8_t BOOL_t +from _basis cimport Basis +from _record cimport PruningPassRecord + +cdef class PruningPasser: + cdef cnp.ndarray X + cdef cnp.ndarray B + cdef cnp.ndarray y + cdef cnp.ndarray weights + cdef INDEX_t m + cdef INDEX_t n + cdef Basis basis + cdef FLOAT_t penalty + cdef FLOAT_t sst + cdef PruningPassRecord record + + cpdef run(PruningPasser self) + + cpdef PruningPassRecord trace(PruningPasser self) diff --git a/sklearn/earth/_pruning.pyx b/sklearn/earth/_pruning.pyx new file mode 100644 index 0000000000000..c5bb6c8a851ac --- /dev/null +++ b/sklearn/earth/_pruning.pyx @@ -0,0 +1,111 @@ +# distutils: language = c +# cython: cdivision = True +# cython: boundscheck = False +# cython: wraparound = False +# cython: profile = False + +from ._record cimport PruningPassIteration +from ._util cimport gcv, apply_weights_1d +import numpy as np + +cdef class PruningPasser: + '''Implements the generic pruning pass as described by Friedman, 1991.''' + def __init__(PruningPasser self, Basis basis, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights, **kwargs): + self.X = X + self.m = self.X.shape[0] + self.n = self.X.shape[1] + self.y = y + self.weights = weights + self.basis = basis + self.B = np.empty(shape=(self.m, len(self.basis) + 1), dtype=np.float) + self.penalty = kwargs['penalty'] if 'penalty' in kwargs else 3.0 + self.sst = np.sum( + self.weights * (self.y - np.average(self.y, weights=self.weights)) ** 2) / self.m + + cpdef run(PruningPasser self): + # This is a totally naive implementation and could potentially be made faster + # through the use of updating algorithms. It is not clear that such + # optimization would be worthwhile, as the pruning pass is not the slowest + # part of the algorithm. + cdef INDEX_t i + cdef INDEX_t j + cdef INDEX_t basis_size = len(self.basis) + cdef INDEX_t pruned_basis_size = self.basis.plen() + cdef FLOAT_t gcv_ + cdef INDEX_t best_iteration + cdef INDEX_t best_bf_to_prune + cdef FLOAT_t best_gcv + cdef FLOAT_t best_iteration_gcv + cdef FLOAT_t best_iteration_mse + + cdef cnp.ndarray[FLOAT_t, ndim = 2] B = self.B + cdef cnp.ndarray[FLOAT_t, ndim = 2] X = self.X + cdef cnp.ndarray[FLOAT_t, ndim = 1] y = self.y + cdef cnp.ndarray[FLOAT_t, ndim = 1] weights = self.weights + cdef cnp.ndarray[FLOAT_t, ndim = 1] weighted_y = y.copy() + + # Initial solution + apply_weights_1d(weighted_y, weights) + self.basis.weighted_transform(X, B, weights) + beta, mse = np.linalg.lstsq(B[:, 0:(basis_size)], weighted_y)[0:2] + if mse: + mse /= self.m + else: + mse = (1.0 / self.m) * np.sum( + (np.dot(B[:, 0:basis_size], beta) - weighted_y) ** 2) + + # Create the record object + self.record = PruningPassRecord( + self.m, self.n, self.penalty, self.sst, pruned_basis_size, mse) + gcv_ = self.record.gcv(0) + best_gcv = gcv_ + best_iteration = 0 + + # Prune basis functions sequentially + for i in range(1, pruned_basis_size): + first = True + pruned_basis_size -= 1 + + # Find the best basis function to prune + for j in range(basis_size): + bf = self.basis[j] + if bf.is_pruned(): + continue + if not bf.is_prunable(): + continue + bf.prune() + self.basis.weighted_transform(X, B, weights) + beta, mse = np.linalg.lstsq( + B[:, 0:pruned_basis_size], weighted_y)[0:2] + if mse: + mse /= self.m + else: + mse = (1 / float(self.m)) * np.sum( + (np.dot(B[:, 0:pruned_basis_size], beta) - weighted_y) ** 2) + gcv_ = gcv(mse, pruned_basis_size, self.m, self.penalty) + + if gcv_ <= best_iteration_gcv or first: + best_iteration_gcv = gcv_ + best_iteration_mse = mse + best_bf_to_prune = j + first = False + bf.unprune() + + # The inner loop found the best basis function to remove for this iteration. + # Now check whether this iteration is better than all the previous + # ones. + if best_iteration_gcv <= best_gcv: + best_gcv = best_iteration_gcv + best_iteration = i + + # Update the record and prune the selected basis function + self.record.append(PruningPassIteration( + best_bf_to_prune, pruned_basis_size, best_iteration_mse)) + self.basis[best_bf_to_prune].prune() + + # Unprune the basis functions pruned after the best iteration + self.record.set_selected(best_iteration) + self.record.roll_back(self.basis) + + cpdef PruningPassRecord trace(PruningPasser self): + return self.record diff --git a/sklearn/earth/_record.c b/sklearn/earth/_record.c new file mode 100644 index 0000000000000..34e3df2db07ab --- /dev/null +++ b/sklearn/earth/_record.c @@ -0,0 +1,13478 @@ +/* Generated by Cython 0.19.2 on Sat Nov 30 16:32:13 2013 */ + +#define PY_SSIZE_T_CLEAN +#ifndef CYTHON_USE_PYLONG_INTERNALS +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 0 +#else +#include "pyconfig.h" +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 1 +#else +#define CYTHON_USE_PYLONG_INTERNALS 0 +#endif +#endif +#endif +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02040000 + #error Cython requires Python 2.4+. +#else +#include /* For offsetof */ +#ifndef offsetof +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION +#define CYTHON_COMPILING_IN_PYPY 1 +#define CYTHON_COMPILING_IN_CPYTHON 0 +#else +#define CYTHON_COMPILING_IN_PYPY 0 +#define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if PY_VERSION_HEX < 0x02050000 + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ + (PyErr_Format(PyExc_TypeError, \ + "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ + (PyObject*)0)) + #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ + !PyComplex_Check(o)) + #define PyIndex_Check __Pyx_PyIndex_Check + #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) + #define __PYX_BUILD_PY_SSIZE_T "i" +#else + #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" + #define __Pyx_PyIndex_Check PyIndex_Check +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) + #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) + #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + #define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + #define PyType_Modified(t) + typedef struct { + void *buf; + PyObject *obj; + Py_ssize_t len; + Py_ssize_t itemsize; + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; + } Py_buffer; + #define PyBUF_SIMPLE 0 + #define PyBUF_WRITABLE 0x0001 + #define PyBUF_FORMAT 0x0004 + #define PyBUF_ND 0x0008 + #define PyBUF_STRIDES (0x0010 | PyBUF_ND) + #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) + #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) + #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) + #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) + #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) + typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); + typedef void (*releasebufferproc)(PyObject *, Py_buffer *); +#endif +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif +#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 + #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") +#endif +#if PY_MAJOR_VERSION >= 3 + #define Py_TPFLAGS_CHECKTYPES 0 + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_TPFLAGS_HAVE_VERSION_TAG 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PyBytesObject PyStringObject + #define PyBytes_Type PyString_Type + #define PyBytes_Check PyString_Check + #define PyBytes_CheckExact PyString_CheckExact + #define PyBytes_FromString PyString_FromString + #define PyBytes_FromStringAndSize PyString_FromStringAndSize + #define PyBytes_FromFormat PyString_FromFormat + #define PyBytes_DecodeEscape PyString_DecodeEscape + #define PyBytes_AsString PyString_AsString + #define PyBytes_AsStringAndSize PyString_AsStringAndSize + #define PyBytes_Size PyString_Size + #define PyBytes_AS_STRING PyString_AS_STRING + #define PyBytes_GET_SIZE PyString_GET_SIZE + #define PyBytes_Repr PyString_Repr + #define PyBytes_Concat PyString_Concat + #define PyBytes_ConcatAndDel PyString_ConcatAndDel +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ + PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) + #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) + #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) + #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) +#else + #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) + #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) +#else + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_NAMESTR(n) ((char *)(n)) + #define __Pyx_DOCSTR(n) ((char *)(n)) +#else + #define __Pyx_NAMESTR(n) (n) + #define __Pyx_DOCSTR(n) (n) +#endif +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + a quiet NaN. */ + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif + + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) +#define _USE_MATH_DEFINES +#endif +#include +#define __PYX_HAVE__sklearn__earth___record +#define __PYX_HAVE_API__sklearn__earth___record +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) +#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) +#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return u_end - u - 1; +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + const char* default_encoding_c = PyBytes_AS_STRING(default_encoding); + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (ascii_chars_u == NULL) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + } + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + default_encoding_c = PyBytes_AS_STRING(default_encoding); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(sys); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +#ifdef __GNUC__ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ +#else /* __GNUC__ */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "_record.pyx", + "numpy.pxd", + "type.pxd", + "_basis.pxd", + "_forward.pxd", +}; + +/* "numpy.pxd":723 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "numpy.pxd":724 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "numpy.pxd":725 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "numpy.pxd":726 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "numpy.pxd":730 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "numpy.pxd":731 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "numpy.pxd":732 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "numpy.pxd":733 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "numpy.pxd":737 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "numpy.pxd":738 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "numpy.pxd":747 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "numpy.pxd":748 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "numpy.pxd":749 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "numpy.pxd":751 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "numpy.pxd":752 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "numpy.pxd":753 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "numpy.pxd":755 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "numpy.pxd":756 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "numpy.pxd":758 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "numpy.pxd":759 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "numpy.pxd":760 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "_basis.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_6_basis_FLOAT_t; + +/* "_basis.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_6_basis_INT_t; + +/* "_basis.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_6_basis_INDEX_t; + +/* "_basis.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef class BasisFunction: + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_6_basis_BOOL_t; + +/* "_util.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_5_util_FLOAT_t; + +/* "_util.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_5_util_INT_t; + +/* "_util.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_5_util_INDEX_t; + +/* "_util.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef FLOAT_t log2(FLOAT_t x) + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_5_util_BOOL_t; + +/* "_forward.pxd":3 + * cimport numpy as cnp + * import numpy as np + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_8_forward_FLOAT_t; + +/* "_forward.pxd":4 + * import numpy as np + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_8_forward_INT_t; + +/* "_forward.pxd":5 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * from _basis cimport Basis + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_8_forward_INDEX_t; + +/* "_forward.pxd":6 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * from _basis cimport Basis + * from _record cimport ForwardPassRecord + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_8_forward_BOOL_t; + +/* "sklearn/earth/_record.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_7_record_FLOAT_t; + +/* "sklearn/earth/_record.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_7_record_INT_t; + +/* "sklearn/earth/_record.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * from _basis cimport Basis + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_7_record_INDEX_t; + +/* "sklearn/earth/_record.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * from _basis cimport Basis + * + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_7_record_BOOL_t; +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis; +struct __pyx_obj_7sklearn_5earth_7_record_Iteration; +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration; +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction; +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction; +struct __pyx_obj_7sklearn_5earth_7_record_Record; +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord; +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord; +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction; +struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser; +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration; +struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration; +struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration; +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction; + +/* "numpy.pxd":762 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "numpy.pxd":763 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "numpy.pxd":764 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "numpy.pxd":766 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply; +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply; + +/* "_basis.pxd":45 + * cpdef INDEX_t degree(BasisFunction self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cpdef cnp.ndarray[INT_t, ndim = 1] valid_knots(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=1] values, cnp.ndarray[FLOAT_t, ndim=1] variable, int variable_idx, INDEX_t check_every, int endspan, int minspan, FLOAT_t minspan_alpha, INDEX_t n, cnp.ndarray[INT_t, ndim=1] workspace) + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":62 + * cpdef BasisFunction get_parent(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_21ConstantBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":86 + * cpdef INDEX_t get_knot_idx(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * cdef class LinearBasisFunction(BasisFunction): + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_18HingeBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_basis.pxd":98 + * cpdef INDEX_t get_variable(self) + * + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) # <<<<<<<<<<<<<< + * + * + */ +struct __pyx_opt_args_7sklearn_5earth_6_basis_19LinearBasisFunction_apply { + int __pyx_n; + int recurse; +}; + +/* "_forward.pxd":10 + * from _record cimport ForwardPassRecord + * + * ctypedef enum StoppingCondition: # <<<<<<<<<<<<<< + * MAXTERMS = 0, + * MAXRSQ = 1, + */ +enum __pyx_t_7sklearn_5earth_8_forward_StoppingCondition { + __pyx_e_7sklearn_5earth_8_forward_MAXTERMS = 0, + __pyx_e_7sklearn_5earth_8_forward_MAXRSQ = 1, + __pyx_e_7sklearn_5earth_8_forward_NOIMPRV = 2, + __pyx_e_7sklearn_5earth_8_forward_LOWGRSQ = 3, + __pyx_e_7sklearn_5earth_8_forward_NOCAND = 4 +}; +typedef enum __pyx_t_7sklearn_5earth_8_forward_StoppingCondition __pyx_t_7sklearn_5earth_8_forward_StoppingCondition; + +/* "_basis.pxd":101 + * + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A wrapper that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ +struct __pyx_obj_7sklearn_5earth_6_basis_Basis { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtab; + PyObject *order; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t num_variables; +}; + + +/* "sklearn/earth/_record.pxd":41 + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition) + * + * cdef class Iteration: # <<<<<<<<<<<<<< + * cdef FLOAT_t mse + * cdef INDEX_t size + */ +struct __pyx_obj_7sklearn_5earth_7_record_Iteration { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *__pyx_vtab; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t mse; + __pyx_t_7sklearn_5earth_7_record_INDEX_t size; +}; + + +/* "sklearn/earth/_record.pxd":57 + * pass + * + * cdef class ForwardPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t parent + * cdef INDEX_t variable + */ +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t parent; + __pyx_t_7sklearn_5earth_7_record_INDEX_t variable; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t knot; + int code; + int no_candidates; +}; + + +/* "_basis.pxd":7 + * ctypedef cnp.uint8_t BOOL_t + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + * + */ +struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtab; + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *parent; + PyObject *child_map; + PyObject *children; + int pruned; + int prunable; + int splittable; +}; + + +/* "_basis.pxd":50 + * + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(ConstantBasisFunction self) + */ +struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; +}; + + +/* "sklearn/earth/_record.pxd":8 + * from _basis cimport Basis + * + * cdef class Record: # <<<<<<<<<<<<<< + * cdef list iterations + * cdef int num_samples + */ +struct __pyx_obj_7sklearn_5earth_7_record_Record { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *__pyx_vtab; + PyObject *iterations; + int num_samples; + int num_variables; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t penalty; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t sst; +}; + + +/* "sklearn/earth/_record.pxd":25 + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration) + * + * cdef class PruningPassRecord(Record): # <<<<<<<<<<<<<< + * cdef INDEX_t selected + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord { + struct __pyx_obj_7sklearn_5earth_7_record_Record __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t selected; +}; + + +/* "sklearn/earth/_record.pxd":34 + * cpdef roll_back(PruningPassRecord self, Basis basis) + * + * cdef class ForwardPassRecord(Record): # <<<<<<<<<<<<<< + * cdef int stopping_condition + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord { + struct __pyx_obj_7sklearn_5earth_7_record_Record __pyx_base; + int stopping_condition; + PyObject *xlabels; +}; + + +/* "_basis.pxd":65 + * + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef FLOAT_t knot + * cdef INDEX_t knot_idx + */ +struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t knot; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t knot_idx; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + int reverse; + PyObject *label; +}; + + +/* "_forward.pxd":19 + * cdef dict stopping_conditions + * + * cdef class ForwardPasser: # <<<<<<<<<<<<<< + * + * # User selected parameters + */ +struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser { + PyObject_HEAD + struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *__pyx_vtab; + int endspan; + int minspan; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t endspan_alpha; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t minspan_alpha; + int max_terms; + int allow_linear; + int max_degree; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t thresh; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t penalty; + int check_every; + int min_search_points; + PyObject *xlabels; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t zero_tol; + PyArrayObject *X; + PyArrayObject *y; + PyArrayObject *sample_weight; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t m; + __pyx_t_7sklearn_5earth_8_forward_INDEX_t n; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t sst; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t y_squared; + PyArrayObject *B; + PyArrayObject *B_orth; + PyArrayObject *c; + PyArrayObject *norms; + PyArrayObject *u; + PyArrayObject *B_orth_times_parent_cum; + __pyx_t_7sklearn_5earth_8_forward_FLOAT_t c_squared; + PyArrayObject *sort_tracker; + PyArrayObject *sorting; + PyArrayObject *mwork; + PyArrayObject *linear_variables; + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *record; + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *basis; +}; + + +/* "sklearn/earth/_record.pxd":49 + * cpdef INDEX_t get_size(Iteration self) + * + * cdef class PruningPassIteration(Iteration): # <<<<<<<<<<<<<< + * cdef INDEX_t pruned + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t pruned; +}; + + +/* "sklearn/earth/_record.pxd":54 + * cpdef INDEX_t get_pruned(PruningPassIteration self) + * + * cdef class FirstPruningPassIteration(PruningPassIteration): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration __pyx_base; +}; + + +/* "sklearn/earth/_record.pxd":68 + * cpdef no_further_candidates(ForwardPassIteration self) + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): # <<<<<<<<<<<<<< + * cpdef INDEX_t get_size(FirstForwardPassIteration self) + */ +struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration { + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration __pyx_base; +}; + + +/* "_basis.pxd":88 + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef str label + */ +struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + __pyx_t_7sklearn_5earth_6_basis_INDEX_t variable; + PyObject *label; +}; + + + +/* "sklearn/earth/_record.pyx":151 + * return result + * + * cdef class Iteration: # <<<<<<<<<<<<<< + * + * def __richcmp__(self, other, method): + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*get_mse)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_size)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *__pyx_vtabptr_7sklearn_5earth_7_record_Iteration; + + +/* "sklearn/earth/_record.pyx":170 + * return self.size + * + * cdef class PruningPassIteration(Iteration): # <<<<<<<<<<<<<< + * def __init__(PruningPassIteration self, INDEX_t pruned, INDEX_t size, FLOAT_t mse): + * self.pruned = pruned + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration __pyx_base; + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_pruned)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration; + + +/* "_basis.pxd":7 + * ctypedef cnp.uint8_t BOOL_t + * + * cdef class BasisFunction: # <<<<<<<<<<<<<< + * '''Abstract. Subclasses must implement the apply, translate, scale, and __init__ methods.''' + * + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction { + int (*has_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_prunable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_pruned)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*is_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_splittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + int (*make_unsplittable)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*get_children)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *); + PyObject *(*_set_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*_add_child)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_parent)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*prune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*unprune)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*degree)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + PyObject *(*apply)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_7sklearn_5earth_6_basis_13BasisFunction_apply *__pyx_optional_args); + PyArrayObject *(*valid_knots)(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, PyArrayObject *, PyArrayObject *, int, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int, int, __pyx_t_7sklearn_5earth_6_basis_FLOAT_t, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction; + + +/* "_basis.pxd":88 + * cpdef apply(self, cnp.ndarray[FLOAT_t, ndim=2] X, cnp.ndarray[FLOAT_t, ndim=1] b, bint recurse= ?) + * + * cdef class LinearBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef INDEX_t variable + * cdef str label + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction; + + +/* "sklearn/earth/_record.pyx":10 + * from ._forward cimport stopping_conditions + * + * cdef class Record: # <<<<<<<<<<<<<< + * + * def __richcmp__(self, other, method): + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record { + PyObject *(*append)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*mse)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*rsq)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*gcv)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_FLOAT_t (*grsq)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *__pyx_vtabptr_7sklearn_5earth_7_record_Record; + + +/* "sklearn/earth/_record.pyx":52 + * return 1 - (gcv_ / gcv0) + * + * cdef class PruningPassRecord(Record): # <<<<<<<<<<<<<< + * def __init__(PruningPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, INDEX_t size, FLOAT_t mse): + * self.num_samples = num_samples + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record __pyx_base; + PyObject *(*set_selected)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_7_record_INDEX_t (*get_selected)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, int __pyx_skip_dispatch); + PyObject *(*roll_back)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord; + + +/* "_forward.pxd":19 + * cdef dict stopping_conditions + * + * cdef class ForwardPasser: # <<<<<<<<<<<<<< + * + * # User selected parameters + */ + +struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser { + struct __pyx_obj_7sklearn_5earth_6_basis_Basis *(*get_basis)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch); + PyObject *(*init_linear_variables)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch); + PyObject *(*run)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, int __pyx_skip_dispatch); + PyObject *(*stop_check)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *); + int (*orthonormal_update)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*orthonormal_downdate)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*next_pair)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *); + PyObject *(*best_knot)(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, __pyx_t_7sklearn_5earth_8_forward_INDEX_t, PyArrayObject *, PyArrayObject *, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_t_7sklearn_5earth_8_forward_FLOAT_t *, __pyx_t_7sklearn_5earth_8_forward_INDEX_t *); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser *__pyx_vtabptr_7sklearn_5earth_8_forward_ForwardPasser; + + +/* "_basis.pxd":65 + * + * + * cdef class HingeBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * cdef FLOAT_t knot + * cdef INDEX_t knot_idx + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_variable)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*get_knot)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + int (*get_reverse)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*get_knot_idx)(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction; + + +/* "_basis.pxd":50 + * + * + * cdef class ConstantBasisFunction(BasisFunction): # <<<<<<<<<<<<<< + * + * cpdef INDEX_t degree(ConstantBasisFunction self) + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction { + struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction __pyx_base; + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_FLOAT_t (*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction *__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction; + + +/* "sklearn/earth/_record.pyx":105 + * return result + * + * cdef class ForwardPassRecord(Record): # <<<<<<<<<<<<<< + * def __init__(ForwardPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, list xlabels): + * self.num_samples = num_samples + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record __pyx_base; + PyObject *(*set_stopping_condition)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *, int, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord; + + +/* "sklearn/earth/_record.pyx":218 + * return result + * + * cdef class ForwardPassIteration(Iteration): # <<<<<<<<<<<<<< + * def __init__(ForwardPassIteration self, INDEX_t parent, INDEX_t variable, int knot, FLOAT_t mse, INDEX_t size): + * self.parent = parent + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration __pyx_base; + PyObject *(*set_no_candidates)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int, int __pyx_skip_dispatch); + PyObject *(*no_further_candidates)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration; + + +/* "_basis.pxd":101 + * + * + * cdef class Basis: # <<<<<<<<<<<<<< + * '''A wrapper that provides functionality related to a set of BasisFunctions with a + * common ConstantBasisFunction ancestor. Retains the order in which BasisFunctions are + */ + +struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis { + PyObject *(*translate)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*scale)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get_root)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + PyObject *(*append)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *, int __pyx_skip_dispatch); + __pyx_t_7sklearn_5earth_6_basis_INDEX_t (*plen)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch); + struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction *(*get)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, __pyx_t_7sklearn_5earth_6_basis_INDEX_t, int __pyx_skip_dispatch); + PyObject *(*transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*weighted_transform)(struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis *__pyx_vtabptr_7sklearn_5earth_6_basis_Basis; + + +/* "sklearn/earth/_record.pyx":254 + * return self.no_candidates + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): # <<<<<<<<<<<<<< + * def __init__(FirstForwardPassIteration self, FLOAT_t mse): + * self.mse = mse + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration; + + +/* "sklearn/earth/_record.pyx":197 + * return result + * + * cdef class FirstPruningPassIteration(PruningPassIteration): # <<<<<<<<<<<<<< + * def __init__(PruningPassIteration self, INDEX_t size, FLOAT_t mse): + * self.size = size + */ + +struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration { + struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration; +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ + +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) + PyErr_SetObject(PyExc_KeyError, args); + Py_XDECREF(args); + } + return NULL; + } + Py_INCREF(value); + return value; +} +#else + #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#endif + +#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ + (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject *); + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong); + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); + +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); + +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); + +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); + +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); + +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); + +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); + +static int __Pyx_check_binary_version(void); + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + +static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig); /*proto*/ + +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/ + +typedef struct { + int code_line; + PyCodeObject* code_object; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'sklearn.earth._basis' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_6_basis_Basis = 0; + +/* Module declarations from 'sklearn.earth._util' */ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t (*__pyx_f_7sklearn_5earth_5_util_gcv)(__pyx_t_7sklearn_5earth_5_util_FLOAT_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch); /*proto*/ +static PyObject *(*__pyx_f_7sklearn_5earth_5_util_ascii_table)(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/ + +/* Module declarations from 'sklearn.earth._forward' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_8_forward_ForwardPasser = 0; +static PyObject **__pyx_vp_7sklearn_5earth_8_forward_stopping_conditions = 0; +#define __pyx_v_7sklearn_5earth_8_forward_stopping_conditions (*__pyx_vp_7sklearn_5earth_8_forward_stopping_conditions) + +/* Module declarations from 'sklearn.earth._record' */ +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_Iteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_Record = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration = 0; +static PyTypeObject *__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord = 0; +#define __Pyx_MODULE_NAME "sklearn.earth._record" +int __pyx_module_is_main_sklearn__earth___record = 0; + +/* Implementation of 'sklearn.earth._record' */ +static PyObject *__pyx_builtin_NotImplemented; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_enumerate; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record___richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_2_eq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, PyObject *__pyx_v_other); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_4__getitem__(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, int __pyx_v_idx); /* proto */ +static Py_ssize_t __pyx_pf_7sklearn_5earth_7_record_6Record_6__len__(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_8append(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_iteration); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_10mse(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_12gcv(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_14rsq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_16grsq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration); /* proto */ +static int __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord___init__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_samples, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_variables, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_penalty, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_sst, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_8set_selected(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_selected); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_10get_selected(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_12roll_back(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_basis); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_14__str__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord___init__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_samples, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_variables, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_penalty, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_sst, PyObject *__pyx_v_xlabels); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_8set_stopping_condition(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self, int __pyx_v_stopping_condition); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_10__str__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration___richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration_2_eq(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self, PyObject *__pyx_v_other); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration_4get_mse(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration_6get_size(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_pruned, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_8get_pruned(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_10__str__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_8__str__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_parent, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_variable, int __pyx_v_knot, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_8__str__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_10set_no_candidates(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, int __pyx_v_value); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_12no_further_candidates(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self, PyObject *__pyx_v_state); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_8get_size(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_10__str__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_Iteration(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_ForwardPassIteration(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_Record(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_ForwardPassRecord(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_PruningPassIteration(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_FirstPruningPassIteration(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_FirstForwardPassIteration(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_PruningPassRecord(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static char __pyx_k_1[] = ""; +static char __pyx_k_2[] = "Pruning Pass\n"; +static char __pyx_k_3[] = "iter\tbf\tterms\tmse\tgcv\trsq\tgrsq"; +static char __pyx_k_4[] = "\t"; +static char __pyx_k_6[] = "\t%.3f\t%.3f\t%.3f"; +static char __pyx_k_8[] = "\nSelected iteration: "; +static char __pyx_k_9[] = "\n"; +static char __pyx_k_10[] = "set_stopping_condition"; +static char __pyx_k_12[] = "%.3f\t%.3f\t%.3f"; +static char __pyx_k_14[] = "Forward Pass\n"; +static char __pyx_k_15[] = "\nStopping Condition %d: %s\n"; +static char __pyx_k_16[] = "%s\t%s\t%s"; +static char __pyx_k_17[] = "%.2f"; +static char __pyx_k_18[] = "-"; +static char __pyx_k_19[] = "%d\t%d\t%d\t%4f\t%d"; +static char __pyx_k_20[] = "no_further_candidates"; +static char __pyx_k_21[] = "%s\t%s\t%s\t%4f\t%s"; +static char __pyx_k_22[] = "ndarray is not C contiguous"; +static char __pyx_k_24[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_26[] = "Non-native byte order not supported"; +static char __pyx_k_28[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_29[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_32[] = "Format string allocated too short."; +static char __pyx_k__B[] = "B"; +static char __pyx_k__H[] = "H"; +static char __pyx_k__I[] = "I"; +static char __pyx_k__L[] = "L"; +static char __pyx_k__O[] = "O"; +static char __pyx_k__Q[] = "Q"; +static char __pyx_k__b[] = "b"; +static char __pyx_k__d[] = "d"; +static char __pyx_k__f[] = "f"; +static char __pyx_k__g[] = "g"; +static char __pyx_k__h[] = "h"; +static char __pyx_k__i[] = "i"; +static char __pyx_k__l[] = "l"; +static char __pyx_k__q[] = "q"; +static char __pyx_k__Zd[] = "Zd"; +static char __pyx_k__Zf[] = "Zf"; +static char __pyx_k__Zg[] = "Zg"; +static char __pyx_k___eq[] = "_eq"; +static char __pyx_k__gcv[] = "gcv"; +static char __pyx_k__mse[] = "mse"; +static char __pyx_k__rsq[] = "rsq"; +static char __pyx_k__sst[] = "sst"; +static char __pyx_k__var[] = "var"; +static char __pyx_k__grsq[] = "grsq"; +static char __pyx_k__iter[] = "iter"; +static char __pyx_k__knot[] = "knot"; +static char __pyx_k__size[] = "size"; +static char __pyx_k__range[] = "range"; +static char __pyx_k__split[] = "split"; +static char __pyx_k__terms[] = "terms"; +static char __pyx_k__append[] = "append"; +static char __pyx_k__parent[] = "parent"; +static char __pyx_k__pruned[] = "pruned"; +static char __pyx_k__get_mse[] = "get_mse"; +static char __pyx_k__penalty[] = "penalty"; +static char __pyx_k__unprune[] = "unprune"; +static char __pyx_k__xlabels[] = "xlabels"; +static char __pyx_k____main__[] = "__main__"; +static char __pyx_k____test__[] = "__test__"; +static char __pyx_k__get_size[] = "get_size"; +static char __pyx_k__selected[] = "selected"; +static char __pyx_k__variable[] = "variable"; +static char __pyx_k____class__[] = "__class__"; +static char __pyx_k___getstate[] = "_getstate"; +static char __pyx_k__enumerate[] = "enumerate"; +static char __pyx_k__roll_back[] = "roll_back"; +static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k____import__[] = "__import__"; +static char __pyx_k__get_pruned[] = "get_pruned"; +static char __pyx_k__iterations[] = "iterations"; +static char __pyx_k__num_samples[] = "num_samples"; +static char __pyx_k__RuntimeError[] = "RuntimeError"; +static char __pyx_k__get_selected[] = "get_selected"; +static char __pyx_k__set_selected[] = "set_selected"; +static char __pyx_k__num_variables[] = "num_variables"; +static char __pyx_k__NotImplemented[] = "NotImplemented"; +static char __pyx_k____pyx_vtable__[] = "__pyx_vtable__"; +static char __pyx_k__set_no_candidates[] = "set_no_candidates"; +static PyObject *__pyx_kp_s_1; +static PyObject *__pyx_n_s_10; +static PyObject *__pyx_kp_s_12; +static PyObject *__pyx_kp_s_14; +static PyObject *__pyx_kp_s_15; +static PyObject *__pyx_kp_s_16; +static PyObject *__pyx_kp_s_17; +static PyObject *__pyx_kp_s_18; +static PyObject *__pyx_kp_s_19; +static PyObject *__pyx_kp_s_2; +static PyObject *__pyx_n_s_20; +static PyObject *__pyx_kp_s_21; +static PyObject *__pyx_kp_u_22; +static PyObject *__pyx_kp_u_24; +static PyObject *__pyx_kp_u_26; +static PyObject *__pyx_kp_u_28; +static PyObject *__pyx_kp_u_29; +static PyObject *__pyx_kp_s_3; +static PyObject *__pyx_kp_u_32; +static PyObject *__pyx_kp_s_4; +static PyObject *__pyx_kp_s_6; +static PyObject *__pyx_kp_s_8; +static PyObject *__pyx_kp_s_9; +static PyObject *__pyx_n_s__NotImplemented; +static PyObject *__pyx_n_s__RuntimeError; +static PyObject *__pyx_n_s__ValueError; +static PyObject *__pyx_n_s____class__; +static PyObject *__pyx_n_s____import__; +static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____pyx_vtable__; +static PyObject *__pyx_n_s____test__; +static PyObject *__pyx_n_s___eq; +static PyObject *__pyx_n_s___getstate; +static PyObject *__pyx_n_s__append; +static PyObject *__pyx_n_s__enumerate; +static PyObject *__pyx_n_s__gcv; +static PyObject *__pyx_n_s__get_mse; +static PyObject *__pyx_n_s__get_pruned; +static PyObject *__pyx_n_s__get_selected; +static PyObject *__pyx_n_s__get_size; +static PyObject *__pyx_n_s__grsq; +static PyObject *__pyx_n_s__iter; +static PyObject *__pyx_n_s__iterations; +static PyObject *__pyx_n_s__knot; +static PyObject *__pyx_n_s__mse; +static PyObject *__pyx_n_s__num_samples; +static PyObject *__pyx_n_s__num_variables; +static PyObject *__pyx_n_s__parent; +static PyObject *__pyx_n_s__penalty; +static PyObject *__pyx_n_s__pruned; +static PyObject *__pyx_n_s__range; +static PyObject *__pyx_n_s__roll_back; +static PyObject *__pyx_n_s__rsq; +static PyObject *__pyx_n_s__selected; +static PyObject *__pyx_n_s__set_no_candidates; +static PyObject *__pyx_n_s__set_selected; +static PyObject *__pyx_n_s__size; +static PyObject *__pyx_n_s__split; +static PyObject *__pyx_n_s__sst; +static PyObject *__pyx_n_s__terms; +static PyObject *__pyx_n_s__unprune; +static PyObject *__pyx_n_s__var; +static PyObject *__pyx_n_s__variable; +static PyObject *__pyx_n_s__xlabels; +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_3; +static PyObject *__pyx_int_15; +static PyObject *__pyx_k_tuple_5; +static PyObject *__pyx_k_tuple_7; +static PyObject *__pyx_k_tuple_11; +static PyObject *__pyx_k_tuple_13; +static PyObject *__pyx_k_tuple_23; +static PyObject *__pyx_k_tuple_25; +static PyObject *__pyx_k_tuple_27; +static PyObject *__pyx_k_tuple_30; +static PyObject *__pyx_k_tuple_31; +static PyObject *__pyx_k_tuple_33; + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_1__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_1__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method) { + PyObject *__pyx_v_method = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); + __pyx_v_method = PyInt_FromLong(__pyx_arg_method); if (unlikely(!__pyx_v_method)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_GOTREF(__pyx_v_method); + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.Record.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record___richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((PyObject *)__pyx_v_method)); + __Pyx_XDECREF(__pyx_v_method); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":12 + * cdef class Record: + * + * def __richcmp__(self, other, method): # <<<<<<<<<<<<<< + * if method == 2: + * return self._eq(other) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record___richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__richcmp__", 0); + + /* "sklearn/earth/_record.pyx":13 + * + * def __richcmp__(self, other, method): + * if method == 2: # <<<<<<<<<<<<<< + * return self._eq(other) + * elif method == 3: + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, __pyx_int_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_record.pyx":14 + * def __richcmp__(self, other, method): + * if method == 2: + * return self._eq(other) # <<<<<<<<<<<<<< + * elif method == 3: + * return not self._eq(other) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + + /* "sklearn/earth/_record.pyx":15 + * if method == 2: + * return self._eq(other) + * elif method == 3: # <<<<<<<<<<<<<< + * return not self._eq(other) + * else: + */ + __pyx_t_4 = PyObject_RichCompare(__pyx_v_method, __pyx_int_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_record.pyx":16 + * return self._eq(other) + * elif method == 3: + * return not self._eq(other) # <<<<<<<<<<<<<< + * else: + * return NotImplemented + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_record.pyx":18 + * return not self._eq(other) + * else: + * return NotImplemented # <<<<<<<<<<<<<< + * + * def _eq(self, other): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_builtin_NotImplemented); + __pyx_r = __pyx_builtin_NotImplemented; + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._record.Record.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_3_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_3_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_eq (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_2_eq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), ((PyObject *)__pyx_v_other)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":20 + * return NotImplemented + * + * def _eq(self, other): # <<<<<<<<<<<<<< + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_2_eq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_eq", 0); + + /* "sklearn/earth/_record.pyx":21 + * + * def _eq(self, other): + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() # <<<<<<<<<<<<<< + * + * def __getitem__(Record self, int idx): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s____class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = (__pyx_t_1 == __pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_3) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_5 = __pyx_t_2; + __pyx_t_2 = 0; + } + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._record.Record._eq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_idx); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_idx) { + int __pyx_v_idx; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_idx); { + __pyx_v_idx = __Pyx_PyInt_AsInt(__pyx_arg_idx); if (unlikely((__pyx_v_idx == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.Record.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_4__getitem__(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), ((int)__pyx_v_idx)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":23 + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + * def __getitem__(Record self, int idx): # <<<<<<<<<<<<<< + * return self.iterations[idx] + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_4__getitem__(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, int __pyx_v_idx) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "sklearn/earth/_record.pyx":24 + * + * def __getitem__(Record self, int idx): + * return self.iterations[idx] # <<<<<<<<<<<<<< + * + * def __len__(Record self): + */ + __Pyx_XDECREF(__pyx_r); + if (unlikely(((PyObject *)__pyx_v_self->iterations) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_self->iterations, __pyx_v_idx)); + __pyx_r = PyList_GET_ITEM(__pyx_v_self->iterations, __pyx_v_idx); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("sklearn.earth._record.Record.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static Py_ssize_t __pyx_pw_7sklearn_5earth_7_record_6Record_7__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_7sklearn_5earth_7_record_6Record_7__len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_6__len__(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":26 + * return self.iterations[idx] + * + * def __len__(Record self): # <<<<<<<<<<<<<< + * return len(self.iterations) + * + */ + +static Py_ssize_t __pyx_pf_7sklearn_5earth_7_record_6Record_6__len__(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__len__", 0); + + /* "sklearn/earth/_record.pyx":27 + * + * def __len__(Record self): + * return len(self.iterations) # <<<<<<<<<<<<<< + * + * cpdef append(Record self, Iteration iteration): + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->iterations); + __Pyx_INCREF(__pyx_t_1); + if (unlikely(__pyx_t_1 == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Record.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":29 + * return len(self.iterations) + * + * cpdef append(Record self, Iteration iteration): # <<<<<<<<<<<<<< + * self.iterations.append(iteration) + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_9append(PyObject *__pyx_v_self, PyObject *__pyx_v_iteration); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_7_record_6Record_append(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_iteration, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("append", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__append); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_9append)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_iteration)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_iteration)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_iteration)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":30 + * + * cpdef append(Record self, Iteration iteration): + * self.iterations.append(iteration) # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t mse(Record self, INDEX_t iteration): + */ + if (unlikely(((PyObject *)__pyx_v_self->iterations) == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->iterations, ((PyObject *)__pyx_v_iteration)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.Record.append", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_9append(PyObject *__pyx_v_self, PyObject *__pyx_v_iteration); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_9append(PyObject *__pyx_v_self, PyObject *__pyx_v_iteration) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("append (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iteration), __pyx_ptype_7sklearn_5earth_7_record_Iteration, 1, "iteration", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_8append(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), ((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_v_iteration)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":29 + * return len(self.iterations) + * + * cpdef append(Record self, Iteration iteration): # <<<<<<<<<<<<<< + * self.iterations.append(iteration) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_8append(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_iteration) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("append", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *)__pyx_v_self->__pyx_vtab)->append(__pyx_v_self, __pyx_v_iteration, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Record.append", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":32 + * self.iterations.append(iteration) + * + * cpdef FLOAT_t mse(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * return self.iterations[iteration].get_mse() + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_11mse(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_f_7sklearn_5earth_7_record_6Record_mse(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("mse", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__mse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_11mse)) { + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_iteration); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":33 + * + * cpdef FLOAT_t mse(Record self, INDEX_t iteration): + * return self.iterations[iteration].get_mse() # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t gcv(Record self, INDEX_t iteration): + */ + if (unlikely(((PyObject *)__pyx_v_self->iterations) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->iterations, __pyx_v_iteration), __pyx_n_s__get_mse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("sklearn.earth._record.Record.mse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_11mse(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_11mse(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("mse (wrapper)", 0); + assert(__pyx_arg_iteration); { + __pyx_v_iteration = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_iteration); if (unlikely((__pyx_v_iteration == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.Record.mse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_10mse(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_7_record_INDEX_t)__pyx_v_iteration)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":32 + * self.iterations.append(iteration) + * + * cpdef FLOAT_t mse(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * return self.iterations[iteration].get_mse() + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_10mse(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("mse", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *)__pyx_v_self->__pyx_vtab)->mse(__pyx_v_self, __pyx_v_iteration, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Record.mse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":35 + * return self.iterations[iteration].get_mse() + * + * cpdef FLOAT_t gcv(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * cdef Iteration it = self.iterations[iteration] + * cdef FLOAT_t mse = it.mse + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_13gcv(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_f_7sklearn_5earth_7_record_6Record_gcv(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_it = 0; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gcv", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__gcv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_13gcv)) { + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_iteration); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":36 + * + * cpdef FLOAT_t gcv(Record self, INDEX_t iteration): + * cdef Iteration it = self.iterations[iteration] # <<<<<<<<<<<<<< + * cdef FLOAT_t mse = it.mse + * return gcv(mse, it.get_size(), self.num_samples, self.penalty) + */ + if (unlikely(((PyObject *)__pyx_v_self->iterations) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyList_GET_ITEM(__pyx_v_self->iterations, __pyx_v_iteration)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_self->iterations, __pyx_v_iteration), __pyx_ptype_7sklearn_5earth_7_record_Iteration))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_GET_ITEM(__pyx_v_self->iterations, __pyx_v_iteration); + __Pyx_INCREF(__pyx_t_1); + __pyx_v_it = ((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":37 + * cpdef FLOAT_t gcv(Record self, INDEX_t iteration): + * cdef Iteration it = self.iterations[iteration] + * cdef FLOAT_t mse = it.mse # <<<<<<<<<<<<<< + * return gcv(mse, it.get_size(), self.num_samples, self.penalty) + * + */ + __pyx_t_4 = __pyx_v_it->mse; + __pyx_v_mse = __pyx_t_4; + + /* "sklearn/earth/_record.pyx":38 + * cdef Iteration it = self.iterations[iteration] + * cdef FLOAT_t mse = it.mse + * return gcv(mse, it.get_size(), self.num_samples, self.penalty) # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t rsq(Record self, INDEX_t iteration): + */ + __pyx_r = __pyx_f_7sklearn_5earth_5_util_gcv(__pyx_v_mse, ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *)__pyx_v_it->__pyx_vtab)->get_size(__pyx_v_it, 0), __pyx_v_self->num_samples, __pyx_v_self->penalty, 0); + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("sklearn.earth._record.Record.gcv", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_it); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_13gcv(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_13gcv(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gcv (wrapper)", 0); + assert(__pyx_arg_iteration); { + __pyx_v_iteration = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_iteration); if (unlikely((__pyx_v_iteration == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.Record.gcv", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_12gcv(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_7_record_INDEX_t)__pyx_v_iteration)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":35 + * return self.iterations[iteration].get_mse() + * + * cpdef FLOAT_t gcv(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * cdef Iteration it = self.iterations[iteration] + * cdef FLOAT_t mse = it.mse + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_12gcv(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gcv", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *)__pyx_v_self->__pyx_vtab)->gcv(__pyx_v_self, __pyx_v_iteration, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Record.gcv", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":40 + * return gcv(mse, it.get_size(), self.num_samples, self.penalty) + * + * cpdef FLOAT_t rsq(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * # gcv(self.sst,1,self.num_samples,self.penalty) + * cdef FLOAT_t mse0 = self.sst + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_15rsq(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_f_7sklearn_5earth_7_record_6Record_rsq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse0; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("rsq", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__rsq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_15rsq)) { + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_iteration); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":42 + * cpdef FLOAT_t rsq(Record self, INDEX_t iteration): + * # gcv(self.sst,1,self.num_samples,self.penalty) + * cdef FLOAT_t mse0 = self.sst # <<<<<<<<<<<<<< + * # gcv(self.mse(iteration):,self.iterations[iteration].get_size(),self.num_samples,self.penalty)#self.gcv(iteration) + * cdef FLOAT_t mse = self.mse(iteration) + */ + __pyx_t_4 = __pyx_v_self->sst; + __pyx_v_mse0 = __pyx_t_4; + + /* "sklearn/earth/_record.pyx":44 + * cdef FLOAT_t mse0 = self.sst + * # gcv(self.mse(iteration):,self.iterations[iteration].get_size(),self.num_samples,self.penalty)#self.gcv(iteration) + * cdef FLOAT_t mse = self.mse(iteration) # <<<<<<<<<<<<<< + * return 1 - (mse / mse0) + * + */ + __pyx_v_mse = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *)__pyx_v_self->__pyx_vtab)->mse(__pyx_v_self, __pyx_v_iteration, 0); + + /* "sklearn/earth/_record.pyx":45 + * # gcv(self.mse(iteration):,self.iterations[iteration].get_size(),self.num_samples,self.penalty)#self.gcv(iteration) + * cdef FLOAT_t mse = self.mse(iteration) + * return 1 - (mse / mse0) # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration): + */ + __pyx_r = (1.0 - (__pyx_v_mse / __pyx_v_mse0)); + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("sklearn.earth._record.Record.rsq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_15rsq(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_15rsq(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("rsq (wrapper)", 0); + assert(__pyx_arg_iteration); { + __pyx_v_iteration = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_iteration); if (unlikely((__pyx_v_iteration == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.Record.rsq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_14rsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_7_record_INDEX_t)__pyx_v_iteration)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":40 + * return gcv(mse, it.get_size(), self.num_samples, self.penalty) + * + * cpdef FLOAT_t rsq(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * # gcv(self.sst,1,self.num_samples,self.penalty) + * cdef FLOAT_t mse0 = self.sst + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_14rsq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("rsq", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *)__pyx_v_self->__pyx_vtab)->rsq(__pyx_v_self, __pyx_v_iteration, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Record.rsq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":47 + * return 1 - (mse / mse0) + * + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * cdef FLOAT_t gcv0 = gcv(self.sst, 1, self.num_samples, self.penalty) + * cdef FLOAT_t gcv_ = self.gcv(iteration) + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_17grsq(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_f_7sklearn_5earth_7_record_6Record_grsq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_gcv0; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_gcv_; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("grsq", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__grsq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_17grsq)) { + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_iteration); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":48 + * + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration): + * cdef FLOAT_t gcv0 = gcv(self.sst, 1, self.num_samples, self.penalty) # <<<<<<<<<<<<<< + * cdef FLOAT_t gcv_ = self.gcv(iteration) + * return 1 - (gcv_ / gcv0) + */ + __pyx_v_gcv0 = __pyx_f_7sklearn_5earth_5_util_gcv(__pyx_v_self->sst, 1, __pyx_v_self->num_samples, __pyx_v_self->penalty, 0); + + /* "sklearn/earth/_record.pyx":49 + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration): + * cdef FLOAT_t gcv0 = gcv(self.sst, 1, self.num_samples, self.penalty) + * cdef FLOAT_t gcv_ = self.gcv(iteration) # <<<<<<<<<<<<<< + * return 1 - (gcv_ / gcv0) + * + */ + __pyx_v_gcv_ = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *)__pyx_v_self->__pyx_vtab)->gcv(__pyx_v_self, __pyx_v_iteration, 0); + + /* "sklearn/earth/_record.pyx":50 + * cdef FLOAT_t gcv0 = gcv(self.sst, 1, self.num_samples, self.penalty) + * cdef FLOAT_t gcv_ = self.gcv(iteration) + * return 1 - (gcv_ / gcv0) # <<<<<<<<<<<<<< + * + * cdef class PruningPassRecord(Record): + */ + __pyx_r = (1.0 - (__pyx_v_gcv_ / __pyx_v_gcv0)); + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("sklearn.earth._record.Record.grsq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_17grsq(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_6Record_17grsq(PyObject *__pyx_v_self, PyObject *__pyx_arg_iteration) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("grsq (wrapper)", 0); + assert(__pyx_arg_iteration); { + __pyx_v_iteration = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_iteration); if (unlikely((__pyx_v_iteration == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.Record.grsq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_6Record_16grsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_7_record_INDEX_t)__pyx_v_iteration)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":47 + * return 1 - (mse / mse0) + * + * cpdef FLOAT_t grsq(Record self, INDEX_t iteration): # <<<<<<<<<<<<<< + * cdef FLOAT_t gcv0 = gcv(self.sst, 1, self.num_samples, self.penalty) + * cdef FLOAT_t gcv_ = self.gcv(iteration) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_6Record_16grsq(struct __pyx_obj_7sklearn_5earth_7_record_Record *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_iteration) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("grsq", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record *)__pyx_v_self->__pyx_vtab)->grsq(__pyx_v_self, __pyx_v_iteration, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Record.grsq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_samples; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_variables; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_penalty; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_sst; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__num_samples,&__pyx_n_s__num_variables,&__pyx_n_s__penalty,&__pyx_n_s__sst,&__pyx_n_s__size,&__pyx_n_s__mse,0}; + PyObject* values[6] = {0,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 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__num_samples)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__num_variables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__penalty)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sst)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { + 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); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + } + __pyx_v_num_samples = __Pyx_PyInt_from_py_npy_ulonglong(values[0]); if (unlikely((__pyx_v_num_samples == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_num_variables = __Pyx_PyInt_from_py_npy_ulonglong(values[1]); if (unlikely((__pyx_v_num_variables == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_penalty = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_penalty == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_sst = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_sst == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_size = __Pyx_PyInt_from_py_npy_ulonglong(values[4]); if (unlikely((__pyx_v_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_mse = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_mse == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord___init__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self), __pyx_v_num_samples, __pyx_v_num_variables, __pyx_v_penalty, __pyx_v_sst, __pyx_v_size, __pyx_v_mse); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":53 + * + * cdef class PruningPassRecord(Record): + * def __init__(PruningPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, INDEX_t size, FLOAT_t mse): # <<<<<<<<<<<<<< + * self.num_samples = num_samples + * self.num_variables = num_variables + */ + +static int __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord___init__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_samples, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_variables, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_penalty, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_sst, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_record.pyx":54 + * cdef class PruningPassRecord(Record): + * def __init__(PruningPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, INDEX_t size, FLOAT_t mse): + * self.num_samples = num_samples # <<<<<<<<<<<<<< + * self.num_variables = num_variables + * self.penalty = penalty + */ + __pyx_v_self->__pyx_base.num_samples = __pyx_v_num_samples; + + /* "sklearn/earth/_record.pyx":55 + * def __init__(PruningPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, INDEX_t size, FLOAT_t mse): + * self.num_samples = num_samples + * self.num_variables = num_variables # <<<<<<<<<<<<<< + * self.penalty = penalty + * self.sst = sst + */ + __pyx_v_self->__pyx_base.num_variables = __pyx_v_num_variables; + + /* "sklearn/earth/_record.pyx":56 + * self.num_samples = num_samples + * self.num_variables = num_variables + * self.penalty = penalty # <<<<<<<<<<<<<< + * self.sst = sst + * self.iterations = [FirstPruningPassIteration(size, mse)] + */ + __pyx_v_self->__pyx_base.penalty = __pyx_v_penalty; + + /* "sklearn/earth/_record.pyx":57 + * self.num_variables = num_variables + * self.penalty = penalty + * self.sst = sst # <<<<<<<<<<<<<< + * self.iterations = [FirstPruningPassIteration(size, mse)] + * + */ + __pyx_v_self->__pyx_base.sst = __pyx_v_sst; + + /* "sklearn/earth/_record.pyx":58 + * self.penalty = penalty + * self.sst = sst + * self.iterations = [FirstPruningPassIteration(size, mse)] # <<<<<<<<<<<<<< + * + * def __reduce__(PruningPassRecord self): + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_mse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __Pyx_GOTREF(__pyx_v_self->__pyx_base.iterations); + __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.iterations)); + __pyx_v_self->__pyx_base.iterations = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_2__reduce__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":60 + * self.iterations = [FirstPruningPassIteration(size, mse)] + * + * def __reduce__(PruningPassRecord self): # <<<<<<<<<<<<<< + * return (PruningPassRecord, (1, 1, 1.0, 1.0, 1, 1.0), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_record.pyx":61 + * + * def __reduce__(PruningPassRecord self): + * return (PruningPassRecord, (1, 1, 1.0, 1.0, 1, 1.0), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(PruningPassRecord self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord))); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord))); + PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_4 = 0; + __pyx_t_2 = 0; + __pyx_r = ((PyObject *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_4_getstate(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":63 + * return (PruningPassRecord, (1, 1, 1.0, 1.0, 1, 1.0), self._getstate()) + * + * def _getstate(PruningPassRecord self): # <<<<<<<<<<<<<< + * result = {'num_samples': self.num_samples, + * 'num_variables': self.num_variables, + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_record.pyx":64 + * + * def _getstate(PruningPassRecord self): + * result = {'num_samples': self.num_samples, # <<<<<<<<<<<<<< + * 'num_variables': self.num_variables, + * 'penalty': self.penalty, + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->__pyx_base.num_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__num_samples), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":65 + * def _getstate(PruningPassRecord self): + * result = {'num_samples': self.num_samples, + * 'num_variables': self.num_variables, # <<<<<<<<<<<<<< + * 'penalty': self.penalty, + * 'sst': self.sst, + */ + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->__pyx_base.num_variables); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__num_variables), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":66 + * result = {'num_samples': self.num_samples, + * 'num_variables': self.num_variables, + * 'penalty': self.penalty, # <<<<<<<<<<<<<< + * 'sst': self.sst, + * 'iterations': self.iterations, + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.penalty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__penalty), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":67 + * 'num_variables': self.num_variables, + * 'penalty': self.penalty, + * 'sst': self.sst, # <<<<<<<<<<<<<< + * 'iterations': self.iterations, + * 'selected': self.selected} + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.sst); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__sst), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":68 + * 'penalty': self.penalty, + * 'sst': self.sst, + * 'iterations': self.iterations, # <<<<<<<<<<<<<< + * 'selected': self.selected} + * return result + */ + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__iterations), ((PyObject *)__pyx_v_self->__pyx_base.iterations)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_record.pyx":69 + * 'sst': self.sst, + * 'iterations': self.iterations, + * 'selected': self.selected} # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->selected); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__selected), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_result = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":70 + * 'iterations': self.iterations, + * 'selected': self.selected} + * return result # <<<<<<<<<<<<<< + * + * def __setstate__(PruningPassRecord self, dict state): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), (&PyDict_Type), 1, "state", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_6__setstate__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self), ((PyObject*)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":72 + * return result + * + * def __setstate__(PruningPassRecord self, dict state): # <<<<<<<<<<<<<< + * self.num_samples = state['num_samples'] + * self.num_variables = state['num_variables'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_3; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_record.pyx":73 + * + * def __setstate__(PruningPassRecord self, dict state): + * self.num_samples = state['num_samples'] # <<<<<<<<<<<<<< + * self.num_variables = state['num_variables'] + * self.penalty = state['penalty'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__num_samples)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.num_samples = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":74 + * def __setstate__(PruningPassRecord self, dict state): + * self.num_samples = state['num_samples'] + * self.num_variables = state['num_variables'] # <<<<<<<<<<<<<< + * self.penalty = state['penalty'] + * self.sst = state['sst'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__num_variables)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.num_variables = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":75 + * self.num_samples = state['num_samples'] + * self.num_variables = state['num_variables'] + * self.penalty = state['penalty'] # <<<<<<<<<<<<<< + * self.sst = state['sst'] + * self.iterations = state['iterations'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__penalty)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.penalty = __pyx_t_3; + + /* "sklearn/earth/_record.pyx":76 + * self.num_variables = state['num_variables'] + * self.penalty = state['penalty'] + * self.sst = state['sst'] # <<<<<<<<<<<<<< + * self.iterations = state['iterations'] + * self.selected = state['selected'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__sst)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.sst = __pyx_t_3; + + /* "sklearn/earth/_record.pyx":77 + * self.penalty = state['penalty'] + * self.sst = state['sst'] + * self.iterations = state['iterations'] # <<<<<<<<<<<<<< + * self.selected = state['selected'] + * + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__iterations)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->__pyx_base.iterations); + __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.iterations)); + __pyx_v_self->__pyx_base.iterations = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":78 + * self.sst = state['sst'] + * self.iterations = state['iterations'] + * self.selected = state['selected'] # <<<<<<<<<<<<<< + * + * cpdef set_selected(PruningPassRecord self, INDEX_t selected): + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__selected)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_4 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->selected = __pyx_t_4; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":80 + * self.selected = state['selected'] + * + * cpdef set_selected(PruningPassRecord self, INDEX_t selected): # <<<<<<<<<<<<<< + * self.selected = selected + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_9set_selected(PyObject *__pyx_v_self, PyObject *__pyx_arg_selected); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_7_record_17PruningPassRecord_set_selected(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_selected, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_selected", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__set_selected); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_9set_selected)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_selected); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":81 + * + * cpdef set_selected(PruningPassRecord self, INDEX_t selected): + * self.selected = selected # <<<<<<<<<<<<<< + * + * cpdef INDEX_t get_selected(PruningPassRecord self): + */ + __pyx_v_self->selected = __pyx_v_selected; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.set_selected", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_9set_selected(PyObject *__pyx_v_self, PyObject *__pyx_arg_selected); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_9set_selected(PyObject *__pyx_v_self, PyObject *__pyx_arg_selected) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_selected; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_selected (wrapper)", 0); + assert(__pyx_arg_selected); { + __pyx_v_selected = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_arg_selected); if (unlikely((__pyx_v_selected == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.set_selected", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_8set_selected(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self), ((__pyx_t_7sklearn_5earth_7_record_INDEX_t)__pyx_v_selected)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":80 + * self.selected = state['selected'] + * + * cpdef set_selected(PruningPassRecord self, INDEX_t selected): # <<<<<<<<<<<<<< + * self.selected = selected + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_8set_selected(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_selected) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_selected", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->set_selected(__pyx_v_self, __pyx_v_selected, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.set_selected", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":83 + * self.selected = selected + * + * cpdef INDEX_t get_selected(PruningPassRecord self): # <<<<<<<<<<<<<< + * return self.selected + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_11get_selected(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_f_7sklearn_5earth_7_record_17PruningPassRecord_get_selected(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_selected", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_selected); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_11get_selected)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":84 + * + * cpdef INDEX_t get_selected(PruningPassRecord self): + * return self.selected # <<<<<<<<<<<<<< + * + * cpdef roll_back(PruningPassRecord self, Basis basis): + */ + __pyx_r = __pyx_v_self->selected; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._record.PruningPassRecord.get_selected", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_11get_selected(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_11get_selected(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_selected (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_10get_selected(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":83 + * self.selected = selected + * + * cpdef INDEX_t get_selected(PruningPassRecord self): # <<<<<<<<<<<<<< + * return self.selected + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_10get_selected(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_selected", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->get_selected(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.get_selected", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":86 + * return self.selected + * + * cpdef roll_back(PruningPassRecord self, Basis basis): # <<<<<<<<<<<<<< + * cdef INDEX_t n = len(self.iterations) + * cdef INDEX_t i + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_13roll_back(PyObject *__pyx_v_self, PyObject *__pyx_v_basis); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_7_record_17PruningPassRecord_roll_back(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_basis, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_n; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_i; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_5; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_6; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("roll_back", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__roll_back); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_13roll_back)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_basis)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_basis)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_basis)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":87 + * + * cpdef roll_back(PruningPassRecord self, Basis basis): + * cdef INDEX_t n = len(self.iterations) # <<<<<<<<<<<<<< + * cdef INDEX_t i + * for i in range(n - self.selected - 1): + */ + __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.iterations); + __Pyx_INCREF(__pyx_t_1); + if (unlikely(__pyx_t_1 == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_n = __pyx_t_4; + + /* "sklearn/earth/_record.pyx":89 + * cdef INDEX_t n = len(self.iterations) + * cdef INDEX_t i + * for i in range(n - self.selected - 1): # <<<<<<<<<<<<<< + * basis[self.iterations[n - i - 1].get_pruned()].unprune() + * + */ + __pyx_t_5 = ((__pyx_v_n - __pyx_v_self->selected) - 1); + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "sklearn/earth/_record.pyx":90 + * cdef INDEX_t i + * for i in range(n - self.selected - 1): + * basis[self.iterations[n - i - 1].get_pruned()].unprune() # <<<<<<<<<<<<<< + * + * def __str__(PruningPassRecord self): + */ + if (unlikely(((PyObject *)__pyx_v_self->__pyx_base.iterations) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_7 = ((__pyx_v_n - __pyx_v_i) - 1); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->__pyx_base.iterations, __pyx_t_7), __pyx_n_s__get_pruned); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_basis), __pyx_t_3); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__unprune); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.roll_back", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_13roll_back(PyObject *__pyx_v_self, PyObject *__pyx_v_basis); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_13roll_back(PyObject *__pyx_v_self, PyObject *__pyx_v_basis) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("roll_back (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_basis), __pyx_ptype_7sklearn_5earth_6_basis_Basis, 1, "basis", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_12roll_back(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self), ((struct __pyx_obj_7sklearn_5earth_6_basis_Basis *)__pyx_v_basis)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":86 + * return self.selected + * + * cpdef roll_back(PruningPassRecord self, Basis basis): # <<<<<<<<<<<<<< + * cdef INDEX_t n = len(self.iterations) + * cdef INDEX_t i + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_12roll_back(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *__pyx_v_basis) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("roll_back", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->roll_back(__pyx_v_self, __pyx_v_basis, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.roll_back", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_15__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_15__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_14__str__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":92 + * basis[self.iterations[n - i - 1].get_pruned()].unprune() + * + * def __str__(PruningPassRecord self): # <<<<<<<<<<<<<< + * result = '' + * result += 'Pruning Pass\n' + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17PruningPassRecord_14__str__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_header = NULL; + PyObject *__pyx_v_data = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_iteration = NULL; + PyObject *__pyx_v_row = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_record.pyx":93 + * + * def __str__(PruningPassRecord self): + * result = '' # <<<<<<<<<<<<<< + * result += 'Pruning Pass\n' + * header = 'iter\tbf\tterms\tmse\tgcv\trsq\tgrsq'.split('\t') + */ + __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); + __pyx_v_result = ((PyObject *)__pyx_kp_s_1); + + /* "sklearn/earth/_record.pyx":94 + * def __str__(PruningPassRecord self): + * result = '' + * result += 'Pruning Pass\n' # <<<<<<<<<<<<<< + * header = 'iter\tbf\tterms\tmse\tgcv\trsq\tgrsq'.split('\t') + * data = [] + */ + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":95 + * result = '' + * result += 'Pruning Pass\n' + * header = 'iter\tbf\tterms\tmse\tgcv\trsq\tgrsq'.split('\t') # <<<<<<<<<<<<<< + * data = [] + * for i, iteration in enumerate(self.iterations): + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_kp_s_3), __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_header = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":96 + * result += 'Pruning Pass\n' + * header = 'iter\tbf\tterms\tmse\tgcv\trsq\tgrsq'.split('\t') + * data = [] # <<<<<<<<<<<<<< + * for i, iteration in enumerate(self.iterations): + * row = str(i) + '\t' + str(iteration) + '\t%.3f\t%.3f\t%.3f' % ( + */ + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_data = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":97 + * header = 'iter\tbf\tterms\tmse\tgcv\trsq\tgrsq'.split('\t') + * data = [] + * for i, iteration in enumerate(self.iterations): # <<<<<<<<<<<<<< + * row = str(i) + '\t' + str(iteration) + '\t%.3f\t%.3f\t%.3f' % ( + * self.gcv(i), self.rsq(i), self.grsq(i)) + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.iterations); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; + for (;;) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_iteration, __pyx_t_4); + __pyx_t_4 = 0; + __Pyx_INCREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); + __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); + __pyx_t_2 = __pyx_t_4; + __pyx_t_4 = 0; + + /* "sklearn/earth/_record.pyx":98 + * data = [] + * for i, iteration in enumerate(self.iterations): + * row = str(i) + '\t' + str(iteration) + '\t%.3f\t%.3f\t%.3f' % ( # <<<<<<<<<<<<<< + * self.gcv(i), self.rsq(i), self.grsq(i)) + * data.append(row.split('\t')) + */ + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_iteration); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_iteration); + __Pyx_GIVEREF(__pyx_v_iteration); + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "sklearn/earth/_record.pyx":99 + * for i, iteration in enumerate(self.iterations): + * row = str(i) + '\t' + str(iteration) + '\t%.3f\t%.3f\t%.3f' % ( + * self.gcv(i), self.rsq(i), self.grsq(i)) # <<<<<<<<<<<<<< + * data.append(row.split('\t')) + * result += ascii_table(header, data) + */ + __pyx_t_7 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_i); if (unlikely((__pyx_t_7 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.gcv(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), __pyx_t_7, 0)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_i); if (unlikely((__pyx_t_7 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.rsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), __pyx_t_7, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_i); if (unlikely((__pyx_t_7 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.grsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), __pyx_t_7, 0)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_6 = 0; + __pyx_t_4 = 0; + __pyx_t_8 = 0; + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_9); + __pyx_t_9 = 0; + + /* "sklearn/earth/_record.pyx":100 + * row = str(i) + '\t' + str(iteration) + '\t%.3f\t%.3f\t%.3f' % ( + * self.gcv(i), self.rsq(i), self.grsq(i)) + * data.append(row.split('\t')) # <<<<<<<<<<<<<< + * result += ascii_table(header, data) + * result += '\nSelected iteration: ' + str(self.selected) + '\n' + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s__split); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_data, __pyx_t_8); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":101 + * self.gcv(i), self.rsq(i), self.grsq(i)) + * data.append(row.split('\t')) + * result += ascii_table(header, data) # <<<<<<<<<<<<<< + * result += '\nSelected iteration: ' + str(self.selected) + '\n' + * return result + */ + __pyx_t_2 = __pyx_f_7sklearn_5earth_5_util_ascii_table(__pyx_v_header, ((PyObject *)__pyx_v_data), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":102 + * data.append(row.split('\t')) + * result += ascii_table(header, data) + * result += '\nSelected iteration: ' + str(self.selected) + '\n' # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->selected); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_kp_s_8), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_kp_s_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":103 + * result += ascii_table(header, data) + * result += '\nSelected iteration: ' + str(self.selected) + '\n' + * return result # <<<<<<<<<<<<<< + * + * cdef class ForwardPassRecord(Record): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassRecord.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_header); + __Pyx_XDECREF(__pyx_v_data); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_iteration); + __Pyx_XDECREF(__pyx_v_row); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_samples; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_variables; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_penalty; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_sst; + PyObject *__pyx_v_xlabels = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__num_samples,&__pyx_n_s__num_variables,&__pyx_n_s__penalty,&__pyx_n_s__sst,&__pyx_n_s__xlabels,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); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__num_samples)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__num_variables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__penalty)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sst)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xlabels)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __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_num_samples = __Pyx_PyInt_from_py_npy_ulonglong(values[0]); if (unlikely((__pyx_v_num_samples == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_num_variables = __Pyx_PyInt_from_py_npy_ulonglong(values[1]); if (unlikely((__pyx_v_num_variables == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_penalty = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_penalty == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_sst = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_sst == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_xlabels = ((PyObject*)values[4]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xlabels), (&PyList_Type), 1, "xlabels", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord___init__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self), __pyx_v_num_samples, __pyx_v_num_variables, __pyx_v_penalty, __pyx_v_sst, __pyx_v_xlabels); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":106 + * + * cdef class ForwardPassRecord(Record): + * def __init__(ForwardPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, list xlabels): # <<<<<<<<<<<<<< + * self.num_samples = num_samples + * self.num_variables = num_variables + */ + +static int __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord___init__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_samples, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_num_variables, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_penalty, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_sst, PyObject *__pyx_v_xlabels) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_record.pyx":107 + * cdef class ForwardPassRecord(Record): + * def __init__(ForwardPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, list xlabels): + * self.num_samples = num_samples # <<<<<<<<<<<<<< + * self.num_variables = num_variables + * self.penalty = penalty + */ + __pyx_v_self->__pyx_base.num_samples = __pyx_v_num_samples; + + /* "sklearn/earth/_record.pyx":108 + * def __init__(ForwardPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, list xlabels): + * self.num_samples = num_samples + * self.num_variables = num_variables # <<<<<<<<<<<<<< + * self.penalty = penalty + * self.sst = sst + */ + __pyx_v_self->__pyx_base.num_variables = __pyx_v_num_variables; + + /* "sklearn/earth/_record.pyx":109 + * self.num_samples = num_samples + * self.num_variables = num_variables + * self.penalty = penalty # <<<<<<<<<<<<<< + * self.sst = sst + * self.iterations = [FirstForwardPassIteration(self.sst)] + */ + __pyx_v_self->__pyx_base.penalty = __pyx_v_penalty; + + /* "sklearn/earth/_record.pyx":110 + * self.num_variables = num_variables + * self.penalty = penalty + * self.sst = sst # <<<<<<<<<<<<<< + * self.iterations = [FirstForwardPassIteration(self.sst)] + * self.xlabels = xlabels + */ + __pyx_v_self->__pyx_base.sst = __pyx_v_sst; + + /* "sklearn/earth/_record.pyx":111 + * self.penalty = penalty + * self.sst = sst + * self.iterations = [FirstForwardPassIteration(self.sst)] # <<<<<<<<<<<<<< + * self.xlabels = xlabels + * + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.sst); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + __Pyx_GOTREF(__pyx_v_self->__pyx_base.iterations); + __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.iterations)); + __pyx_v_self->__pyx_base.iterations = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":112 + * self.sst = sst + * self.iterations = [FirstForwardPassIteration(self.sst)] + * self.xlabels = xlabels # <<<<<<<<<<<<<< + * + * def __reduce__(ForwardPassRecord self): + */ + __Pyx_INCREF(((PyObject *)__pyx_v_xlabels)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_xlabels)); + __Pyx_GOTREF(__pyx_v_self->xlabels); + __Pyx_DECREF(((PyObject *)__pyx_v_self->xlabels)); + __pyx_v_self->xlabels = __pyx_v_xlabels; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_2__reduce__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":114 + * self.xlabels = xlabels + * + * def __reduce__(ForwardPassRecord self): # <<<<<<<<<<<<<< + * return (ForwardPassRecord, (self.num_samples, self.num_variables, self.penalty, self.sst, self.xlabels), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_record.pyx":115 + * + * def __reduce__(ForwardPassRecord self): + * return (ForwardPassRecord, (self.num_samples, self.num_variables, self.penalty, self.sst, self.xlabels), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(ForwardPassRecord self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->__pyx_base.num_samples); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->__pyx_base.num_variables); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.penalty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.sst); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_self->xlabels)); + PyTuple_SET_ITEM(__pyx_t_5, 4, ((PyObject *)__pyx_v_self->xlabels)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->xlabels)); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord))); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord))); + PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_5 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_4_getstate(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":117 + * return (ForwardPassRecord, (self.num_samples, self.num_variables, self.penalty, self.sst, self.xlabels), self._getstate()) + * + * def _getstate(ForwardPassRecord self): # <<<<<<<<<<<<<< + * return {'num_samples': self.num_samples, + * 'num_variables': self.num_variables, + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_record.pyx":118 + * + * def _getstate(ForwardPassRecord self): + * return {'num_samples': self.num_samples, # <<<<<<<<<<<<<< + * 'num_variables': self.num_variables, + * 'penalty': self.penalty, + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->__pyx_base.num_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__num_samples), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":119 + * def _getstate(ForwardPassRecord self): + * return {'num_samples': self.num_samples, + * 'num_variables': self.num_variables, # <<<<<<<<<<<<<< + * 'penalty': self.penalty, + * 'sst': self.sst, + */ + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->__pyx_base.num_variables); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__num_variables), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":120 + * return {'num_samples': self.num_samples, + * 'num_variables': self.num_variables, + * 'penalty': self.penalty, # <<<<<<<<<<<<<< + * 'sst': self.sst, + * 'iterations': self.iterations, + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.penalty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__penalty), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":121 + * 'num_variables': self.num_variables, + * 'penalty': self.penalty, + * 'sst': self.sst, # <<<<<<<<<<<<<< + * 'iterations': self.iterations, + * 'xlabels': self.xlabels} + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.sst); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__sst), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":122 + * 'penalty': self.penalty, + * 'sst': self.sst, + * 'iterations': self.iterations, # <<<<<<<<<<<<<< + * 'xlabels': self.xlabels} + * + */ + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__iterations), ((PyObject *)__pyx_v_self->__pyx_base.iterations)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "sklearn/earth/_record.pyx":123 + * 'sst': self.sst, + * 'iterations': self.iterations, + * 'xlabels': self.xlabels} # <<<<<<<<<<<<<< + * + * def __setstate__(ForwardPassRecord self, dict state): + */ + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__xlabels), ((PyObject *)__pyx_v_self->xlabels)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), (&PyDict_Type), 1, "state", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_6__setstate__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self), ((PyObject*)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":125 + * 'xlabels': self.xlabels} + * + * def __setstate__(ForwardPassRecord self, dict state): # <<<<<<<<<<<<<< + * self.num_samples = state['num_samples'] + * self.num_variables = state['num_variables'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_record.pyx":126 + * + * def __setstate__(ForwardPassRecord self, dict state): + * self.num_samples = state['num_samples'] # <<<<<<<<<<<<<< + * self.num_variables = state['num_variables'] + * self.penalty = state['penalty'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__num_samples)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.num_samples = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":127 + * def __setstate__(ForwardPassRecord self, dict state): + * self.num_samples = state['num_samples'] + * self.num_variables = state['num_variables'] # <<<<<<<<<<<<<< + * self.penalty = state['penalty'] + * self.sst = state['sst'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__num_variables)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.num_variables = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":128 + * self.num_samples = state['num_samples'] + * self.num_variables = state['num_variables'] + * self.penalty = state['penalty'] # <<<<<<<<<<<<<< + * self.sst = state['sst'] + * self.iterations = state['iterations'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__penalty)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.penalty = __pyx_t_3; + + /* "sklearn/earth/_record.pyx":129 + * self.num_variables = state['num_variables'] + * self.penalty = state['penalty'] + * self.sst = state['sst'] # <<<<<<<<<<<<<< + * self.iterations = state['iterations'] + * self.xlabels = state['xlabels'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__sst)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.sst = __pyx_t_3; + + /* "sklearn/earth/_record.pyx":130 + * self.penalty = state['penalty'] + * self.sst = state['sst'] + * self.iterations = state['iterations'] # <<<<<<<<<<<<<< + * self.xlabels = state['xlabels'] + * + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__iterations)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->__pyx_base.iterations); + __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.iterations)); + __pyx_v_self->__pyx_base.iterations = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":131 + * self.sst = state['sst'] + * self.iterations = state['iterations'] + * self.xlabels = state['xlabels'] # <<<<<<<<<<<<<< + * + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition): + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__xlabels)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->xlabels); + __Pyx_DECREF(((PyObject *)__pyx_v_self->xlabels)); + __pyx_v_self->xlabels = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":133 + * self.xlabels = state['xlabels'] + * + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition): # <<<<<<<<<<<<<< + * self.stopping_condition = stopping_condition + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_9set_stopping_condition(PyObject *__pyx_v_self, PyObject *__pyx_arg_stopping_condition); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_7_record_17ForwardPassRecord_set_stopping_condition(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self, int __pyx_v_stopping_condition, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_stopping_condition", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_9set_stopping_condition)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyInt_FromLong(__pyx_v_stopping_condition); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":134 + * + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition): + * self.stopping_condition = stopping_condition # <<<<<<<<<<<<<< + * + * def __str__(ForwardPassRecord self): + */ + __pyx_v_self->stopping_condition = __pyx_v_stopping_condition; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.set_stopping_condition", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_9set_stopping_condition(PyObject *__pyx_v_self, PyObject *__pyx_arg_stopping_condition); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_9set_stopping_condition(PyObject *__pyx_v_self, PyObject *__pyx_arg_stopping_condition) { + int __pyx_v_stopping_condition; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_stopping_condition (wrapper)", 0); + assert(__pyx_arg_stopping_condition); { + __pyx_v_stopping_condition = __Pyx_PyInt_AsInt(__pyx_arg_stopping_condition); if (unlikely((__pyx_v_stopping_condition == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.set_stopping_condition", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_8set_stopping_condition(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self), ((int)__pyx_v_stopping_condition)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":133 + * self.xlabels = state['xlabels'] + * + * cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition): # <<<<<<<<<<<<<< + * self.stopping_condition = stopping_condition + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_8set_stopping_condition(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self, int __pyx_v_stopping_condition) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_stopping_condition", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->set_stopping_condition(__pyx_v_self, __pyx_v_stopping_condition, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.set_stopping_condition", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_11__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_11__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_10__str__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":136 + * self.stopping_condition = stopping_condition + * + * def __str__(ForwardPassRecord self): # <<<<<<<<<<<<<< + * header = ['iter', 'parent', 'var', 'knot', + * 'mse', 'terms', 'gcv', 'rsq', 'grsq'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_17ForwardPassRecord_10__str__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *__pyx_v_self) { + PyObject *__pyx_v_header = NULL; + PyObject *__pyx_v_data = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_iteration = NULL; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_record.pyx":137 + * + * def __str__(ForwardPassRecord self): + * header = ['iter', 'parent', 'var', 'knot', # <<<<<<<<<<<<<< + * 'mse', 'terms', 'gcv', 'rsq', 'grsq'] + * data = [] + */ + __pyx_t_1 = PyList_New(9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__iter)); + PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__iter)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__iter)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__parent)); + PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__parent)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__parent)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__var)); + PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__var)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__var)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__knot)); + PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__knot)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__knot)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mse)); + PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__mse)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mse)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__terms)); + PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__terms)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__terms)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__gcv)); + PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__gcv)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__gcv)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__rsq)); + PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__rsq)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rsq)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__grsq)); + PyList_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__grsq)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__grsq)); + __pyx_v_header = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":139 + * header = ['iter', 'parent', 'var', 'knot', + * 'mse', 'terms', 'gcv', 'rsq', 'grsq'] + * data = [] # <<<<<<<<<<<<<< + * for i, iteration in enumerate(self.iterations): + * data.append( + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_data = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":140 + * 'mse', 'terms', 'gcv', 'rsq', 'grsq'] + * data = [] + * for i, iteration in enumerate(self.iterations): # <<<<<<<<<<<<<< + * data.append( + * [str(i)] + str(iteration).split('\t') + ('%.3f\t%.3f\t%.3f' % + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_1 = __pyx_int_0; + __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base.iterations); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + for (;;) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_iteration, __pyx_t_4); + __pyx_t_4 = 0; + __Pyx_INCREF(__pyx_t_1); + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1); + __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); + __pyx_t_1 = __pyx_t_4; + __pyx_t_4 = 0; + + /* "sklearn/earth/_record.pyx":142 + * for i, iteration in enumerate(self.iterations): + * data.append( + * [str(i)] + str(iteration).split('\t') + ('%.3f\t%.3f\t%.3f' % # <<<<<<<<<<<<<< + * (self.gcv(i), self.rsq(i), self.grsq(i))).split('\t')) + * result = '' + */ + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_iteration); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_iteration); + __Pyx_GIVEREF(__pyx_v_iteration); + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_4), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "sklearn/earth/_record.pyx":143 + * data.append( + * [str(i)] + str(iteration).split('\t') + ('%.3f\t%.3f\t%.3f' % + * (self.gcv(i), self.rsq(i), self.grsq(i))).split('\t')) # <<<<<<<<<<<<<< + * result = '' + * result += 'Forward Pass\n' + */ + __pyx_t_7 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_i); if (unlikely((__pyx_t_7 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.gcv(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), __pyx_t_7, 0)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_i); if (unlikely((__pyx_t_7 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.rsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), __pyx_t_7, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_v_i); if (unlikely((__pyx_t_7 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.grsq(((struct __pyx_obj_7sklearn_5earth_7_record_Record *)__pyx_v_self), __pyx_t_7, 0)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_6 = 0; + __pyx_t_4 = 0; + __pyx_t_8 = 0; + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_t_8), __pyx_n_s__split); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Add(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_data, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":144 + * [str(i)] + str(iteration).split('\t') + ('%.3f\t%.3f\t%.3f' % + * (self.gcv(i), self.rsq(i), self.grsq(i))).split('\t')) + * result = '' # <<<<<<<<<<<<<< + * result += 'Forward Pass\n' + * result += ascii_table(header, data) + */ + __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); + __pyx_v_result = ((PyObject *)__pyx_kp_s_1); + + /* "sklearn/earth/_record.pyx":145 + * (self.gcv(i), self.rsq(i), self.grsq(i))).split('\t')) + * result = '' + * result += 'Forward Pass\n' # <<<<<<<<<<<<<< + * result += ascii_table(header, data) + * result += '\nStopping Condition %d: %s\n' % ( + */ + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_kp_s_14)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":146 + * result = '' + * result += 'Forward Pass\n' + * result += ascii_table(header, data) # <<<<<<<<<<<<<< + * result += '\nStopping Condition %d: %s\n' % ( + * self.stopping_condition, stopping_conditions[self.stopping_condition]) + */ + __pyx_t_1 = __pyx_f_7sklearn_5earth_5_util_ascii_table(((PyObject *)__pyx_v_header), ((PyObject *)__pyx_v_data), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":148 + * result += ascii_table(header, data) + * result += '\nStopping Condition %d: %s\n' % ( + * self.stopping_condition, stopping_conditions[self.stopping_condition]) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->stopping_condition); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(((PyObject *)__pyx_v_7sklearn_5earth_8_forward_stopping_conditions) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_7sklearn_5earth_8_forward_stopping_conditions), __pyx_v_self->stopping_condition, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_9); + __pyx_t_9 = 0; + + /* "sklearn/earth/_record.pyx":149 + * result += '\nStopping Condition %d: %s\n' % ( + * self.stopping_condition, stopping_conditions[self.stopping_condition]) + * return result # <<<<<<<<<<<<<< + * + * cdef class Iteration: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassRecord.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_header); + __Pyx_XDECREF(__pyx_v_data); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_iteration); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_1__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_1__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_method) { + PyObject *__pyx_v_method = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); + __pyx_v_method = PyInt_FromLong(__pyx_arg_method); if (unlikely(!__pyx_v_method)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_GOTREF(__pyx_v_method); + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.Iteration.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_9Iteration___richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((PyObject *)__pyx_v_method)); + __Pyx_XDECREF(__pyx_v_method); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":153 + * cdef class Iteration: + * + * def __richcmp__(self, other, method): # <<<<<<<<<<<<<< + * if method == 2: + * return self._eq(other) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration___richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_method) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__richcmp__", 0); + + /* "sklearn/earth/_record.pyx":154 + * + * def __richcmp__(self, other, method): + * if method == 2: # <<<<<<<<<<<<<< + * return self._eq(other) + * elif method == 3: + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, __pyx_int_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_record.pyx":155 + * def __richcmp__(self, other, method): + * if method == 2: + * return self._eq(other) # <<<<<<<<<<<<<< + * elif method == 3: + * return not self._eq(other) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + + /* "sklearn/earth/_record.pyx":156 + * if method == 2: + * return self._eq(other) + * elif method == 3: # <<<<<<<<<<<<<< + * return not self._eq(other) + * else: + */ + __pyx_t_4 = PyObject_RichCompare(__pyx_v_method, __pyx_int_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_2) { + + /* "sklearn/earth/_record.pyx":157 + * return self._eq(other) + * elif method == 3: + * return not self._eq(other) # <<<<<<<<<<<<<< + * else: + * return NotImplemented + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s___eq); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_other); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other); + __Pyx_GIVEREF(__pyx_v_other); + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "sklearn/earth/_record.pyx":159 + * return not self._eq(other) + * else: + * return NotImplemented # <<<<<<<<<<<<<< + * + * def _eq(self, other): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_builtin_NotImplemented); + __pyx_r = __pyx_builtin_NotImplemented; + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("sklearn.earth._record.Iteration.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_3_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_3_eq(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_eq (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_9Iteration_2_eq(((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_v_self), ((PyObject *)__pyx_v_other)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":161 + * return NotImplemented + * + * def _eq(self, other): # <<<<<<<<<<<<<< + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration_2_eq(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self, PyObject *__pyx_v_other) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_eq", 0); + + /* "sklearn/earth/_record.pyx":162 + * + * def _eq(self, other): + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t get_mse(Iteration self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s____class__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = (__pyx_t_1 == __pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_3) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_5 = __pyx_t_2; + __pyx_t_2 = 0; + } + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._record.Iteration._eq", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":164 + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + * cpdef FLOAT_t get_mse(Iteration self): # <<<<<<<<<<<<<< + * return self.mse + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_5get_mse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_f_7sklearn_5earth_7_record_9Iteration_get_mse(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_mse", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_mse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_9Iteration_5get_mse)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":165 + * + * cpdef FLOAT_t get_mse(Iteration self): + * return self.mse # <<<<<<<<<<<<<< + * + * cpdef INDEX_t get_size(Iteration self): + */ + __pyx_r = __pyx_v_self->mse; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._record.Iteration.get_mse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_5get_mse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_5get_mse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_mse (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_9Iteration_4get_mse(((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":164 + * return self.__class__ is other.__class__ and self._getstate() == other._getstate() + * + * cpdef FLOAT_t get_mse(Iteration self): # <<<<<<<<<<<<<< + * return self.mse + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration_4get_mse(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_mse", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *)__pyx_v_self->__pyx_vtab)->get_mse(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Iteration.get_mse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":167 + * return self.mse + * + * cpdef INDEX_t get_size(Iteration self): # <<<<<<<<<<<<<< + * return self.size + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_7get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_f_7sklearn_5earth_7_record_9Iteration_get_size(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_size", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_9Iteration_7get_size)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":168 + * + * cpdef INDEX_t get_size(Iteration self): + * return self.size # <<<<<<<<<<<<<< + * + * cdef class PruningPassIteration(Iteration): + */ + __pyx_r = __pyx_v_self->size; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._record.Iteration.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_7get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_9Iteration_7get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_size (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_9Iteration_6get_size(((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":167 + * return self.mse + * + * cpdef INDEX_t get_size(Iteration self): # <<<<<<<<<<<<<< + * return self.size + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_9Iteration_6get_size(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_size", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration *)__pyx_v_self->__pyx_vtab)->get_size(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.Iteration.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_pruned; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__pruned,&__pyx_n_s__size,&__pyx_n_s__mse,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pruned)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __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_pruned = __Pyx_PyInt_from_py_npy_ulonglong(values[0]); if (unlikely((__pyx_v_pruned == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_size = __Pyx_PyInt_from_py_npy_ulonglong(values[1]); if (unlikely((__pyx_v_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_mse = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_mse == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.PruningPassIteration.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration___init__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *)__pyx_v_self), __pyx_v_pruned, __pyx_v_size, __pyx_v_mse); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":171 + * + * cdef class PruningPassIteration(Iteration): + * def __init__(PruningPassIteration self, INDEX_t pruned, INDEX_t size, FLOAT_t mse): # <<<<<<<<<<<<<< + * self.pruned = pruned + * self.size = size + */ + +static int __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_pruned, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_record.pyx":172 + * cdef class PruningPassIteration(Iteration): + * def __init__(PruningPassIteration self, INDEX_t pruned, INDEX_t size, FLOAT_t mse): + * self.pruned = pruned # <<<<<<<<<<<<<< + * self.size = size + * self.mse = mse + */ + __pyx_v_self->pruned = __pyx_v_pruned; + + /* "sklearn/earth/_record.pyx":173 + * def __init__(PruningPassIteration self, INDEX_t pruned, INDEX_t size, FLOAT_t mse): + * self.pruned = pruned + * self.size = size # <<<<<<<<<<<<<< + * self.mse = mse + * + */ + __pyx_v_self->__pyx_base.size = __pyx_v_size; + + /* "sklearn/earth/_record.pyx":174 + * self.pruned = pruned + * self.size = size + * self.mse = mse # <<<<<<<<<<<<<< + * + * def __reduce__(PruningPassIteration self): + */ + __pyx_v_self->__pyx_base.mse = __pyx_v_mse; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_2__reduce__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":176 + * self.mse = mse + * + * def __reduce__(PruningPassIteration self): # <<<<<<<<<<<<<< + * return (PruningPassIteration, (1, 1, 1.0), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_record.pyx":177 + * + * def __reduce__(PruningPassIteration self): + * return (PruningPassIteration, (1, 1, 1.0), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(PruningPassIteration self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassIteration.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_4_getstate(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":179 + * return (PruningPassIteration, (1, 1, 1.0), self._getstate()) + * + * def _getstate(PruningPassIteration self): # <<<<<<<<<<<<<< + * return {'pruned': self.pruned, + * 'size': self.size, + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_record.pyx":180 + * + * def _getstate(PruningPassIteration self): + * return {'pruned': self.pruned, # <<<<<<<<<<<<<< + * 'size': self.size, + * 'mse': self.mse} + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->pruned); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pruned), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":181 + * def _getstate(PruningPassIteration self): + * return {'pruned': self.pruned, + * 'size': self.size, # <<<<<<<<<<<<<< + * 'mse': self.mse} + * + */ + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->__pyx_base.size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__size), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":182 + * return {'pruned': self.pruned, + * 'size': self.size, + * 'mse': self.mse} # <<<<<<<<<<<<<< + * + * def __setstate__(PruningPassIteration self, dict state): + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.mse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mse), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassIteration._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), (&PyDict_Type), 1, "state", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_6__setstate__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *)__pyx_v_self), ((PyObject*)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":184 + * 'mse': self.mse} + * + * def __setstate__(PruningPassIteration self, dict state): # <<<<<<<<<<<<<< + * self.pruned = state['pruned'] + * self.size = state['size'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_2; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_record.pyx":185 + * + * def __setstate__(PruningPassIteration self, dict state): + * self.pruned = state['pruned'] # <<<<<<<<<<<<<< + * self.size = state['size'] + * self.mse = state['mse'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__pruned)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->pruned = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":186 + * def __setstate__(PruningPassIteration self, dict state): + * self.pruned = state['pruned'] + * self.size = state['size'] # <<<<<<<<<<<<<< + * self.mse = state['mse'] + * + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__size)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.size = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":187 + * self.pruned = state['pruned'] + * self.size = state['size'] + * self.mse = state['mse'] # <<<<<<<<<<<<<< + * + * cpdef INDEX_t get_pruned(PruningPassIteration self): + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__mse)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.mse = __pyx_t_3; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassIteration.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":189 + * self.mse = state['mse'] + * + * cpdef INDEX_t get_pruned(PruningPassIteration self): # <<<<<<<<<<<<<< + * return self.pruned + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_9get_pruned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_f_7sklearn_5earth_7_record_20PruningPassIteration_get_pruned(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_pruned", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_pruned); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_9get_pruned)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":190 + * + * cpdef INDEX_t get_pruned(PruningPassIteration self): + * return self.pruned # <<<<<<<<<<<<<< + * + * def __str__(PruningPassIteration self): + */ + __pyx_r = __pyx_v_self->pruned; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._record.PruningPassIteration.get_pruned", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_9get_pruned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_9get_pruned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_pruned (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_8get_pruned(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":189 + * self.mse = state['mse'] + * + * cpdef INDEX_t get_pruned(PruningPassIteration self): # <<<<<<<<<<<<<< + * return self.pruned + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_8get_pruned(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_pruned", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration *)__pyx_v_self->__pyx_base.__pyx_vtab)->get_pruned(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassIteration.get_pruned", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_11__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_11__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_10__str__(((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":192 + * return self.pruned + * + * def __str__(PruningPassIteration self): # <<<<<<<<<<<<<< + * result = '%s\t%s\t%s' % (str(self.pruned), self.size, '%.2f' % + * self.mse if self.mse is not None else None) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20PruningPassIteration_10__str__(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_record.pyx":193 + * + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % (str(self.pruned), self.size, '%.2f' % # <<<<<<<<<<<<<< + * self.mse if self.mse is not None else None) + * return result + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->pruned); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->__pyx_base.size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + + /* "sklearn/earth/_record.pyx":194 + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % (str(self.pruned), self.size, '%.2f' % + * self.mse if self.mse is not None else None) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.mse); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = (__pyx_t_4 != Py_None); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if ((__pyx_t_5 != 0)) { + + /* "sklearn/earth/_record.pyx":193 + * + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % (str(self.pruned), self.size, '%.2f' % # <<<<<<<<<<<<<< + * self.mse if self.mse is not None else None) + * return result + */ + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.mse); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_3 = ((PyObject *)__pyx_t_6); + __pyx_t_6 = 0; + } else { + + /* "sklearn/earth/_record.pyx":194 + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % (str(self.pruned), self.size, '%.2f' % + * self.mse if self.mse is not None else None) # <<<<<<<<<<<<<< + * return result + * + */ + __Pyx_INCREF(Py_None); + __pyx_t_3 = Py_None; + } + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __pyx_v_result = ((PyObject *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "sklearn/earth/_record.pyx":195 + * result = '%s\t%s\t%s' % (str(self.pruned), self.size, '%.2f' % + * self.mse if self.mse is not None else None) + * return result # <<<<<<<<<<<<<< + * + * cdef class FirstPruningPassIteration(PruningPassIteration): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("sklearn.earth._record.PruningPassIteration.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__size,&__pyx_n_s__mse,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_size = __Pyx_PyInt_from_py_npy_ulonglong(values[0]); if (unlikely((__pyx_v_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_mse = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_mse == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.FirstPruningPassIteration.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration___init__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *)__pyx_v_self), __pyx_v_size, __pyx_v_mse); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":198 + * + * cdef class FirstPruningPassIteration(PruningPassIteration): + * def __init__(PruningPassIteration self, INDEX_t size, FLOAT_t mse): # <<<<<<<<<<<<<< + * self.size = size + * self.mse = mse + */ + +static int __pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_record.pyx":199 + * cdef class FirstPruningPassIteration(PruningPassIteration): + * def __init__(PruningPassIteration self, INDEX_t size, FLOAT_t mse): + * self.size = size # <<<<<<<<<<<<<< + * self.mse = mse + * + */ + __pyx_v_self->__pyx_base.__pyx_base.size = __pyx_v_size; + + /* "sklearn/earth/_record.pyx":200 + * def __init__(PruningPassIteration self, INDEX_t size, FLOAT_t mse): + * self.size = size + * self.mse = mse # <<<<<<<<<<<<<< + * + * def __reduce__(FirstPruningPassIteration self): + */ + __pyx_v_self->__pyx_base.__pyx_base.mse = __pyx_v_mse; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_2__reduce__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":202 + * self.mse = mse + * + * def __reduce__(FirstPruningPassIteration self): # <<<<<<<<<<<<<< + * return (FirstPruningPassIteration, (1, 1.0), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_record.pyx":203 + * + * def __reduce__(FirstPruningPassIteration self): + * return (FirstPruningPassIteration, (1, 1.0), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(FirstPruningPassIteration self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.FirstPruningPassIteration.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_4_getstate(((struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":205 + * return (FirstPruningPassIteration, (1, 1.0), self._getstate()) + * + * def _getstate(FirstPruningPassIteration self): # <<<<<<<<<<<<<< + * return {'size': self.size, + * 'mse': self.mse} + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_record.pyx":206 + * + * def _getstate(FirstPruningPassIteration self): + * return {'size': self.size, # <<<<<<<<<<<<<< + * 'mse': self.mse} + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->__pyx_base.__pyx_base.size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__size), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":207 + * def _getstate(FirstPruningPassIteration self): + * return {'size': self.size, + * 'mse': self.mse} # <<<<<<<<<<<<<< + * + * def __setstate__(FirstPruningPassIteration self, dict state): + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.mse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mse), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.FirstPruningPassIteration._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), (&PyDict_Type), 1, "state", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_6__setstate__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *)__pyx_v_self), ((PyObject*)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":209 + * 'mse': self.mse} + * + * def __setstate__(FirstPruningPassIteration self, dict state): # <<<<<<<<<<<<<< + * self.size = state['size'] + * self.mse = state['mse'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_2; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_record.pyx":210 + * + * def __setstate__(FirstPruningPassIteration self, dict state): + * self.size = state['size'] # <<<<<<<<<<<<<< + * self.mse = state['mse'] + * + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__size)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.__pyx_base.size = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":211 + * def __setstate__(FirstPruningPassIteration self, dict state): + * self.size = state['size'] + * self.mse = state['mse'] # <<<<<<<<<<<<<< + * + * def __str__(PruningPassIteration self): + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__mse)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.__pyx_base.mse = __pyx_t_3; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.FirstPruningPassIteration.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_9__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_9__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_8__str__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":213 + * self.mse = state['mse'] + * + * def __str__(PruningPassIteration self): # <<<<<<<<<<<<<< + * result = '%s\t%s\t%s' % ('-', self.size, '%.2f' % + * self.mse if self.mse is not None else None) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstPruningPassIteration_8__str__(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_record.pyx":214 + * + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % ('-', self.size, '%.2f' % # <<<<<<<<<<<<<< + * self.mse if self.mse is not None else None) + * return result + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->__pyx_base.__pyx_base.size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + + /* "sklearn/earth/_record.pyx":215 + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % ('-', self.size, '%.2f' % + * self.mse if self.mse is not None else None) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.mse); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = (__pyx_t_3 != Py_None); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if ((__pyx_t_4 != 0)) { + + /* "sklearn/earth/_record.pyx":214 + * + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % ('-', self.size, '%.2f' % # <<<<<<<<<<<<<< + * self.mse if self.mse is not None else None) + * return result + */ + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.mse); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_2 = ((PyObject *)__pyx_t_5); + __pyx_t_5 = 0; + } else { + + /* "sklearn/earth/_record.pyx":215 + * def __str__(PruningPassIteration self): + * result = '%s\t%s\t%s' % ('-', self.size, '%.2f' % + * self.mse if self.mse is not None else None) # <<<<<<<<<<<<<< + * return result + * + */ + __Pyx_INCREF(Py_None); + __pyx_t_2 = Py_None; + } + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_v_result = ((PyObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":216 + * result = '%s\t%s\t%s' % ('-', self.size, '%.2f' % + * self.mse if self.mse is not None else None) + * return result # <<<<<<<<<<<<<< + * + * cdef class ForwardPassIteration(Iteration): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sklearn.earth._record.FirstPruningPassIteration.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_parent; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_variable; + int __pyx_v_knot; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__parent,&__pyx_n_s__variable,&__pyx_n_s__knot,&__pyx_n_s__mse,&__pyx_n_s__size,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); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__variable)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__knot)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mse)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __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_parent = __Pyx_PyInt_from_py_npy_ulonglong(values[0]); if (unlikely((__pyx_v_parent == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_variable = __Pyx_PyInt_from_py_npy_ulonglong(values[1]); if (unlikely((__pyx_v_variable == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_knot = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_knot == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_mse = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_mse == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_size = __Pyx_PyInt_from_py_npy_ulonglong(values[4]); if (unlikely((__pyx_v_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration___init__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self), __pyx_v_parent, __pyx_v_variable, __pyx_v_knot, __pyx_v_mse, __pyx_v_size); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":219 + * + * cdef class ForwardPassIteration(Iteration): + * def __init__(ForwardPassIteration self, INDEX_t parent, INDEX_t variable, int knot, FLOAT_t mse, INDEX_t size): # <<<<<<<<<<<<<< + * self.parent = parent + * self.variable = variable + */ + +static int __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_parent, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_variable, int __pyx_v_knot, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse, __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_v_size) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_record.pyx":220 + * cdef class ForwardPassIteration(Iteration): + * def __init__(ForwardPassIteration self, INDEX_t parent, INDEX_t variable, int knot, FLOAT_t mse, INDEX_t size): + * self.parent = parent # <<<<<<<<<<<<<< + * self.variable = variable + * self.knot = knot + */ + __pyx_v_self->parent = __pyx_v_parent; + + /* "sklearn/earth/_record.pyx":221 + * def __init__(ForwardPassIteration self, INDEX_t parent, INDEX_t variable, int knot, FLOAT_t mse, INDEX_t size): + * self.parent = parent + * self.variable = variable # <<<<<<<<<<<<<< + * self.knot = knot + * self.mse = mse + */ + __pyx_v_self->variable = __pyx_v_variable; + + /* "sklearn/earth/_record.pyx":222 + * self.parent = parent + * self.variable = variable + * self.knot = knot # <<<<<<<<<<<<<< + * self.mse = mse + * self.size = size + */ + __pyx_v_self->knot = __pyx_v_knot; + + /* "sklearn/earth/_record.pyx":223 + * self.variable = variable + * self.knot = knot + * self.mse = mse # <<<<<<<<<<<<<< + * self.size = size + * + */ + __pyx_v_self->__pyx_base.mse = __pyx_v_mse; + + /* "sklearn/earth/_record.pyx":224 + * self.knot = knot + * self.mse = mse + * self.size = size # <<<<<<<<<<<<<< + * + * def __reduce__(ForwardPassIteration self): + */ + __pyx_v_self->__pyx_base.size = __pyx_v_size; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_2__reduce__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":226 + * self.size = size + * + * def __reduce__(ForwardPassIteration self): # <<<<<<<<<<<<<< + * return (ForwardPassIteration, (1, 1, 1, 1.0, 1), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_record.pyx":227 + * + * def __reduce__(ForwardPassIteration self): + * return (ForwardPassIteration, (1, 1, 1, 1.0, 1), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(ForwardPassIteration self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_4_getstate(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":229 + * return (ForwardPassIteration, (1, 1, 1, 1.0, 1), self._getstate()) + * + * def _getstate(ForwardPassIteration self): # <<<<<<<<<<<<<< + * return {'parent': self.parent, + * 'variable': self.variable, + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_record.pyx":230 + * + * def _getstate(ForwardPassIteration self): + * return {'parent': self.parent, # <<<<<<<<<<<<<< + * 'variable': self.variable, + * 'knot': self.knot, + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->parent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__parent), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":231 + * def _getstate(ForwardPassIteration self): + * return {'parent': self.parent, + * 'variable': self.variable, # <<<<<<<<<<<<<< + * 'knot': self.knot, + * 'mse': self.mse, + */ + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->variable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__variable), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":232 + * return {'parent': self.parent, + * 'variable': self.variable, + * 'knot': self.knot, # <<<<<<<<<<<<<< + * 'mse': self.mse, + * 'size': self.size} + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->knot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__knot), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":233 + * 'variable': self.variable, + * 'knot': self.knot, + * 'mse': self.mse, # <<<<<<<<<<<<<< + * 'size': self.size} + * + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.mse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mse), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_record.pyx":234 + * 'knot': self.knot, + * 'mse': self.mse, + * 'size': self.size} # <<<<<<<<<<<<<< + * + * def __setstate__(ForwardPassIteration self, dict state): + */ + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->__pyx_base.size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__size), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), (&PyDict_Type), 1, "state", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_6__setstate__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self), ((PyObject*)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":236 + * 'size': self.size} + * + * def __setstate__(ForwardPassIteration self, dict state): # <<<<<<<<<<<<<< + * self.parent = state['parent'] + * self.variable = state['variable'] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_2; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_record.pyx":237 + * + * def __setstate__(ForwardPassIteration self, dict state): + * self.parent = state['parent'] # <<<<<<<<<<<<<< + * self.variable = state['variable'] + * self.knot = state['knot'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__parent)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->parent = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":238 + * def __setstate__(ForwardPassIteration self, dict state): + * self.parent = state['parent'] + * self.variable = state['variable'] # <<<<<<<<<<<<<< + * self.knot = state['knot'] + * self.mse = state['mse'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__variable)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->variable = __pyx_t_2; + + /* "sklearn/earth/_record.pyx":239 + * self.parent = state['parent'] + * self.variable = state['variable'] + * self.knot = state['knot'] # <<<<<<<<<<<<<< + * self.mse = state['mse'] + * self.size = state['size'] + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__knot)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->knot = __pyx_t_3; + + /* "sklearn/earth/_record.pyx":240 + * self.variable = state['variable'] + * self.knot = state['knot'] + * self.mse = state['mse'] # <<<<<<<<<<<<<< + * self.size = state['size'] + * + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__mse)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.mse = __pyx_t_3; + + /* "sklearn/earth/_record.pyx":241 + * self.knot = state['knot'] + * self.mse = state['mse'] + * self.size = state['size'] # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__size)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.size = __pyx_t_2; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_9__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_9__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_8__str__(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":243 + * self.size = state['size'] + * + * def __str__(self): # <<<<<<<<<<<<<< + * result = '%d\t%d\t%d\t%4f\t%d' % ( + * self.parent, self.variable, self.knot, self.mse, self.size) + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_8__str__(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_record.pyx":245 + * def __str__(self): + * result = '%d\t%d\t%d\t%4f\t%d' % ( + * self.parent, self.variable, self.knot, self.mse, self.size) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->parent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->variable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->knot); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.mse); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyInt_to_py_npy_ulonglong(__pyx_v_self->__pyx_base.size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __pyx_v_result = ((PyObject *)__pyx_t_5); + __pyx_t_5 = 0; + + /* "sklearn/earth/_record.pyx":246 + * result = '%d\t%d\t%d\t%4f\t%d' % ( + * self.parent, self.variable, self.knot, self.mse, self.size) + * return result # <<<<<<<<<<<<<< + * + * cpdef set_no_candidates(ForwardPassIteration self, bint value): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":248 + * return result + * + * cpdef set_no_candidates(ForwardPassIteration self, bint value): # <<<<<<<<<<<<<< + * self.no_candidates = value + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_11set_no_candidates(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_7_record_20ForwardPassIteration_set_no_candidates(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, int __pyx_v_value, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_no_candidates", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__set_no_candidates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_11set_no_candidates)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":249 + * + * cpdef set_no_candidates(ForwardPassIteration self, bint value): + * self.no_candidates = value # <<<<<<<<<<<<<< + * + * cpdef no_further_candidates(ForwardPassIteration self): + */ + __pyx_v_self->no_candidates = __pyx_v_value; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.set_no_candidates", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_11set_no_candidates(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_11set_no_candidates(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) { + int __pyx_v_value; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_no_candidates (wrapper)", 0); + assert(__pyx_arg_value); { + __pyx_v_value = __Pyx_PyObject_IsTrue(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.set_no_candidates", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_10set_no_candidates(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self), ((int)__pyx_v_value)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":248 + * return result + * + * cpdef set_no_candidates(ForwardPassIteration self, bint value): # <<<<<<<<<<<<<< + * self.no_candidates = value + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_10set_no_candidates(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, int __pyx_v_value) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_no_candidates", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self->__pyx_base.__pyx_vtab)->set_no_candidates(__pyx_v_self, __pyx_v_value, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.set_no_candidates", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":251 + * self.no_candidates = value + * + * cpdef no_further_candidates(ForwardPassIteration self): # <<<<<<<<<<<<<< + * return self.no_candidates + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_13no_further_candidates(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_7_record_20ForwardPassIteration_no_further_candidates(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("no_further_candidates", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_13no_further_candidates)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":252 + * + * cpdef no_further_candidates(ForwardPassIteration self): + * return self.no_candidates # <<<<<<<<<<<<<< + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->no_candidates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.no_further_candidates", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_13no_further_candidates(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_13no_further_candidates(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("no_further_candidates (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_12no_further_candidates(((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":251 + * self.no_candidates = value + * + * cpdef no_further_candidates(ForwardPassIteration self): # <<<<<<<<<<<<<< + * return self.no_candidates + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_20ForwardPassIteration_12no_further_candidates(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("no_further_candidates", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration *)__pyx_v_self->__pyx_base.__pyx_vtab)->no_further_candidates(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.ForwardPassIteration.no_further_candidates", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__mse,0}; + PyObject* values[1] = {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 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mse)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_mse = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_mse == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._record.FirstForwardPassIteration.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration___init__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *)__pyx_v_self), __pyx_v_mse); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":255 + * + * cdef class FirstForwardPassIteration(ForwardPassIteration): + * def __init__(FirstForwardPassIteration self, FLOAT_t mse): # <<<<<<<<<<<<<< + * self.mse = mse + * + */ + +static int __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration___init__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self, __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_v_mse) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "sklearn/earth/_record.pyx":256 + * cdef class FirstForwardPassIteration(ForwardPassIteration): + * def __init__(FirstForwardPassIteration self, FLOAT_t mse): + * self.mse = mse # <<<<<<<<<<<<<< + * + * def __reduce__(FirstForwardPassIteration self): + */ + __pyx_v_self->__pyx_base.__pyx_base.mse = __pyx_v_mse; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_2__reduce__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":258 + * self.mse = mse + * + * def __reduce__(FirstForwardPassIteration self): # <<<<<<<<<<<<<< + * return (FirstForwardPassIteration, (1.0,), self._getstate()) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_2__reduce__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce__", 0); + + /* "sklearn/earth/_record.pyx":259 + * + * def __reduce__(FirstForwardPassIteration self): + * return (FirstForwardPassIteration, (1.0,), self._getstate()) # <<<<<<<<<<<<<< + * + * def _getstate(FirstForwardPassIteration self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration))); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._record.FirstForwardPassIteration.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_5_getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getstate (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_4_getstate(((struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":261 + * return (FirstForwardPassIteration, (1.0,), self._getstate()) + * + * def _getstate(FirstForwardPassIteration self): # <<<<<<<<<<<<<< + * return {'mse': self.mse} + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_4_getstate(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_getstate", 0); + + /* "sklearn/earth/_record.pyx":262 + * + * def _getstate(FirstForwardPassIteration self): + * return {'mse': self.mse} # <<<<<<<<<<<<<< + * + * def __setstate__(FirstForwardPassIteration self, dict state): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.mse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mse), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.FirstForwardPassIteration._getstate", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_7__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), (&PyDict_Type), 1, "state", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_6__setstate__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *)__pyx_v_self), ((PyObject*)__pyx_v_state)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":264 + * return {'mse': self.mse} + * + * def __setstate__(FirstForwardPassIteration self, dict state): # <<<<<<<<<<<<<< + * self.mse = state['mse'] + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_6__setstate__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self, PyObject *__pyx_v_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __pyx_t_7sklearn_5earth_7_record_FLOAT_t __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate__", 0); + + /* "sklearn/earth/_record.pyx":265 + * + * def __setstate__(FirstForwardPassIteration self, dict state): + * self.mse = state['mse'] # <<<<<<<<<<<<<< + * + * cpdef INDEX_t get_size(FirstForwardPassIteration self): + */ + if (unlikely(((PyObject *)__pyx_v_state) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_state), ((PyObject *)__pyx_n_s__mse)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->__pyx_base.__pyx_base.mse = __pyx_t_2; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.FirstForwardPassIteration.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":267 + * self.mse = state['mse'] + * + * cpdef INDEX_t get_size(FirstForwardPassIteration self): # <<<<<<<<<<<<<< + * return 1 + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_9get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_f_7sklearn_5earth_7_record_25FirstForwardPassIteration_get_size(CYTHON_UNUSED struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self, int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_5earth_7_record_INDEX_t __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_size", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_9get_size)) { + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_from_py_npy_ulonglong(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/earth/_record.pyx":268 + * + * cpdef INDEX_t get_size(FirstForwardPassIteration self): + * return 1 # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + __pyx_r = 1; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.earth._record.FirstForwardPassIteration.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_9get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_9get_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_size (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_8get_size(((struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":267 + * self.mse = state['mse'] + * + * cpdef INDEX_t get_size(FirstForwardPassIteration self): # <<<<<<<<<<<<<< + * return 1 + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_8get_size(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_size", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_to_py_npy_ulonglong(((struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.get_size(((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._record.FirstForwardPassIteration.get_size", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_11__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_11__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_10__str__(((struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_record.pyx":270 + * return 1 + * + * def __str__(self): # <<<<<<<<<<<<<< + * result = '%s\t%s\t%s\t%4f\t%s' % ('-', '-', '-', self.mse, 1) + * return result + */ + +static PyObject *__pyx_pf_7sklearn_5earth_7_record_25FirstForwardPassIteration_10__str__(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "sklearn/earth/_record.pyx":271 + * + * def __str__(self): + * result = '%s\t%s\t%s\t%4f\t%s' % ('-', '-', '-', self.mse, 1) # <<<<<<<<<<<<<< + * return result + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.mse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_v_result = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/earth/_record.pyx":272 + * def __str__(self): + * result = '%s\t%s\t%s\t%4f\t%s' % ('-', '-', '-', self.mse, 1) + * return result # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.earth._record.FirstForwardPassIteration.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":194 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "numpy.pxd":200 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":203 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":204 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":206 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "numpy.pxd":208 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":209 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + goto __pyx_L4; + } + /*else*/ { + + /* "numpy.pxd":211 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "numpy.pxd":213 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":214 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "numpy.pxd":217 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_3) { + + /* "numpy.pxd":218 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = __pyx_t_1; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (__pyx_t_2) { + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "numpy.pxd":221 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "numpy.pxd":222 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "numpy.pxd":223 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_2 = (__pyx_v_copy_shape != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":226 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "numpy.pxd":227 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "numpy.pxd":228 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "numpy.pxd":229 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "numpy.pxd":230 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + goto __pyx_L7; + } + /*else*/ { + + /* "numpy.pxd":232 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "numpy.pxd":233 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L7:; + + /* "numpy.pxd":234 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "numpy.pxd":235 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "numpy.pxd":236 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "numpy.pxd":239 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef list stack + */ + __pyx_v_f = NULL; + + /* "numpy.pxd":240 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef list stack + * cdef int offset + */ + __pyx_t_4 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_4); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":244 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "numpy.pxd":246 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_3; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":248 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + goto __pyx_L10; + } + /*else*/ { + + /* "numpy.pxd":251 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L10:; + + /* "numpy.pxd":253 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":254 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_5 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_5; + + /* "numpy.pxd":255 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_2 = __pyx_t_1; + } + if (!__pyx_t_2) { + + /* "numpy.pxd":256 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_1) { + __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_7 = __pyx_t_3; + } else { + __pyx_t_7 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_7; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_27), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + switch (__pyx_v_t) { + + /* "numpy.pxd":258 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + case NPY_BYTE: + __pyx_v_f = __pyx_k__b; + break; + + /* "numpy.pxd":259 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = __pyx_k__B; + break; + + /* "numpy.pxd":260 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = __pyx_k__h; + break; + + /* "numpy.pxd":261 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = __pyx_k__H; + break; + + /* "numpy.pxd":262 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = __pyx_k__i; + break; + + /* "numpy.pxd":263 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = __pyx_k__I; + break; + + /* "numpy.pxd":264 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = __pyx_k__l; + break; + + /* "numpy.pxd":265 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = __pyx_k__L; + break; + + /* "numpy.pxd":266 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = __pyx_k__q; + break; + + /* "numpy.pxd":267 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = __pyx_k__Q; + break; + + /* "numpy.pxd":268 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = __pyx_k__f; + break; + + /* "numpy.pxd":269 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = __pyx_k__d; + break; + + /* "numpy.pxd":270 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = __pyx_k__g; + break; + + /* "numpy.pxd":271 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = __pyx_k__Zf; + break; + + /* "numpy.pxd":272 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = __pyx_k__Zd; + break; + + /* "numpy.pxd":273 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = __pyx_k__Zg; + break; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = __pyx_k__O; + break; + default: + + /* "numpy.pxd":276 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_28), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + + /* "numpy.pxd":277 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "numpy.pxd":278 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":280 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + __pyx_v_info->format = ((char *)malloc(255)); + + /* "numpy.pxd":281 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "numpy.pxd":282 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "numpy.pxd":285 + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + * &offset) # <<<<<<<<<<<<<< + * f[0] = c'\0' # Terminate format string + * + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_9; + + /* "numpy.pxd":286 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + __pyx_L11:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":288 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "numpy.pxd":289 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":290 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":291 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":292 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + goto __pyx_L4; + } + __pyx_L4:; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":768 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "numpy.pxd":769 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":771 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "numpy.pxd":772 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":774 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "numpy.pxd":775 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":777 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "numpy.pxd":778 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":780 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "numpy.pxd":781 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":783 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + char *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "numpy.pxd":790 + * cdef int delta_offset + * cdef tuple i + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":791 + * cdef tuple i + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "numpy.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) { + PyObject* sequence = ((PyObject *)__pyx_v_fields); + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + } else if (1) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else + { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_30), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "numpy.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (__pyx_t_7) { + __pyx_t_8 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_8 = __pyx_t_7; + } + if (!__pyx_t_8) { + + /* "numpy.pxd":802 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + __pyx_t_9 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_10 = __pyx_t_9; + } else { + __pyx_t_10 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_10; + } else { + __pyx_t_7 = __pyx_t_8; + } + if (__pyx_t_7) { + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_31), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "numpy.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!__pyx_t_7) break; + + /* "numpy.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 120; + + /* "numpy.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "numpy.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1); + } + + /* "numpy.pxd":818 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize); + + /* "numpy.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_7 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":821 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_7 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":826 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 98; + goto __pyx_L13; + } + + /* "numpy.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 66; + goto __pyx_L13; + } + + /* "numpy.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 104; + goto __pyx_L13; + } + + /* "numpy.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 72; + goto __pyx_L13; + } + + /* "numpy.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 105; + goto __pyx_L13; + } + + /* "numpy.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 73; + goto __pyx_L13; + } + + /* "numpy.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 108; + goto __pyx_L13; + } + + /* "numpy.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 76; + goto __pyx_L13; + } + + /* "numpy.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 113; + goto __pyx_L13; + } + + /* "numpy.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 81; + goto __pyx_L13; + } + + /* "numpy.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 102; + goto __pyx_L13; + } + + /* "numpy.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 100; + goto __pyx_L13; + } + + /* "numpy.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 103; + goto __pyx_L13; + } + + /* "numpy.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 102; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 100; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 103; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 79; + goto __pyx_L13; + } + /*else*/ { + + /* "numpy.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_28), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L13:; + + /* "numpy.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_12; + } + __pyx_L11:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "numpy.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":965 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "numpy.pxd":967 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":968 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":970 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + Py_INCREF(__pyx_v_base); + + /* "numpy.pxd":971 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "numpy.pxd":972 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "numpy.pxd":973 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "numpy.pxd":976 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":977 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":979 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration __pyx_vtable_7sklearn_5earth_7_record_Iteration; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_Iteration(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_Iteration *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_Iteration *)o); + p->__pyx_vtab = __pyx_vtabptr_7sklearn_5earth_7_record_Iteration; + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_7_record_Iteration(PyObject *o) { + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_Iteration[] = { + {__Pyx_NAMESTR("_eq"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_9Iteration_3_eq, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_mse"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_9Iteration_5get_mse, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_size"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_9Iteration_7get_size, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_Iteration = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.Iteration"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_Iteration), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_Iteration, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + __pyx_pw_7sklearn_5earth_7_record_9Iteration_1__richcmp__, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_Iteration, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_Iteration, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassIteration __pyx_vtable_7sklearn_5earth_7_record_ForwardPassIteration; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_ForwardPassIteration(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_7_record_Iteration(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration*)__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_ForwardPassIteration[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("set_no_candidates"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_11set_no_candidates, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("no_further_candidates"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_13no_further_candidates, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_ForwardPassIteration = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.ForwardPassIteration"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_Iteration, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_9__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_ForwardPassIteration, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_7_record_20ForwardPassIteration_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_ForwardPassIteration, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record __pyx_vtable_7sklearn_5earth_7_record_Record; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_Record(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_Record *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_Record *)o); + p->__pyx_vtab = __pyx_vtabptr_7sklearn_5earth_7_record_Record; + p->iterations = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_7_record_Record(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_7_record_Record *p = (struct __pyx_obj_7sklearn_5earth_7_record_Record *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->iterations); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_7_record_Record(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_7_record_Record *p = (struct __pyx_obj_7sklearn_5earth_7_record_Record *)o; + if (p->iterations) { + e = (*v)(p->iterations, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_7_record_Record(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_7_record_Record *p = (struct __pyx_obj_7sklearn_5earth_7_record_Record *)o; + PyObject* tmp; + tmp = ((PyObject*)p->iterations); + p->iterations = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_7sklearn_5earth_7_record_Record(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_Record[] = { + {__Pyx_NAMESTR("_eq"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_3_eq, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_9append, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("mse"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_11mse, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("gcv"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_13gcv, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("rsq"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_15rsq, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("grsq"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_6Record_17grsq, METH_O, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_Record = { + __pyx_pw_7sklearn_5earth_7_record_6Record_7__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_7sklearn_5earth_7_record_Record, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_Record = { + __pyx_pw_7sklearn_5earth_7_record_6Record_7__len__, /*mp_length*/ + __pyx_pw_7sklearn_5earth_7_record_6Record_5__getitem__, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_Record = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.Record"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_Record), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_Record, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_Record, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Record, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_7_record_Record, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_7_record_Record, /*tp_clear*/ + __pyx_pw_7sklearn_5earth_7_record_6Record_1__richcmp__, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_Record, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_Record, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_ForwardPassRecord __pyx_vtable_7sklearn_5earth_7_record_ForwardPassRecord; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_ForwardPassRecord(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_7_record_Record(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record*)__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord; + p->xlabels = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7sklearn_5earth_7_record_ForwardPassRecord(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *p = (struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->xlabels); + PyObject_GC_Track(o); + __pyx_tp_dealloc_7sklearn_5earth_7_record_Record(o); +} + +static int __pyx_tp_traverse_7sklearn_5earth_7_record_ForwardPassRecord(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *p = (struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)o; + e = __pyx_tp_traverse_7sklearn_5earth_7_record_Record(o, v, a); if (e) return e; + if (p->xlabels) { + e = (*v)(p->xlabels, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7sklearn_5earth_7_record_ForwardPassRecord(PyObject *o) { + struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *p = (struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *)o; + PyObject* tmp; + __pyx_tp_clear_7sklearn_5earth_7_record_Record(o); + tmp = ((PyObject*)p->xlabels); + p->xlabels = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_ForwardPassRecord[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("set_stopping_condition"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_9set_stopping_condition, METH_O, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_ForwardPassRecord = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.ForwardPassRecord"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_ForwardPassRecord, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_11__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_7_record_ForwardPassRecord, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_7_record_ForwardPassRecord, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_ForwardPassRecord, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_7_record_17ForwardPassRecord_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_ForwardPassRecord, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassIteration __pyx_vtable_7sklearn_5earth_7_record_PruningPassIteration; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_PruningPassIteration(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_7_record_Iteration(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration*)__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_PruningPassIteration[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_pruned"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_9get_pruned, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_PruningPassIteration = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.PruningPassIteration"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_Iteration, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_11__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_PruningPassIteration, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_7_record_20PruningPassIteration_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_PruningPassIteration, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstPruningPassIteration __pyx_vtable_7sklearn_5earth_7_record_FirstPruningPassIteration; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_FirstPruningPassIteration(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_7_record_PruningPassIteration(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration *)o); + p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration*)__pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_FirstPruningPassIteration[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_FirstPruningPassIteration = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.FirstPruningPassIteration"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_FirstPruningPassIteration), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_Iteration, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_9__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_FirstPruningPassIteration, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_7_record_25FirstPruningPassIteration_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_FirstPruningPassIteration, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_FirstForwardPassIteration __pyx_vtable_7sklearn_5earth_7_record_FirstForwardPassIteration; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_FirstForwardPassIteration(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_7_record_ForwardPassIteration(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration *)o); + p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Iteration*)__pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_FirstForwardPassIteration[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_size"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_9get_size, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_FirstForwardPassIteration = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.FirstForwardPassIteration"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_FirstForwardPassIteration), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_Iteration, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_11__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_FirstForwardPassIteration, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_7_record_25FirstForwardPassIteration_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_FirstForwardPassIteration, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_5earth_7_record_PruningPassRecord __pyx_vtable_7sklearn_5earth_7_record_PruningPassRecord; + +static PyObject *__pyx_tp_new_7sklearn_5earth_7_record_PruningPassRecord(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *p; + PyObject *o = __pyx_tp_new_7sklearn_5earth_7_record_Record(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_5earth_7_record_Record*)__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_5earth_7_record_PruningPassRecord[] = { + {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_getstate"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_5_getstate, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__setstate__"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_7__setstate__, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("set_selected"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_9set_selected, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_selected"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_11get_selected, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("roll_back"), (PyCFunction)__pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_13roll_back, METH_O, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_7sklearn_5earth_7_record_PruningPassRecord = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.earth._record.PruningPassRecord"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_5earth_7_record_Record, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_15__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7sklearn_5earth_7_record_Record, /*tp_traverse*/ + __pyx_tp_clear_7sklearn_5earth_7_record_Record, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_5earth_7_record_PruningPassRecord, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_7sklearn_5earth_7_record_17PruningPassRecord_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_5earth_7_record_PruningPassRecord, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + __Pyx_NAMESTR("_record"), + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, + {&__pyx_n_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 1}, + {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0}, + {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0}, + {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0}, + {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0}, + {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0}, + {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, + {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0}, + {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0}, + {&__pyx_n_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 1}, + {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0}, + {&__pyx_kp_u_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 1, 0, 0}, + {&__pyx_kp_u_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 1, 0, 0}, + {&__pyx_kp_u_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 1, 0, 0}, + {&__pyx_kp_u_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 1, 0, 0}, + {&__pyx_kp_u_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 1, 0, 0}, + {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, + {&__pyx_kp_u_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 1, 0, 0}, + {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, + {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0}, + {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0}, + {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0}, + {&__pyx_n_s__NotImplemented, __pyx_k__NotImplemented, sizeof(__pyx_k__NotImplemented), 0, 0, 1, 1}, + {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, + {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1}, + {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, + {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_vtable__, __pyx_k____pyx_vtable__, sizeof(__pyx_k____pyx_vtable__), 0, 0, 1, 1}, + {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s___eq, __pyx_k___eq, sizeof(__pyx_k___eq), 0, 0, 1, 1}, + {&__pyx_n_s___getstate, __pyx_k___getstate, sizeof(__pyx_k___getstate), 0, 0, 1, 1}, + {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1}, + {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1}, + {&__pyx_n_s__gcv, __pyx_k__gcv, sizeof(__pyx_k__gcv), 0, 0, 1, 1}, + {&__pyx_n_s__get_mse, __pyx_k__get_mse, sizeof(__pyx_k__get_mse), 0, 0, 1, 1}, + {&__pyx_n_s__get_pruned, __pyx_k__get_pruned, sizeof(__pyx_k__get_pruned), 0, 0, 1, 1}, + {&__pyx_n_s__get_selected, __pyx_k__get_selected, sizeof(__pyx_k__get_selected), 0, 0, 1, 1}, + {&__pyx_n_s__get_size, __pyx_k__get_size, sizeof(__pyx_k__get_size), 0, 0, 1, 1}, + {&__pyx_n_s__grsq, __pyx_k__grsq, sizeof(__pyx_k__grsq), 0, 0, 1, 1}, + {&__pyx_n_s__iter, __pyx_k__iter, sizeof(__pyx_k__iter), 0, 0, 1, 1}, + {&__pyx_n_s__iterations, __pyx_k__iterations, sizeof(__pyx_k__iterations), 0, 0, 1, 1}, + {&__pyx_n_s__knot, __pyx_k__knot, sizeof(__pyx_k__knot), 0, 0, 1, 1}, + {&__pyx_n_s__mse, __pyx_k__mse, sizeof(__pyx_k__mse), 0, 0, 1, 1}, + {&__pyx_n_s__num_samples, __pyx_k__num_samples, sizeof(__pyx_k__num_samples), 0, 0, 1, 1}, + {&__pyx_n_s__num_variables, __pyx_k__num_variables, sizeof(__pyx_k__num_variables), 0, 0, 1, 1}, + {&__pyx_n_s__parent, __pyx_k__parent, sizeof(__pyx_k__parent), 0, 0, 1, 1}, + {&__pyx_n_s__penalty, __pyx_k__penalty, sizeof(__pyx_k__penalty), 0, 0, 1, 1}, + {&__pyx_n_s__pruned, __pyx_k__pruned, sizeof(__pyx_k__pruned), 0, 0, 1, 1}, + {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, + {&__pyx_n_s__roll_back, __pyx_k__roll_back, sizeof(__pyx_k__roll_back), 0, 0, 1, 1}, + {&__pyx_n_s__rsq, __pyx_k__rsq, sizeof(__pyx_k__rsq), 0, 0, 1, 1}, + {&__pyx_n_s__selected, __pyx_k__selected, sizeof(__pyx_k__selected), 0, 0, 1, 1}, + {&__pyx_n_s__set_no_candidates, __pyx_k__set_no_candidates, sizeof(__pyx_k__set_no_candidates), 0, 0, 1, 1}, + {&__pyx_n_s__set_selected, __pyx_k__set_selected, sizeof(__pyx_k__set_selected), 0, 0, 1, 1}, + {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1}, + {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1}, + {&__pyx_n_s__sst, __pyx_k__sst, sizeof(__pyx_k__sst), 0, 0, 1, 1}, + {&__pyx_n_s__terms, __pyx_k__terms, sizeof(__pyx_k__terms), 0, 0, 1, 1}, + {&__pyx_n_s__unprune, __pyx_k__unprune, sizeof(__pyx_k__unprune), 0, 0, 1, 1}, + {&__pyx_n_s__var, __pyx_k__var, sizeof(__pyx_k__var), 0, 0, 1, 1}, + {&__pyx_n_s__variable, __pyx_k__variable, sizeof(__pyx_k__variable), 0, 0, 1, 1}, + {&__pyx_n_s__xlabels, __pyx_k__xlabels, sizeof(__pyx_k__xlabels), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s__NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "sklearn/earth/_record.pyx":95 + * result = '' + * result += 'Pruning Pass\n' + * header = 'iter\tbf\tterms\tmse\tgcv\trsq\tgrsq'.split('\t') # <<<<<<<<<<<<<< + * data = [] + * for i, iteration in enumerate(self.iterations): + */ + __pyx_k_tuple_5 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_5); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); + + /* "sklearn/earth/_record.pyx":100 + * row = str(i) + '\t' + str(iteration) + '\t%.3f\t%.3f\t%.3f' % ( + * self.gcv(i), self.rsq(i), self.grsq(i)) + * data.append(row.split('\t')) # <<<<<<<<<<<<<< + * result += ascii_table(header, data) + * result += '\nSelected iteration: ' + str(self.selected) + '\n' + */ + __pyx_k_tuple_7 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_7); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7)); + + /* "sklearn/earth/_record.pyx":142 + * for i, iteration in enumerate(self.iterations): + * data.append( + * [str(i)] + str(iteration).split('\t') + ('%.3f\t%.3f\t%.3f' % # <<<<<<<<<<<<<< + * (self.gcv(i), self.rsq(i), self.grsq(i))).split('\t')) + * result = '' + */ + __pyx_k_tuple_11 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_11); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11)); + + /* "sklearn/earth/_record.pyx":143 + * data.append( + * [str(i)] + str(iteration).split('\t') + ('%.3f\t%.3f\t%.3f' % + * (self.gcv(i), self.rsq(i), self.grsq(i))).split('\t')) # <<<<<<<<<<<<<< + * result = '' + * result += 'Forward Pass\n' + */ + __pyx_k_tuple_13 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_13); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_k_tuple_23 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_22)); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_23); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23)); + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_k_tuple_25 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_24)); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_25); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_k_tuple_27 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_26)); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_27); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_k_tuple_30 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_29)); if (unlikely(!__pyx_k_tuple_30)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_30); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_30)); + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_k_tuple_31 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_26)); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_31); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31)); + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_k_tuple_33 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_32)); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_33); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33)); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_record(void); /*proto*/ +PyMODINIT_FUNC init_record(void) +#else +PyMODINIT_FUNC PyInit__record(void); /*proto*/ +PyMODINIT_FUNC PyInit__record(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__record(void)", 0); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __Pyx_CyFunction_USED + if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_record"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_d); + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "sklearn.earth._record")) { + if (unlikely(PyDict_SetItemString(modules, "sklearn.earth._record", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + } + #endif + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + /*--- Initialize various global constants etc. ---*/ + if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if (__pyx_module_is_main_sklearn__earth___record) { + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + /*--- Builtin init code ---*/ + if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Constants init code ---*/ + if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_7sklearn_5earth_7_record_Iteration = &__pyx_vtable_7sklearn_5earth_7_record_Iteration; + __pyx_vtable_7sklearn_5earth_7_record_Iteration.get_mse = (__pyx_t_7sklearn_5earth_7_record_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_9Iteration_get_mse; + __pyx_vtable_7sklearn_5earth_7_record_Iteration.get_size = (__pyx_t_7sklearn_5earth_7_record_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_9Iteration_get_size; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_Iteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_Iteration.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_Iteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Iteration", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_Iteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_Iteration = &__pyx_type_7sklearn_5earth_7_record_Iteration; + __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration = &__pyx_vtable_7sklearn_5earth_7_record_ForwardPassIteration; + __pyx_vtable_7sklearn_5earth_7_record_ForwardPassIteration.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_7_record_Iteration; + __pyx_vtable_7sklearn_5earth_7_record_ForwardPassIteration.set_no_candidates = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_20ForwardPassIteration_set_no_candidates; + __pyx_vtable_7sklearn_5earth_7_record_ForwardPassIteration.no_further_candidates = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassIteration *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_20ForwardPassIteration_no_further_candidates; + __pyx_type_7sklearn_5earth_7_record_ForwardPassIteration.tp_base = __pyx_ptype_7sklearn_5earth_7_record_Iteration; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_ForwardPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_ForwardPassIteration.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "ForwardPassIteration", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_ForwardPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration = &__pyx_type_7sklearn_5earth_7_record_ForwardPassIteration; + __pyx_vtabptr_7sklearn_5earth_7_record_Record = &__pyx_vtable_7sklearn_5earth_7_record_Record; + __pyx_vtable_7sklearn_5earth_7_record_Record.append = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_6Record_append; + __pyx_vtable_7sklearn_5earth_7_record_Record.mse = (__pyx_t_7sklearn_5earth_7_record_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_6Record_mse; + __pyx_vtable_7sklearn_5earth_7_record_Record.rsq = (__pyx_t_7sklearn_5earth_7_record_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_6Record_rsq; + __pyx_vtable_7sklearn_5earth_7_record_Record.gcv = (__pyx_t_7sklearn_5earth_7_record_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_6Record_gcv; + __pyx_vtable_7sklearn_5earth_7_record_Record.grsq = (__pyx_t_7sklearn_5earth_7_record_FLOAT_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_Record *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_6Record_grsq; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_Record) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_Record.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_Record) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Record", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_Record) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_Record = &__pyx_type_7sklearn_5earth_7_record_Record; + __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord = &__pyx_vtable_7sklearn_5earth_7_record_ForwardPassRecord; + __pyx_vtable_7sklearn_5earth_7_record_ForwardPassRecord.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_7_record_Record; + __pyx_vtable_7sklearn_5earth_7_record_ForwardPassRecord.set_stopping_condition = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_7_record_ForwardPassRecord *, int, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_17ForwardPassRecord_set_stopping_condition; + __pyx_type_7sklearn_5earth_7_record_ForwardPassRecord.tp_base = __pyx_ptype_7sklearn_5earth_7_record_Record; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_ForwardPassRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_ForwardPassRecord.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "ForwardPassRecord", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_ForwardPassRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_ForwardPassRecord = &__pyx_type_7sklearn_5earth_7_record_ForwardPassRecord; + __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration = &__pyx_vtable_7sklearn_5earth_7_record_PruningPassIteration; + __pyx_vtable_7sklearn_5earth_7_record_PruningPassIteration.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_7_record_Iteration; + __pyx_vtable_7sklearn_5earth_7_record_PruningPassIteration.get_pruned = (__pyx_t_7sklearn_5earth_7_record_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassIteration *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_20PruningPassIteration_get_pruned; + __pyx_type_7sklearn_5earth_7_record_PruningPassIteration.tp_base = __pyx_ptype_7sklearn_5earth_7_record_Iteration; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_PruningPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_PruningPassIteration.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "PruningPassIteration", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_PruningPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration = &__pyx_type_7sklearn_5earth_7_record_PruningPassIteration; + __pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration = &__pyx_vtable_7sklearn_5earth_7_record_FirstPruningPassIteration; + __pyx_vtable_7sklearn_5earth_7_record_FirstPruningPassIteration.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_7_record_PruningPassIteration; + __pyx_type_7sklearn_5earth_7_record_FirstPruningPassIteration.tp_base = __pyx_ptype_7sklearn_5earth_7_record_PruningPassIteration; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_FirstPruningPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_FirstPruningPassIteration.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_FirstPruningPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "FirstPruningPassIteration", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_FirstPruningPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_FirstPruningPassIteration = &__pyx_type_7sklearn_5earth_7_record_FirstPruningPassIteration; + __pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration = &__pyx_vtable_7sklearn_5earth_7_record_FirstForwardPassIteration; + __pyx_vtable_7sklearn_5earth_7_record_FirstForwardPassIteration.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_7_record_ForwardPassIteration; + __pyx_vtable_7sklearn_5earth_7_record_FirstForwardPassIteration.__pyx_base.__pyx_base.get_size = (__pyx_t_7sklearn_5earth_7_record_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_Iteration *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_25FirstForwardPassIteration_get_size; + __pyx_type_7sklearn_5earth_7_record_FirstForwardPassIteration.tp_base = __pyx_ptype_7sklearn_5earth_7_record_ForwardPassIteration; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_FirstForwardPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_FirstForwardPassIteration.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_FirstForwardPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "FirstForwardPassIteration", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_FirstForwardPassIteration) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_FirstForwardPassIteration = &__pyx_type_7sklearn_5earth_7_record_FirstForwardPassIteration; + __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord = &__pyx_vtable_7sklearn_5earth_7_record_PruningPassRecord; + __pyx_vtable_7sklearn_5earth_7_record_PruningPassRecord.__pyx_base = *__pyx_vtabptr_7sklearn_5earth_7_record_Record; + __pyx_vtable_7sklearn_5earth_7_record_PruningPassRecord.set_selected = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, __pyx_t_7sklearn_5earth_7_record_INDEX_t, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_17PruningPassRecord_set_selected; + __pyx_vtable_7sklearn_5earth_7_record_PruningPassRecord.get_selected = (__pyx_t_7sklearn_5earth_7_record_INDEX_t (*)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_17PruningPassRecord_get_selected; + __pyx_vtable_7sklearn_5earth_7_record_PruningPassRecord.roll_back = (PyObject *(*)(struct __pyx_obj_7sklearn_5earth_7_record_PruningPassRecord *, struct __pyx_obj_7sklearn_5earth_6_basis_Basis *, int __pyx_skip_dispatch))__pyx_f_7sklearn_5earth_7_record_17PruningPassRecord_roll_back; + __pyx_type_7sklearn_5earth_7_record_PruningPassRecord.tp_base = __pyx_ptype_7sklearn_5earth_7_record_Record; + if (PyType_Ready(&__pyx_type_7sklearn_5earth_7_record_PruningPassRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_5earth_7_record_PruningPassRecord.tp_dict, __pyx_vtabptr_7sklearn_5earth_7_record_PruningPassRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "PruningPassRecord", (PyObject *)&__pyx_type_7sklearn_5earth_7_record_PruningPassRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_7_record_PruningPassRecord = &__pyx_type_7sklearn_5earth_7_record_PruningPassRecord; + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_BasisFunction = __Pyx_ImportType("sklearn.earth._basis", "BasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_BasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_BasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_BasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_BasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "ConstantBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_ConstantBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_ConstantBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_ConstantBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_ConstantBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "HingeBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_HingeBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_HingeBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_HingeBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_HingeBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction = __Pyx_ImportType("sklearn.earth._basis", "LinearBasisFunction", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_LinearBasisFunction), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_LinearBasisFunction*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_LinearBasisFunction->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_LinearBasisFunction)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_6_basis_Basis = __Pyx_ImportType("sklearn.earth._basis", "Basis", sizeof(struct __pyx_obj_7sklearn_5earth_6_basis_Basis), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_6_basis_Basis)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_6_basis_Basis = (struct __pyx_vtabstruct_7sklearn_5earth_6_basis_Basis*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_6_basis_Basis->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_6_basis_Basis)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_5earth_8_forward_ForwardPasser = __Pyx_ImportType("sklearn.earth._forward", "ForwardPasser", sizeof(struct __pyx_obj_7sklearn_5earth_8_forward_ForwardPasser), 1); if (unlikely(!__pyx_ptype_7sklearn_5earth_8_forward_ForwardPasser)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_7sklearn_5earth_8_forward_ForwardPasser = (struct __pyx_vtabstruct_7sklearn_5earth_8_forward_ForwardPasser*)__Pyx_GetVtable(__pyx_ptype_7sklearn_5earth_8_forward_ForwardPasser->tp_dict); if (unlikely(!__pyx_vtabptr_7sklearn_5earth_8_forward_ForwardPasser)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Variable import code ---*/ + __pyx_t_1 = __Pyx_ImportModule("sklearn.earth._forward"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportVoidPtr(__pyx_t_1, "stopping_conditions", (void **)&__pyx_vp_7sklearn_5earth_8_forward_stopping_conditions, "PyObject *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; + /*--- Function import code ---*/ + __pyx_t_2 = __Pyx_ImportModule("sklearn.earth._util"); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_2, "gcv", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_gcv, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_FLOAT_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ImportFunction(__pyx_t_2, "ascii_table", (void (**)(void))&__pyx_f_7sklearn_5earth_5_util_ascii_table, "PyObject *(PyObject *, PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_DECREF(__pyx_t_2); __pyx_t_2 = 0; + /*--- Execution code ---*/ + + /* "sklearn/earth/_record.pyx":1 + * # distutils: language = c # <<<<<<<<<<<<<< + * # cython: cdivision = True + * # cython: boundscheck = False + */ + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + + /* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + if (__pyx_m) { + __Pyx_AddTraceback("init sklearn.earth._record", __pyx_clineno, __pyx_lineno, __pyx_filename); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init sklearn.earth._record"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* Runtime support code */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%s() got an unexpected keyword argument '%s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return NULL; + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + #if PY_VERSION_HEX < 0x02050000 + if (PyClass_Check(type)) { + #else + if (PyType_Check(type)) { + #endif +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + #if PY_VERSION_HEX < 0x02050000 + if (PyInstance_Check(type)) { + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + Py_INCREF(type); + } else { + type = 0; + PyErr_SetString(PyExc_TypeError, + "raise: exception must be an old-style class or instance"); + goto raise_error; + } + #else + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + #endif + } + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else /* Python 3+ */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + index, (index == 1) ? "" : "s"); +} + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s____pyx_vtable__, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +static void* __Pyx_GetVtable(PyObject *dict) { + void* ptr; + PyObject *ob = PyObject_GetItem(dict, __pyx_n_s____pyx_vtable__); + if (!ob) + goto bad; +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + ptr = PyCapsule_GetPointer(ob, 0); +#else + ptr = PyCObject_AsVoidPtr(ob); +#endif + if (!ptr && !PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); + Py_DECREF(ob); + return ptr; +bad: + Py_XDECREF(ob); + return NULL; +} + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject* x) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if (sizeof(npy_ulonglong) == sizeof(char)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedChar(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedChar(x); + } else if (sizeof(npy_ulonglong) == sizeof(short)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedShort(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedShort(x); + } else if (sizeof(npy_ulonglong) == sizeof(int)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedInt(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedInt(x); + } else if (sizeof(npy_ulonglong) == sizeof(long)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLong(x); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLongLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLongLong(x); + } else { + #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); + #else + npy_ulonglong val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } + #endif + return (npy_ulonglong)-1; + } +} + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong val) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(npy_ulonglong) == sizeof(char)) || + (sizeof(npy_ulonglong) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(npy_ulonglong) == sizeof(int)) || + (sizeof(npy_ulonglong) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); + else + return PyLong_FromLongLong((PY_LONG_LONG)val); + } else { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + return _PyLong_FromByteArray(bytes, sizeof(npy_ulonglong), + little, !is_unsigned); + } +} + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + #if PY_VERSION_HEX >= 0x02050000 + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; /* try absolute import on failure */ + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } + #else + if (level>0) { + PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); + goto bad; + } + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, NULL); + #endif +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { + const unsigned char neg_one = (unsigned char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned char" : + "value too large to convert to unsigned char"); + } + return (unsigned char)-1; + } + return (unsigned char)val; + } + return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { + const unsigned short neg_one = (unsigned short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned short" : + "value too large to convert to unsigned short"); + } + return (unsigned short)-1; + } + return (unsigned short)val; + } + return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { + const unsigned int neg_one = (unsigned int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned int" : + "value too large to convert to unsigned int"); + } + return (unsigned int)-1; + } + return (unsigned int)val; + } + return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { + const char neg_one = (char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to char" : + "value too large to convert to char"); + } + return (char)-1; + } + return (char)val; + } + return (char)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { + const short neg_one = (short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to short" : + "value too large to convert to short"); + } + return (short)-1; + } + return (short)val; + } + return (short)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { + const signed char neg_one = (signed char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed char" : + "value too large to convert to signed char"); + } + return (signed char)-1; + } + return (signed char)val; + } + return (signed char)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { + const signed short neg_one = (signed short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed short" : + "value too large to convert to signed short"); + } + return (signed short)-1; + } + return (signed short)val; + } + return (signed short)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { + const signed int neg_one = (signed int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed int" : + "value too large to convert to signed int"); + } + return (signed int)-1; + } + return (signed int)val; + } + return (signed int)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { + const unsigned long neg_one = (unsigned long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned long)PyLong_AsLong(x); + } + } else { + unsigned long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned long)-1; + val = __Pyx_PyInt_AsUnsignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { + const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + unsigned PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsUnsignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { + const long neg_one = (long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (long)PyLong_AsLong(x); + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (long)-1; + val = __Pyx_PyInt_AsLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { + const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { + const signed long neg_one = (signed long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed long)PyLong_AsLong(x); + } + } else { + signed long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed long)-1; + val = __Pyx_PyInt_AsSignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { + const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + signed PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsSignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + #if PY_VERSION_HEX < 0x02050000 + return PyErr_Warn(NULL, message); + #else + return PyErr_WarnEx(NULL, message, 1); + #endif + } + return 0; +} + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility", + module_name, class_name); + #if PY_VERSION_HEX < 0x02050000 + if (PyErr_Warn(NULL, warning) < 0) goto bad; + #else + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + #endif + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s has the wrong size, try recompiling", + module_name, class_name); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportVoidPtr +#define __PYX_HAVE_RT_ImportVoidPtr +static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, name); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%s does not export expected C variable %s", + PyModule_GetName(module), name); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C variable %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj)); + goto bad; + } + *p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C variable %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), name, sig, desc); + goto bad; + } + *p = PyCObject_AsVoidPtr(cobj);} +#endif + if (!(*p)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportFunction +#define __PYX_HAVE_RT_ImportFunction +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, funcname); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%s does not export expected C function %s", + PyModule_GetName(module), funcname); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); + goto bad; + } + tmp.p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, desc); + goto bad; + } + tmp.p = PyCObject_AsVoidPtr(cobj);} +#endif + *f = tmp.fp; + if (!(*f)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = (start + end) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, /*int firstlineno,*/ + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_globals = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else /* Python 3+ has unicode identifiers */ + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else /* PY_VERSION_HEX < 0x03030000 */ + if (PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_DATA_SIZE(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ + return PyUnicode_AsUTF8AndSize(o, length); +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ +#endif /* PY_VERSION_HEX < 0x03030000 */ + } else +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (r < 0) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return Py_INCREF(x), x; + m = Py_TYPE(x)->tp_as_number; +#if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%s__ returned non-%s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject* x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { +#if PY_VERSION_HEX < 0x02050000 + if (ival <= LONG_MAX) + return PyInt_FromLong((long)ival); + else { + unsigned char *bytes = (unsigned char *) &ival; + int one = 1; int little = (int)*(unsigned char*)&one; + return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); + } +#else + return PyInt_FromSize_t(ival); +#endif +} +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { + unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); + if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t)-1; + } + return (size_t)val; +} + + +#endif /* Py_PYTHON_H */ diff --git a/sklearn/earth/_record.pxd b/sklearn/earth/_record.pxd new file mode 100644 index 0000000000000..062929cf9799b --- /dev/null +++ b/sklearn/earth/_record.pxd @@ -0,0 +1,69 @@ +cimport numpy as cnp +ctypedef cnp.float64_t FLOAT_t +ctypedef cnp.intp_t INT_t +ctypedef cnp.ulong_t INDEX_t +ctypedef cnp.uint8_t BOOL_t +from _basis cimport Basis + +cdef class Record: + cdef list iterations + cdef int num_samples + cdef int num_variables + cdef FLOAT_t penalty + cdef FLOAT_t sst # Sum of squares total + + cpdef append(Record self, Iteration iteration) + + cpdef FLOAT_t mse(Record self, INDEX_t iteration) + + cpdef FLOAT_t rsq(Record self, INDEX_t iteration) + + cpdef FLOAT_t gcv(Record self, INDEX_t iteration) + + cpdef FLOAT_t grsq(Record self, INDEX_t iteration) + +cdef class PruningPassRecord(Record): + cdef INDEX_t selected + + cpdef set_selected(PruningPassRecord self, INDEX_t selected) + + cpdef INDEX_t get_selected(PruningPassRecord self) + + cpdef roll_back(PruningPassRecord self, Basis basis) + +cdef class ForwardPassRecord(Record): + cdef int stopping_condition + + cdef list xlabels + + cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition) + +cdef class Iteration: + cdef FLOAT_t mse + cdef INDEX_t size + + cpdef FLOAT_t get_mse(Iteration self) + + cpdef INDEX_t get_size(Iteration self) + +cdef class PruningPassIteration(Iteration): + cdef INDEX_t pruned + + cpdef INDEX_t get_pruned(PruningPassIteration self) + +cdef class FirstPruningPassIteration(PruningPassIteration): + pass + +cdef class ForwardPassIteration(Iteration): + cdef INDEX_t parent + cdef INDEX_t variable + cdef FLOAT_t knot + cdef int code + cdef bint no_candidates + + cpdef set_no_candidates(ForwardPassIteration self, bint value) + + cpdef no_further_candidates(ForwardPassIteration self) + +cdef class FirstForwardPassIteration(ForwardPassIteration): + cpdef INDEX_t get_size(FirstForwardPassIteration self) diff --git a/sklearn/earth/_record.pyx b/sklearn/earth/_record.pyx new file mode 100644 index 0000000000000..aa27153e4917d --- /dev/null +++ b/sklearn/earth/_record.pyx @@ -0,0 +1,272 @@ +# distutils: language = c +# cython: cdivision = True +# cython: boundscheck = False +# cython: wraparound = False +# cython: profile = False + +from ._util cimport gcv, ascii_table +from ._forward cimport stopping_conditions + +cdef class Record: + + def __richcmp__(self, other, method): + if method == 2: + return self._eq(other) + elif method == 3: + return not self._eq(other) + else: + return NotImplemented + + def _eq(self, other): + return self.__class__ is other.__class__ and self._getstate() == other._getstate() + + def __getitem__(Record self, int idx): + return self.iterations[idx] + + def __len__(Record self): + return len(self.iterations) + + cpdef append(Record self, Iteration iteration): + self.iterations.append(iteration) + + cpdef FLOAT_t mse(Record self, INDEX_t iteration): + return self.iterations[iteration].get_mse() + + cpdef FLOAT_t gcv(Record self, INDEX_t iteration): + cdef Iteration it = self.iterations[iteration] + cdef FLOAT_t mse = it.mse + return gcv(mse, it.get_size(), self.num_samples, self.penalty) + + cpdef FLOAT_t rsq(Record self, INDEX_t iteration): + # gcv(self.sst,1,self.num_samples,self.penalty) + cdef FLOAT_t mse0 = self.sst + # gcv(self.mse(iteration):,self.iterations[iteration].get_size(),self.num_samples,self.penalty)#self.gcv(iteration) + cdef FLOAT_t mse = self.mse(iteration) + return 1 - (mse / mse0) + + cpdef FLOAT_t grsq(Record self, INDEX_t iteration): + cdef FLOAT_t gcv0 = gcv(self.sst, 1, self.num_samples, self.penalty) + cdef FLOAT_t gcv_ = self.gcv(iteration) + return 1 - (gcv_ / gcv0) + +cdef class PruningPassRecord(Record): + def __init__(PruningPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, INDEX_t size, FLOAT_t mse): + self.num_samples = num_samples + self.num_variables = num_variables + self.penalty = penalty + self.sst = sst + self.iterations = [FirstPruningPassIteration(size, mse)] + + def __reduce__(PruningPassRecord self): + return (PruningPassRecord, (1, 1, 1.0, 1.0, 1, 1.0), self._getstate()) + + def _getstate(PruningPassRecord self): + result = {'num_samples': self.num_samples, + 'num_variables': self.num_variables, + 'penalty': self.penalty, + 'sst': self.sst, + 'iterations': self.iterations, + 'selected': self.selected} + return result + + def __setstate__(PruningPassRecord self, dict state): + self.num_samples = state['num_samples'] + self.num_variables = state['num_variables'] + self.penalty = state['penalty'] + self.sst = state['sst'] + self.iterations = state['iterations'] + self.selected = state['selected'] + + cpdef set_selected(PruningPassRecord self, INDEX_t selected): + self.selected = selected + + cpdef INDEX_t get_selected(PruningPassRecord self): + return self.selected + + cpdef roll_back(PruningPassRecord self, Basis basis): + cdef INDEX_t n = len(self.iterations) + cdef INDEX_t i + for i in range(n - self.selected - 1): + basis[self.iterations[n - i - 1].get_pruned()].unprune() + + def __str__(PruningPassRecord self): + result = '' + result += 'Pruning Pass\n' + header = 'iter\tbf\tterms\tmse\tgcv\trsq\tgrsq'.split('\t') + data = [] + for i, iteration in enumerate(self.iterations): + row = str(i) + '\t' + str(iteration) + '\t%.3f\t%.3f\t%.3f' % ( + self.gcv(i), self.rsq(i), self.grsq(i)) + data.append(row.split('\t')) + result += ascii_table(header, data) + result += '\nSelected iteration: ' + str(self.selected) + '\n' + return result + +cdef class ForwardPassRecord(Record): + def __init__(ForwardPassRecord self, INDEX_t num_samples, INDEX_t num_variables, FLOAT_t penalty, FLOAT_t sst, list xlabels): + self.num_samples = num_samples + self.num_variables = num_variables + self.penalty = penalty + self.sst = sst + self.iterations = [FirstForwardPassIteration(self.sst)] + self.xlabels = xlabels + + def __reduce__(ForwardPassRecord self): + return (ForwardPassRecord, (self.num_samples, self.num_variables, self.penalty, self.sst, self.xlabels), self._getstate()) + + def _getstate(ForwardPassRecord self): + return {'num_samples': self.num_samples, + 'num_variables': self.num_variables, + 'penalty': self.penalty, + 'sst': self.sst, + 'iterations': self.iterations, + 'xlabels': self.xlabels} + + def __setstate__(ForwardPassRecord self, dict state): + self.num_samples = state['num_samples'] + self.num_variables = state['num_variables'] + self.penalty = state['penalty'] + self.sst = state['sst'] + self.iterations = state['iterations'] + self.xlabels = state['xlabels'] + + cpdef set_stopping_condition(ForwardPassRecord self, int stopping_condition): + self.stopping_condition = stopping_condition + + def __str__(ForwardPassRecord self): + header = ['iter', 'parent', 'var', 'knot', + 'mse', 'terms', 'gcv', 'rsq', 'grsq'] + data = [] + for i, iteration in enumerate(self.iterations): + data.append( + [str(i)] + str(iteration).split('\t') + ('%.3f\t%.3f\t%.3f' % + (self.gcv(i), self.rsq(i), self.grsq(i))).split('\t')) + result = '' + result += 'Forward Pass\n' + result += ascii_table(header, data) + result += '\nStopping Condition %d: %s\n' % ( + self.stopping_condition, stopping_conditions[self.stopping_condition]) + return result + +cdef class Iteration: + + def __richcmp__(self, other, method): + if method == 2: + return self._eq(other) + elif method == 3: + return not self._eq(other) + else: + return NotImplemented + + def _eq(self, other): + return self.__class__ is other.__class__ and self._getstate() == other._getstate() + + cpdef FLOAT_t get_mse(Iteration self): + return self.mse + + cpdef INDEX_t get_size(Iteration self): + return self.size + +cdef class PruningPassIteration(Iteration): + def __init__(PruningPassIteration self, INDEX_t pruned, INDEX_t size, FLOAT_t mse): + self.pruned = pruned + self.size = size + self.mse = mse + + def __reduce__(PruningPassIteration self): + return (PruningPassIteration, (1, 1, 1.0), self._getstate()) + + def _getstate(PruningPassIteration self): + return {'pruned': self.pruned, + 'size': self.size, + 'mse': self.mse} + + def __setstate__(PruningPassIteration self, dict state): + self.pruned = state['pruned'] + self.size = state['size'] + self.mse = state['mse'] + + cpdef INDEX_t get_pruned(PruningPassIteration self): + return self.pruned + + def __str__(PruningPassIteration self): + result = '%s\t%s\t%s' % (str(self.pruned), self.size, '%.2f' % + self.mse if self.mse is not None else None) + return result + +cdef class FirstPruningPassIteration(PruningPassIteration): + def __init__(PruningPassIteration self, INDEX_t size, FLOAT_t mse): + self.size = size + self.mse = mse + + def __reduce__(FirstPruningPassIteration self): + return (FirstPruningPassIteration, (1, 1.0), self._getstate()) + + def _getstate(FirstPruningPassIteration self): + return {'size': self.size, + 'mse': self.mse} + + def __setstate__(FirstPruningPassIteration self, dict state): + self.size = state['size'] + self.mse = state['mse'] + + def __str__(PruningPassIteration self): + result = '%s\t%s\t%s' % ('-', self.size, '%.2f' % + self.mse if self.mse is not None else None) + return result + +cdef class ForwardPassIteration(Iteration): + def __init__(ForwardPassIteration self, INDEX_t parent, INDEX_t variable, int knot, FLOAT_t mse, INDEX_t size): + self.parent = parent + self.variable = variable + self.knot = knot + self.mse = mse + self.size = size + + def __reduce__(ForwardPassIteration self): + return (ForwardPassIteration, (1, 1, 1, 1.0, 1), self._getstate()) + + def _getstate(ForwardPassIteration self): + return {'parent': self.parent, + 'variable': self.variable, + 'knot': self.knot, + 'mse': self.mse, + 'size': self.size} + + def __setstate__(ForwardPassIteration self, dict state): + self.parent = state['parent'] + self.variable = state['variable'] + self.knot = state['knot'] + self.mse = state['mse'] + self.size = state['size'] + + def __str__(self): + result = '%d\t%d\t%d\t%4f\t%d' % ( + self.parent, self.variable, self.knot, self.mse, self.size) + return result + + cpdef set_no_candidates(ForwardPassIteration self, bint value): + self.no_candidates = value + + cpdef no_further_candidates(ForwardPassIteration self): + return self.no_candidates + +cdef class FirstForwardPassIteration(ForwardPassIteration): + def __init__(FirstForwardPassIteration self, FLOAT_t mse): + self.mse = mse + + def __reduce__(FirstForwardPassIteration self): + return (FirstForwardPassIteration, (1.0,), self._getstate()) + + def _getstate(FirstForwardPassIteration self): + return {'mse': self.mse} + + def __setstate__(FirstForwardPassIteration self, dict state): + self.mse = state['mse'] + + cpdef INDEX_t get_size(FirstForwardPassIteration self): + return 1 + + def __str__(self): + result = '%s\t%s\t%s\t%4f\t%s' % ('-', '-', '-', self.mse, 1) + return result diff --git a/sklearn/earth/_util.c b/sklearn/earth/_util.c new file mode 100644 index 0000000000000..39b80952d7183 --- /dev/null +++ b/sklearn/earth/_util.c @@ -0,0 +1,8273 @@ +/* Generated by Cython 0.19.2 on Sat Nov 30 16:32:13 2013 */ + +#define PY_SSIZE_T_CLEAN +#ifndef CYTHON_USE_PYLONG_INTERNALS +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 0 +#else +#include "pyconfig.h" +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 1 +#else +#define CYTHON_USE_PYLONG_INTERNALS 0 +#endif +#endif +#endif +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02040000 + #error Cython requires Python 2.4+. +#else +#include /* For offsetof */ +#ifndef offsetof +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION +#define CYTHON_COMPILING_IN_PYPY 1 +#define CYTHON_COMPILING_IN_CPYTHON 0 +#else +#define CYTHON_COMPILING_IN_PYPY 0 +#define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if PY_VERSION_HEX < 0x02050000 + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ + (PyErr_Format(PyExc_TypeError, \ + "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ + (PyObject*)0)) + #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ + !PyComplex_Check(o)) + #define PyIndex_Check __Pyx_PyIndex_Check + #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) + #define __PYX_BUILD_PY_SSIZE_T "i" +#else + #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" + #define __Pyx_PyIndex_Check PyIndex_Check +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) + #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) + #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + #define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + #define PyType_Modified(t) + typedef struct { + void *buf; + PyObject *obj; + Py_ssize_t len; + Py_ssize_t itemsize; + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; + } Py_buffer; + #define PyBUF_SIMPLE 0 + #define PyBUF_WRITABLE 0x0001 + #define PyBUF_FORMAT 0x0004 + #define PyBUF_ND 0x0008 + #define PyBUF_STRIDES (0x0010 | PyBUF_ND) + #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) + #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) + #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) + #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) + #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) + typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); + typedef void (*releasebufferproc)(PyObject *, Py_buffer *); +#endif +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif +#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 + #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") +#endif +#if PY_MAJOR_VERSION >= 3 + #define Py_TPFLAGS_CHECKTYPES 0 + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#if PY_VERSION_HEX < 0x02060000 + #define Py_TPFLAGS_HAVE_VERSION_TAG 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PyBytesObject PyStringObject + #define PyBytes_Type PyString_Type + #define PyBytes_Check PyString_Check + #define PyBytes_CheckExact PyString_CheckExact + #define PyBytes_FromString PyString_FromString + #define PyBytes_FromStringAndSize PyString_FromStringAndSize + #define PyBytes_FromFormat PyString_FromFormat + #define PyBytes_DecodeEscape PyString_DecodeEscape + #define PyBytes_AsString PyString_AsString + #define PyBytes_AsStringAndSize PyString_AsStringAndSize + #define PyBytes_Size PyString_Size + #define PyBytes_AS_STRING PyString_AS_STRING + #define PyBytes_GET_SIZE PyString_GET_SIZE + #define PyBytes_Repr PyString_Repr + #define PyBytes_Concat PyString_Concat + #define PyBytes_ConcatAndDel PyString_ConcatAndDel +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ + PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) +#endif +#if PY_VERSION_HEX < 0x02060000 + #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) + #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_VERSION_HEX < 0x03020000 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) + #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) + #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) +#else + #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) + #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) + #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ + (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ + (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ + (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) +#else + #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) + #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) + #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) +#endif +#if PY_VERSION_HEX < 0x02050000 + #define __Pyx_NAMESTR(n) ((char *)(n)) + #define __Pyx_DOCSTR(n) ((char *)(n)) +#else + #define __Pyx_NAMESTR(n) (n) + #define __Pyx_DOCSTR(n) (n) +#endif +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + a quiet NaN. */ + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif + + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) +#define _USE_MATH_DEFINES +#endif +#include +#define __PYX_HAVE__sklearn__earth___util +#define __PYX_HAVE_API__sklearn__earth___util +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#include "math.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) +#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) +#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return u_end - u - 1; +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + const char* default_encoding_c = PyBytes_AS_STRING(default_encoding); + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (ascii_chars_u == NULL) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + } + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params() { + PyObject* sys = NULL; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (sys == NULL) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + if (default_encoding == NULL) goto bad; + default_encoding_c = PyBytes_AS_STRING(default_encoding); + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(sys); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(sys); + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +#ifdef __GNUC__ + /* Test for GCC > 2.95 */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #else /* __GNUC__ > 2 ... */ + #define likely(x) (x) + #define unlikely(x) (x) + #endif /* __GNUC__ > 2 ... */ +#else /* __GNUC__ */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "_util.pyx", + "numpy.pxd", + "type.pxd", +}; +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; /* for error messages only */ + struct __Pyx_StructField_* fields; + size_t size; /* sizeof(type) */ + size_t arraysize[8]; /* length of array in each dimension */ + int ndim; + char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */ + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "numpy.pxd":723 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "numpy.pxd":724 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "numpy.pxd":725 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "numpy.pxd":726 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "numpy.pxd":730 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "numpy.pxd":731 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "numpy.pxd":732 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "numpy.pxd":733 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "numpy.pxd":737 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "numpy.pxd":738 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "numpy.pxd":747 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "numpy.pxd":748 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "numpy.pxd":749 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "numpy.pxd":751 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "numpy.pxd":752 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "numpy.pxd":753 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "numpy.pxd":755 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "numpy.pxd":756 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "numpy.pxd":758 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "numpy.pxd":759 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "numpy.pxd":760 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "sklearn/earth/_util.pxd":2 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t # <<<<<<<<<<<<<< + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_5earth_5_util_FLOAT_t; + +/* "sklearn/earth/_util.pxd":3 + * cimport numpy as cnp + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t # <<<<<<<<<<<<<< + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t + */ +typedef __pyx_t_5numpy_intp_t __pyx_t_7sklearn_5earth_5_util_INT_t; + +/* "sklearn/earth/_util.pxd":4 + * ctypedef cnp.float64_t FLOAT_t + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t # <<<<<<<<<<<<<< + * ctypedef cnp.uint8_t BOOL_t + * + */ +typedef __pyx_t_5numpy_ulong_t __pyx_t_7sklearn_5earth_5_util_INDEX_t; + +/* "sklearn/earth/_util.pxd":5 + * ctypedef cnp.intp_t INT_t + * ctypedef cnp.ulong_t INDEX_t + * ctypedef cnp.uint8_t BOOL_t # <<<<<<<<<<<<<< + * + * cdef FLOAT_t log2(FLOAT_t x) + */ +typedef __pyx_t_5numpy_uint8_t __pyx_t_7sklearn_5earth_5_util_BOOL_t; +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ + +/* "numpy.pxd":762 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "numpy.pxd":763 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "numpy.pxd":764 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "numpy.pxd":766 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); + +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) +#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); /*proto*/ + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( + PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** py_start, PyObject** py_stop, PyObject** py_slice, + int has_cstart, int has_cstop, int wraparound); + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; +static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject *); + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong); + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); + +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); + +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); + +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); + +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); + +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); + +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); + +static int __Pyx_check_binary_version(void); + +static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /*proto*/ + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + +typedef struct { + int code_line; + PyCodeObject* code_object; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'libc.math' */ + +/* Module declarations from 'sklearn.earth._util' */ +static PyObject *__pyx_f_7sklearn_5earth_5_util_apply_weights_2d(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_apply_weights_slice(PyArrayObject *, PyArrayObject *, __pyx_t_7sklearn_5earth_5_util_INDEX_t, int __pyx_skip_dispatch); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_apply_weights_1d(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_f_7sklearn_5earth_5_util_gcv(__pyx_t_7sklearn_5earth_5_util_FLOAT_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch); /*proto*/ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_f_7sklearn_5earth_5_util_gcv_adjust(__pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_str_pad(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_ascii_table(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/ +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t = { "FLOAT_t", NULL, sizeof(__pyx_t_7sklearn_5earth_5_util_FLOAT_t), { 0 }, 0, 'R', 0, 0 }; +#define __Pyx_MODULE_NAME "sklearn.earth._util" +int __pyx_module_is_main_sklearn__earth___util = 0; + +/* Implementation of 'sklearn.earth._util' */ +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_enumerate; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_pf_7sklearn_5earth_5_util_apply_weights_2d(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_5_util_2apply_weights_slice(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_column); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_5_util_4apply_weights_1d(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_weights); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_5_util_6gcv(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_mse, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_5_util_8gcv_adjust(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_5_util_10str_pad(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_string, PyObject *__pyx_v_length); /* proto */ +static PyObject *__pyx_pf_7sklearn_5earth_5_util_12ascii_table(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_header, PyObject *__pyx_v_data); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static char __pyx_k_1[] = " "; +static char __pyx_k_2[] = ""; +static char __pyx_k_3[] = "-"; +static char __pyx_k_4[] = "\n"; +static char __pyx_k_5[] = "ndarray is not C contiguous"; +static char __pyx_k_7[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_9[] = "Non-native byte order not supported"; +static char __pyx_k_11[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_12[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_15[] = "Format string allocated too short."; +static char __pyx_k__B[] = "B"; +static char __pyx_k__H[] = "H"; +static char __pyx_k__I[] = "I"; +static char __pyx_k__L[] = "L"; +static char __pyx_k__O[] = "O"; +static char __pyx_k__Q[] = "Q"; +static char __pyx_k__b[] = "b"; +static char __pyx_k__d[] = "d"; +static char __pyx_k__f[] = "f"; +static char __pyx_k__g[] = "g"; +static char __pyx_k__h[] = "h"; +static char __pyx_k__i[] = "i"; +static char __pyx_k__l[] = "l"; +static char __pyx_k__q[] = "q"; +static char __pyx_k__y[] = "y"; +static char __pyx_k__Zd[] = "Zd"; +static char __pyx_k__Zf[] = "Zf"; +static char __pyx_k__Zg[] = "Zg"; +static char __pyx_k__np[] = "np"; +static char __pyx_k__mse[] = "mse"; +static char __pyx_k__data[] = "data"; +static char __pyx_k__numpy[] = "numpy"; +static char __pyx_k__range[] = "range"; +static char __pyx_k__column[] = "column"; +static char __pyx_k__header[] = "header"; +static char __pyx_k__length[] = "length"; +static char __pyx_k__string[] = "string"; +static char __pyx_k__penalty[] = "penalty"; +static char __pyx_k__weights[] = "weights"; +static char __pyx_k____main__[] = "__main__"; +static char __pyx_k____test__[] = "__test__"; +static char __pyx_k__data_size[] = "data_size"; +static char __pyx_k__enumerate[] = "enumerate"; +static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k____import__[] = "__import__"; +static char __pyx_k__basis_size[] = "basis_size"; +static char __pyx_k__RuntimeError[] = "RuntimeError"; +static char __pyx_k____pyx_getbuffer[] = "__pyx_getbuffer"; +static char __pyx_k____pyx_releasebuffer[] = "__pyx_releasebuffer"; +static PyObject *__pyx_kp_s_1; +static PyObject *__pyx_kp_u_11; +static PyObject *__pyx_kp_u_12; +static PyObject *__pyx_kp_u_15; +static PyObject *__pyx_kp_s_2; +static PyObject *__pyx_kp_s_3; +static PyObject *__pyx_kp_s_4; +static PyObject *__pyx_kp_u_5; +static PyObject *__pyx_kp_u_7; +static PyObject *__pyx_kp_u_9; +static PyObject *__pyx_n_s__B; +static PyObject *__pyx_n_s__RuntimeError; +static PyObject *__pyx_n_s__ValueError; +static PyObject *__pyx_n_s____import__; +static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____pyx_getbuffer; +static PyObject *__pyx_n_s____pyx_releasebuffer; +static PyObject *__pyx_n_s____test__; +static PyObject *__pyx_n_s__basis_size; +static PyObject *__pyx_n_s__column; +static PyObject *__pyx_n_s__data; +static PyObject *__pyx_n_s__data_size; +static PyObject *__pyx_n_s__enumerate; +static PyObject *__pyx_n_s__header; +static PyObject *__pyx_n_s__length; +static PyObject *__pyx_n_s__mse; +static PyObject *__pyx_n_s__np; +static PyObject *__pyx_n_s__numpy; +static PyObject *__pyx_n_s__penalty; +static PyObject *__pyx_n_s__range; +static PyObject *__pyx_n_s__string; +static PyObject *__pyx_n_s__weights; +static PyObject *__pyx_n_s__y; +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_15; +static PyObject *__pyx_k_tuple_6; +static PyObject *__pyx_k_tuple_8; +static PyObject *__pyx_k_tuple_10; +static PyObject *__pyx_k_tuple_13; +static PyObject *__pyx_k_tuple_14; +static PyObject *__pyx_k_tuple_16; + +/* "sklearn/earth/_util.pyx":10 + * from libc.math cimport sqrt, log + * + * cdef FLOAT_t log2(FLOAT_t x): # <<<<<<<<<<<<<< + * return log(x) / log(2.0) + * + */ + +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_f_7sklearn_5earth_5_util_log2(__pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_x) { + __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("log2", 0); + + /* "sklearn/earth/_util.pyx":11 + * + * cdef FLOAT_t log2(FLOAT_t x): + * return log(x) / log(2.0) # <<<<<<<<<<<<<< + * + * cpdef apply_weights_2d(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): + */ + __pyx_r = (log(__pyx_v_x) / log(2.0)); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":13 + * return log(x) / log(2.0) + * + * cpdef apply_weights_2d(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t j + */ + +static PyObject *__pyx_pw_7sklearn_5earth_5_util_1apply_weights_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_apply_weights_2d(PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights, CYTHON_UNUSED int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_j; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_m; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_n; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_1; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_2; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_3; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_4; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_5; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_6; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply_weights_2d", 0); + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + + /* "sklearn/earth/_util.pyx":16 + * cdef INDEX_t i + * cdef INDEX_t j + * cdef INDEX_t m = B.shape[0] # <<<<<<<<<<<<<< + * cdef INDEX_t n = B.shape[1] + * for i in range(m): + */ + __pyx_v_m = (__pyx_v_B->dimensions[0]); + + /* "sklearn/earth/_util.pyx":17 + * cdef INDEX_t j + * cdef INDEX_t m = B.shape[0] + * cdef INDEX_t n = B.shape[1] # <<<<<<<<<<<<<< + * for i in range(m): + * for j in range(n): + */ + __pyx_v_n = (__pyx_v_B->dimensions[1]); + + /* "sklearn/earth/_util.pyx":18 + * cdef INDEX_t m = B.shape[0] + * cdef INDEX_t n = B.shape[1] + * for i in range(m): # <<<<<<<<<<<<<< + * for j in range(n): + * B[i, j] *= sqrt(weights[i]) + */ + __pyx_t_1 = __pyx_v_m; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; + + /* "sklearn/earth/_util.pyx":19 + * cdef INDEX_t n = B.shape[1] + * for i in range(m): + * for j in range(n): # <<<<<<<<<<<<<< + * B[i, j] *= sqrt(weights[i]) + * + */ + __pyx_t_3 = __pyx_v_n; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_j = __pyx_t_4; + + /* "sklearn/earth/_util.pyx":20 + * for i in range(m): + * for j in range(n): + * B[i, j] *= sqrt(weights[i]) # <<<<<<<<<<<<<< + * + * cpdef apply_weights_slice(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights, INDEX_t column): + */ + __pyx_t_5 = __pyx_v_i; + __pyx_t_6 = __pyx_v_i; + __pyx_t_7 = __pyx_v_j; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_5_util_FLOAT_t *, __pyx_pybuffernd_B.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_B.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_B.diminfo[1].strides) *= sqrt((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_5_util_FLOAT_t *, __pyx_pybuffernd_weights.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_weights.diminfo[0].strides))); + } + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_2d", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_1apply_weights_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_1apply_weights_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_B = 0; + PyArrayObject *__pyx_v_weights = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("apply_weights_2d (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__B,&__pyx_n_s__weights,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__B)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weights)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply_weights_2d", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply_weights_2d") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_B = ((PyArrayObject *)values[0]); + __pyx_v_weights = ((PyArrayObject *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("apply_weights_2d", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_2d", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_B), __pyx_ptype_5numpy_ndarray, 1, "B", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weights), __pyx_ptype_5numpy_ndarray, 1, "weights", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_5_util_apply_weights_2d(__pyx_self, __pyx_v_B, __pyx_v_weights); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":13 + * return log(x) / log(2.0) + * + * cpdef apply_weights_2d(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t j + */ + +static PyObject *__pyx_pf_7sklearn_5earth_5_util_apply_weights_2d(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply_weights_2d", 0); + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_7sklearn_5earth_5_util_apply_weights_2d(((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_weights), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_2d", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":22 + * B[i, j] *= sqrt(weights[i]) + * + * cpdef apply_weights_slice(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights, INDEX_t column): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t j + */ + +static PyObject *__pyx_pw_7sklearn_5earth_5_util_3apply_weights_slice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_apply_weights_slice(PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_column, CYTHON_UNUSED int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_m; + CYTHON_UNUSED __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_n; + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_1; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_2; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_3; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_4; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply_weights_slice", 0); + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + + /* "sklearn/earth/_util.pyx":25 + * cdef INDEX_t i + * cdef INDEX_t j + * cdef INDEX_t m = B.shape[0] # <<<<<<<<<<<<<< + * cdef INDEX_t n = B.shape[1] + * for i in range(m): + */ + __pyx_v_m = (__pyx_v_B->dimensions[0]); + + /* "sklearn/earth/_util.pyx":26 + * cdef INDEX_t j + * cdef INDEX_t m = B.shape[0] + * cdef INDEX_t n = B.shape[1] # <<<<<<<<<<<<<< + * for i in range(m): + * B[i, column] *= sqrt(weights[i]) + */ + __pyx_v_n = (__pyx_v_B->dimensions[1]); + + /* "sklearn/earth/_util.pyx":27 + * cdef INDEX_t m = B.shape[0] + * cdef INDEX_t n = B.shape[1] + * for i in range(m): # <<<<<<<<<<<<<< + * B[i, column] *= sqrt(weights[i]) + * + */ + __pyx_t_1 = __pyx_v_m; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; + + /* "sklearn/earth/_util.pyx":28 + * cdef INDEX_t n = B.shape[1] + * for i in range(m): + * B[i, column] *= sqrt(weights[i]) # <<<<<<<<<<<<<< + * + * cpdef apply_weights_1d(cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights): + */ + __pyx_t_3 = __pyx_v_i; + __pyx_t_4 = __pyx_v_i; + __pyx_t_5 = __pyx_v_column; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_5earth_5_util_FLOAT_t *, __pyx_pybuffernd_B.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_B.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_B.diminfo[1].strides) *= sqrt((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_5_util_FLOAT_t *, __pyx_pybuffernd_weights.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_weights.diminfo[0].strides))); + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_3apply_weights_slice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_3apply_weights_slice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_B = 0; + PyArrayObject *__pyx_v_weights = 0; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_column; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("apply_weights_slice (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__B,&__pyx_n_s__weights,&__pyx_n_s__column,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__B)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weights)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply_weights_slice", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__column)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply_weights_slice", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply_weights_slice") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __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_B = ((PyArrayObject *)values[0]); + __pyx_v_weights = ((PyArrayObject *)values[1]); + __pyx_v_column = __Pyx_PyInt_from_py_npy_ulonglong(values[2]); if (unlikely((__pyx_v_column == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("apply_weights_slice", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_B), __pyx_ptype_5numpy_ndarray, 1, "B", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weights), __pyx_ptype_5numpy_ndarray, 1, "weights", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_5_util_2apply_weights_slice(__pyx_self, __pyx_v_B, __pyx_v_weights, __pyx_v_column); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":22 + * B[i, j] *= sqrt(weights[i]) + * + * cpdef apply_weights_slice(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights, INDEX_t column): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t j + */ + +static PyObject *__pyx_pf_7sklearn_5earth_5_util_2apply_weights_slice(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_B, PyArrayObject *__pyx_v_weights, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_column) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_B; + __Pyx_Buffer __pyx_pybuffer_B; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply_weights_slice", 0); + __pyx_pybuffer_B.pybuffer.buf = NULL; + __pyx_pybuffer_B.refcount = 0; + __pyx_pybuffernd_B.data = NULL; + __pyx_pybuffernd_B.rcbuffer = &__pyx_pybuffer_B; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_B.rcbuffer->pybuffer, (PyObject*)__pyx_v_B, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_B.diminfo[0].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_B.diminfo[0].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_B.diminfo[1].strides = __pyx_pybuffernd_B.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_B.diminfo[1].shape = __pyx_pybuffernd_B.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_7sklearn_5earth_5_util_apply_weights_slice(((PyArrayObject *)__pyx_v_B), ((PyArrayObject *)__pyx_v_weights), __pyx_v_column, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_B.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":30 + * B[i, column] *= sqrt(weights[i]) + * + * cpdef apply_weights_1d(cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t m = y.shape[0] + */ + +static PyObject *__pyx_pw_7sklearn_5earth_5_util_5apply_weights_1d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_apply_weights_1d(PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_weights, CYTHON_UNUSED int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_i; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_m; + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_1; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_2; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_3; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply_weights_1d", 0); + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + + /* "sklearn/earth/_util.pyx":32 + * cpdef apply_weights_1d(cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights): + * cdef INDEX_t i + * cdef INDEX_t m = y.shape[0] # <<<<<<<<<<<<<< + * for i in range(m): + * y[i] *= sqrt(weights[i]) + */ + __pyx_v_m = (__pyx_v_y->dimensions[0]); + + /* "sklearn/earth/_util.pyx":33 + * cdef INDEX_t i + * cdef INDEX_t m = y.shape[0] + * for i in range(m): # <<<<<<<<<<<<<< + * y[i] *= sqrt(weights[i]) + * + */ + __pyx_t_1 = __pyx_v_m; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; + + /* "sklearn/earth/_util.pyx":34 + * cdef INDEX_t m = y.shape[0] + * for i in range(m): + * y[i] *= sqrt(weights[i]) # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t gcv(FLOAT_t mse, INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): + */ + __pyx_t_3 = __pyx_v_i; + __pyx_t_4 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_5_util_FLOAT_t *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_y.diminfo[0].strides) *= sqrt((*__Pyx_BufPtrStrided1d(__pyx_t_7sklearn_5earth_5_util_FLOAT_t *, __pyx_pybuffernd_weights.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_weights.diminfo[0].strides))); + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_1d", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_5apply_weights_1d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_5apply_weights_1d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_y = 0; + PyArrayObject *__pyx_v_weights = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("apply_weights_1d (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__y,&__pyx_n_s__weights,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weights)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("apply_weights_1d", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply_weights_1d") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_y = ((PyArrayObject *)values[0]); + __pyx_v_weights = ((PyArrayObject *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("apply_weights_1d", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_1d", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weights), __pyx_ptype_5numpy_ndarray, 1, "weights", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_7sklearn_5earth_5_util_4apply_weights_1d(__pyx_self, __pyx_v_y, __pyx_v_weights); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":30 + * B[i, column] *= sqrt(weights[i]) + * + * cpdef apply_weights_1d(cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights): # <<<<<<<<<<<<<< + * cdef INDEX_t i + * cdef INDEX_t m = y.shape[0] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_5_util_4apply_weights_1d(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_weights) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_weights; + __Pyx_Buffer __pyx_pybuffer_weights; + __Pyx_LocalBuf_ND __pyx_pybuffernd_y; + __Pyx_Buffer __pyx_pybuffer_y; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("apply_weights_1d", 0); + __pyx_pybuffer_y.pybuffer.buf = NULL; + __pyx_pybuffer_y.refcount = 0; + __pyx_pybuffernd_y.data = NULL; + __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_pybuffer_weights.pybuffer.buf = NULL; + __pyx_pybuffer_weights.refcount = 0; + __pyx_pybuffernd_weights.data = NULL; + __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_5earth_5_util_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_7sklearn_5earth_5_util_apply_weights_1d(((PyArrayObject *)__pyx_v_y), ((PyArrayObject *)__pyx_v_weights), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("sklearn.earth._util.apply_weights_1d", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":36 + * y[i] *= sqrt(weights[i]) + * + * cpdef FLOAT_t gcv(FLOAT_t mse, INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): # <<<<<<<<<<<<<< + * return mse * gcv_adjust(basis_size, data_size, penalty) + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_5_util_7gcv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_f_7sklearn_5earth_5_util_gcv(__pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_mse, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty, CYTHON_UNUSED int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gcv", 0); + + /* "sklearn/earth/_util.pyx":37 + * + * cpdef FLOAT_t gcv(FLOAT_t mse, INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): + * return mse * gcv_adjust(basis_size, data_size, penalty) # <<<<<<<<<<<<<< + * + * cpdef FLOAT_t gcv_adjust(INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): + */ + __pyx_r = (__pyx_v_mse * __pyx_f_7sklearn_5earth_5_util_gcv_adjust(__pyx_v_basis_size, __pyx_v_data_size, __pyx_v_penalty, 0)); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_7gcv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_7gcv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_mse; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size; + __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gcv (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__mse,&__pyx_n_s__basis_size,&__pyx_n_s__data_size,&__pyx_n_s__penalty,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); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mse)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__basis_size)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("gcv", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data_size)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("gcv", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__penalty)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("gcv", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gcv") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __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_mse = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_mse == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_basis_size = __Pyx_PyInt_from_py_npy_ulonglong(values[1]); if (unlikely((__pyx_v_basis_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_data_size = __Pyx_PyInt_from_py_npy_ulonglong(values[2]); if (unlikely((__pyx_v_data_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_penalty = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_penalty == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("gcv", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._util.gcv", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_5_util_6gcv(__pyx_self, __pyx_v_mse, __pyx_v_basis_size, __pyx_v_data_size, __pyx_v_penalty); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":36 + * y[i] *= sqrt(weights[i]) + * + * cpdef FLOAT_t gcv(FLOAT_t mse, INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): # <<<<<<<<<<<<<< + * return mse * gcv_adjust(basis_size, data_size, penalty) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_5_util_6gcv(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_mse, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gcv", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(__pyx_f_7sklearn_5earth_5_util_gcv(__pyx_v_mse, __pyx_v_basis_size, __pyx_v_data_size, __pyx_v_penalty, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._util.gcv", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":39 + * return mse * gcv_adjust(basis_size, data_size, penalty) + * + * cpdef FLOAT_t gcv_adjust(INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): # <<<<<<<<<<<<<< + * return 1.0 / ((1 - ((basis_size + penalty * (basis_size - 1)) / data_size)) ** 2) + * + */ + +static PyObject *__pyx_pw_7sklearn_5earth_5_util_9gcv_adjust(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_f_7sklearn_5earth_5_util_gcv_adjust(__pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty, CYTHON_UNUSED int __pyx_skip_dispatch) { + __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gcv_adjust", 0); + + /* "sklearn/earth/_util.pyx":40 + * + * cpdef FLOAT_t gcv_adjust(INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): + * return 1.0 / ((1 - ((basis_size + penalty * (basis_size - 1)) / data_size)) ** 2) # <<<<<<<<<<<<<< + * + * cpdef str_pad(string, length): + */ + __pyx_r = (1.0 / pow((1.0 - ((__pyx_v_basis_size + (__pyx_v_penalty * (__pyx_v_basis_size - 1))) / __pyx_v_data_size)), 2.0)); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_9gcv_adjust(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_9gcv_adjust(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size; + __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size; + __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gcv_adjust (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__basis_size,&__pyx_n_s__data_size,&__pyx_n_s__penalty,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); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__basis_size)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data_size)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("gcv_adjust", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__penalty)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("gcv_adjust", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gcv_adjust") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __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_basis_size = __Pyx_PyInt_from_py_npy_ulonglong(values[0]); if (unlikely((__pyx_v_basis_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_data_size = __Pyx_PyInt_from_py_npy_ulonglong(values[1]); if (unlikely((__pyx_v_data_size == (npy_ulonglong)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_penalty = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_penalty == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("gcv_adjust", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._util.gcv_adjust", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_5_util_8gcv_adjust(__pyx_self, __pyx_v_basis_size, __pyx_v_data_size, __pyx_v_penalty); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":39 + * return mse * gcv_adjust(basis_size, data_size, penalty) + * + * cpdef FLOAT_t gcv_adjust(INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): # <<<<<<<<<<<<<< + * return 1.0 / ((1 - ((basis_size + penalty * (basis_size - 1)) / data_size)) ** 2) + * + */ + +static PyObject *__pyx_pf_7sklearn_5earth_5_util_8gcv_adjust(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_basis_size, __pyx_t_7sklearn_5earth_5_util_INDEX_t __pyx_v_data_size, __pyx_t_7sklearn_5earth_5_util_FLOAT_t __pyx_v_penalty) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gcv_adjust", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(__pyx_f_7sklearn_5earth_5_util_gcv_adjust(__pyx_v_basis_size, __pyx_v_data_size, __pyx_v_penalty, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._util.gcv_adjust", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":42 + * return 1.0 / ((1 - ((basis_size + penalty * (basis_size - 1)) / data_size)) ** 2) + * + * cpdef str_pad(string, length): # <<<<<<<<<<<<<< + * if len(string) >= length: + * return string[0:length] + */ + +static PyObject *__pyx_pw_7sklearn_5earth_5_util_11str_pad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_str_pad(PyObject *__pyx_v_string, PyObject *__pyx_v_length, CYTHON_UNUSED int __pyx_skip_dispatch) { + PyObject *__pyx_v_pad = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("str_pad", 0); + + /* "sklearn/earth/_util.pyx":43 + * + * cpdef str_pad(string, length): + * if len(string) >= length: # <<<<<<<<<<<<<< + * return string[0:length] + * pad = length - len(string) + */ + __pyx_t_1 = PyObject_Length(__pyx_v_string); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_v_length, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_4) { + + /* "sklearn/earth/_util.pyx":44 + * cpdef str_pad(string, length): + * if len(string) >= length: + * return string[0:length] # <<<<<<<<<<<<<< + * pad = length - len(string) + * return string + ' ' * pad + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_string, 0, 0, NULL, &__pyx_v_length, NULL, 1, 0, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "sklearn/earth/_util.pyx":45 + * if len(string) >= length: + * return string[0:length] + * pad = length - len(string) # <<<<<<<<<<<<<< + * return string + ' ' * pad + * + */ + __pyx_t_1 = PyObject_Length(__pyx_v_string); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyNumber_Subtract(__pyx_v_length, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_pad = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":46 + * return string[0:length] + * pad = length - len(string) + * return string + ' ' * pad # <<<<<<<<<<<<<< + * + * cpdef ascii_table(header, data): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyNumber_Multiply(((PyObject *)__pyx_kp_s_1), __pyx_v_pad); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_3 = PyNumber_Add(__pyx_v_string, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("sklearn.earth._util.str_pad", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_pad); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_11str_pad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_11str_pad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_string = 0; + PyObject *__pyx_v_length = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("str_pad (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__string,&__pyx_n_s__length,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__string)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__length)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("str_pad", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "str_pad") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_string = values[0]; + __pyx_v_length = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("str_pad", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._util.str_pad", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_5_util_10str_pad(__pyx_self, __pyx_v_string, __pyx_v_length); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":42 + * return 1.0 / ((1 - ((basis_size + penalty * (basis_size - 1)) / data_size)) ** 2) + * + * cpdef str_pad(string, length): # <<<<<<<<<<<<<< + * if len(string) >= length: + * return string[0:length] + */ + +static PyObject *__pyx_pf_7sklearn_5earth_5_util_10str_pad(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_string, PyObject *__pyx_v_length) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("str_pad", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_7sklearn_5earth_5_util_str_pad(__pyx_v_string, __pyx_v_length, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._util.str_pad", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":48 + * return string + ' ' * pad + * + * cpdef ascii_table(header, data): # <<<<<<<<<<<<<< + * ''' + * header - list of strings representing the header row + */ + +static PyObject *__pyx_pw_7sklearn_5earth_5_util_13ascii_table(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7sklearn_5earth_5_util_ascii_table(PyObject *__pyx_v_header, PyObject *__pyx_v_data, CYTHON_UNUSED int __pyx_skip_dispatch) { + CYTHON_UNUSED PyObject *__pyx_v_m = NULL; + PyObject *__pyx_v_n = NULL; + PyObject *__pyx_v_column_widths = NULL; + CYTHON_UNUSED PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_row = NULL; + PyObject *__pyx_v_j = NULL; + PyObject *__pyx_v_col = NULL; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_col_width = NULL; + PyObject *__pyx_v_head = NULL; + PyObject *__pyx_v_item = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + Py_ssize_t __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + int __pyx_t_13; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("ascii_table", 0); + + /* "sklearn/earth/_util.pyx":53 + * data - list of lists of strings representing data rows + * ''' + * m = len(data) # <<<<<<<<<<<<<< + * n = len(header) + * column_widths = [len(head) for head in header] + */ + __pyx_t_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_m = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":54 + * ''' + * m = len(data) + * n = len(header) # <<<<<<<<<<<<<< + * column_widths = [len(head) for head in header] + * for i, row in enumerate(data): + */ + __pyx_t_1 = PyObject_Length(__pyx_v_header); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_n = __pyx_t_2; + __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":55 + * m = len(data) + * n = len(header) + * column_widths = [len(head) for head in header] # <<<<<<<<<<<<<< + * for i, row in enumerate(data): + * for j, col in enumerate(row): + */ + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyList_CheckExact(__pyx_v_header) || PyTuple_CheckExact(__pyx_v_header)) { + __pyx_t_3 = __pyx_v_header; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; + } + for (;;) { + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_3); + if (unlikely(!__pyx_t_5)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_head, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_6 = PyObject_Length(__pyx_v_head); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_column_widths = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":56 + * n = len(header) + * column_widths = [len(head) for head in header] + * for i, row in enumerate(data): # <<<<<<<<<<<<<< + * for j, col in enumerate(row): + * if len(col) > column_widths[j]: + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + if (PyList_CheckExact(__pyx_v_data) || PyTuple_CheckExact(__pyx_v_data)) { + __pyx_t_3 = __pyx_v_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; + } + for (;;) { + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_3); + if (unlikely(!__pyx_t_5)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_INCREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); + __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); + __pyx_t_2 = __pyx_t_5; + __pyx_t_5 = 0; + + /* "sklearn/earth/_util.pyx":57 + * column_widths = [len(head) for head in header] + * for i, row in enumerate(data): + * for j, col in enumerate(row): # <<<<<<<<<<<<<< + * if len(col) > column_widths[j]: + * column_widths[j] = len(col) + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_5 = __pyx_int_0; + if (PyList_CheckExact(__pyx_v_row) || PyTuple_CheckExact(__pyx_v_row)) { + __pyx_t_7 = __pyx_v_row; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_row); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + } + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_7)) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_7)) { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_9 = __pyx_t_8(__pyx_t_7); + if (unlikely(!__pyx_t_9)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_XDECREF_SET(__pyx_v_col, __pyx_t_9); + __pyx_t_9 = 0; + __Pyx_INCREF(__pyx_t_5); + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_5); + __pyx_t_9 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_5); + __pyx_t_5 = __pyx_t_9; + __pyx_t_9 = 0; + + /* "sklearn/earth/_util.pyx":58 + * for i, row in enumerate(data): + * for j, col in enumerate(row): + * if len(col) > column_widths[j]: # <<<<<<<<<<<<<< + * column_widths[j] = len(col) + * + */ + __pyx_t_10 = PyObject_Length(__pyx_v_col); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_column_widths), __pyx_v_j); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_12 = PyObject_RichCompare(__pyx_t_9, __pyx_t_11, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (__pyx_t_13) { + + /* "sklearn/earth/_util.pyx":59 + * for j, col in enumerate(row): + * if len(col) > column_widths[j]: + * column_widths[j] = len(col) # <<<<<<<<<<<<<< + * + * for j in range(n): + */ + __pyx_t_10 = PyObject_Length(__pyx_v_col); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (PyObject_SetItem(((PyObject *)__pyx_v_column_widths), __pyx_v_j, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + goto __pyx_L9; + } + __pyx_L9:; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":61 + * column_widths[j] = len(col) + * + * for j in range(n): # <<<<<<<<<<<<<< + * column_widths[j] += 1 + * + */ + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_n); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n); + __Pyx_GIVEREF(__pyx_v_n); + __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { + __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (;;) { + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_3 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_3)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_3); + __pyx_t_3 = 0; + + /* "sklearn/earth/_util.pyx":62 + * + * for j in range(n): + * column_widths[j] += 1 # <<<<<<<<<<<<<< + * + * result = '' + */ + __Pyx_INCREF(__pyx_v_j); + __pyx_t_3 = __pyx_v_j; + __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_column_widths), __pyx_t_3); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (PyObject_SetItem(((PyObject *)__pyx_v_column_widths), __pyx_t_3, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":64 + * column_widths[j] += 1 + * + * result = '' # <<<<<<<<<<<<<< + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' + */ + __Pyx_INCREF(((PyObject *)__pyx_kp_s_2)); + __pyx_v_result = ((PyObject *)__pyx_kp_s_2); + + /* "sklearn/earth/_util.pyx":65 + * + * result = '' + * for j, col_width in enumerate(column_widths): # <<<<<<<<<<<<<< + * result += '-' * col_width + '-' + * result += '\n' + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + __pyx_t_3 = ((PyObject *)__pyx_v_column_widths); __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + for (;;) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_col_width, __pyx_t_7); + __pyx_t_7 = 0; + __Pyx_INCREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_2); + __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_2); + __pyx_t_2 = __pyx_t_7; + __pyx_t_7 = 0; + + /* "sklearn/earth/_util.pyx":66 + * result = '' + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' # <<<<<<<<<<<<<< + * result += '\n' + * for j, head in enumerate(header): + */ + __pyx_t_7 = PyNumber_Multiply(((PyObject *)__pyx_kp_s_3), __pyx_v_col_width); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_7)); + __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_7), ((PyObject *)__pyx_kp_s_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_7); + __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":67 + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' + * result += '\n' # <<<<<<<<<<<<<< + * for j, head in enumerate(header): + * result += str_pad(head, column_widths[j]) + ' ' + */ + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":68 + * result += '-' * col_width + '-' + * result += '\n' + * for j, head in enumerate(header): # <<<<<<<<<<<<<< + * result += str_pad(head, column_widths[j]) + ' ' + * result += '\n' + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + if (PyList_CheckExact(__pyx_v_header) || PyTuple_CheckExact(__pyx_v_header)) { + __pyx_t_3 = __pyx_v_header; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; + } + for (;;) { + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_7 = __pyx_t_4(__pyx_t_3); + if (unlikely(!__pyx_t_7)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_7); + } + __Pyx_XDECREF_SET(__pyx_v_head, __pyx_t_7); + __pyx_t_7 = 0; + __Pyx_INCREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_2); + __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_2); + __pyx_t_2 = __pyx_t_7; + __pyx_t_7 = 0; + + /* "sklearn/earth/_util.pyx":69 + * result += '\n' + * for j, head in enumerate(header): + * result += str_pad(head, column_widths[j]) + ' ' # <<<<<<<<<<<<<< + * result += '\n' + * for j, col_width in enumerate(column_widths): + */ + __pyx_t_7 = PyObject_GetItem(((PyObject *)__pyx_v_column_widths), __pyx_v_j); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = __pyx_f_7sklearn_5earth_5_util_str_pad(__pyx_v_head, __pyx_t_7, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_5); + __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":70 + * for j, head in enumerate(header): + * result += str_pad(head, column_widths[j]) + ' ' + * result += '\n' # <<<<<<<<<<<<<< + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' + */ + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":71 + * result += str_pad(head, column_widths[j]) + ' ' + * result += '\n' + * for j, col_width in enumerate(column_widths): # <<<<<<<<<<<<<< + * result += '-' * col_width + '-' + * for i, row in enumerate(data): + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + __pyx_t_3 = ((PyObject *)__pyx_v_column_widths); __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + for (;;) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_col_width, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_INCREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_2); + __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); + __pyx_t_2 = __pyx_t_5; + __pyx_t_5 = 0; + + /* "sklearn/earth/_util.pyx":72 + * result += '\n' + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' # <<<<<<<<<<<<<< + * for i, row in enumerate(data): + * result += '\n' + */ + __pyx_t_5 = PyNumber_Multiply(((PyObject *)__pyx_kp_s_3), __pyx_v_col_width); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_t_5), ((PyObject *)__pyx_kp_s_3)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_7)); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_5); + __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":73 + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' + * for i, row in enumerate(data): # <<<<<<<<<<<<<< + * result += '\n' + * for j, item in enumerate(row): + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + if (PyList_CheckExact(__pyx_v_data) || PyTuple_CheckExact(__pyx_v_data)) { + __pyx_t_3 = __pyx_v_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; + } + for (;;) { + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_3); + if (unlikely(!__pyx_t_5)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_INCREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); + __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); + __pyx_t_2 = __pyx_t_5; + __pyx_t_5 = 0; + + /* "sklearn/earth/_util.pyx":74 + * result += '-' * col_width + '-' + * for i, row in enumerate(data): + * result += '\n' # <<<<<<<<<<<<<< + * for j, item in enumerate(row): + * result += str_pad(item, column_widths[j]) + ' ' + */ + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_5); + __pyx_t_5 = 0; + + /* "sklearn/earth/_util.pyx":75 + * for i, row in enumerate(data): + * result += '\n' + * for j, item in enumerate(row): # <<<<<<<<<<<<<< + * result += str_pad(item, column_widths[j]) + ' ' + * result += '\n' + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_5 = __pyx_int_0; + if (PyList_CheckExact(__pyx_v_row) || PyTuple_CheckExact(__pyx_v_row)) { + __pyx_t_7 = __pyx_v_row; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_row); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + } + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_7)) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_12 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_12); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_12 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_7)) { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_12); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_12 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + __pyx_t_12 = __pyx_t_8(__pyx_t_7); + if (unlikely(!__pyx_t_12)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_12); + } + __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_12); + __pyx_t_12 = 0; + __Pyx_INCREF(__pyx_t_5); + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_5); + __pyx_t_12 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_5); + __pyx_t_5 = __pyx_t_12; + __pyx_t_12 = 0; + + /* "sklearn/earth/_util.pyx":76 + * result += '\n' + * for j, item in enumerate(row): + * result += str_pad(item, column_widths[j]) + ' ' # <<<<<<<<<<<<<< + * result += '\n' + * for j, col_width in enumerate(column_widths): + */ + __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_column_widths), __pyx_v_j); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_11 = __pyx_f_7sklearn_5earth_5_util_str_pad(__pyx_v_item, __pyx_t_12, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyNumber_Add(__pyx_t_11, ((PyObject *)__pyx_kp_s_1)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_11); + __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":77 + * for j, item in enumerate(row): + * result += str_pad(item, column_widths[j]) + ' ' + * result += '\n' # <<<<<<<<<<<<<< + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' + */ + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_2); + __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":78 + * result += str_pad(item, column_widths[j]) + ' ' + * result += '\n' + * for j, col_width in enumerate(column_widths): # <<<<<<<<<<<<<< + * result += '-' * col_width + '-' + * return result + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + __pyx_t_3 = ((PyObject *)__pyx_v_column_widths); __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + for (;;) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_col_width, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_INCREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_2); + __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); + __pyx_t_2 = __pyx_t_5; + __pyx_t_5 = 0; + + /* "sklearn/earth/_util.pyx":79 + * result += '\n' + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' # <<<<<<<<<<<<<< + * return result + */ + __pyx_t_5 = PyNumber_Multiply(((PyObject *)__pyx_kp_s_3), __pyx_v_col_width); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_t_5), ((PyObject *)__pyx_kp_s_3)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_7)); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_result, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_5); + __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/earth/_util.pyx":80 + * for j, col_width in enumerate(column_widths): + * result += '-' * col_width + '-' + * return result # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_AddTraceback("sklearn.earth._util.ascii_table", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_m); + __Pyx_XDECREF(__pyx_v_n); + __Pyx_XDECREF(__pyx_v_column_widths); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_row); + __Pyx_XDECREF(__pyx_v_j); + __Pyx_XDECREF(__pyx_v_col); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_col_width); + __Pyx_XDECREF(__pyx_v_head); + __Pyx_XDECREF(__pyx_v_item); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_5earth_5_util_13ascii_table(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_5earth_5_util_12ascii_table[] = "\n header - list of strings representing the header row\n data - list of lists of strings representing data rows\n "; +static PyObject *__pyx_pw_7sklearn_5earth_5_util_13ascii_table(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_header = 0; + PyObject *__pyx_v_data = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("ascii_table (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__header,&__pyx_n_s__data,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__header)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("ascii_table", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ascii_table") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_header = values[0]; + __pyx_v_data = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("ascii_table", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.earth._util.ascii_table", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_7sklearn_5earth_5_util_12ascii_table(__pyx_self, __pyx_v_header, __pyx_v_data); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/earth/_util.pyx":48 + * return string + ' ' * pad + * + * cpdef ascii_table(header, data): # <<<<<<<<<<<<<< + * ''' + * header - list of strings representing the header row + */ + +static PyObject *__pyx_pf_7sklearn_5earth_5_util_12ascii_table(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_header, PyObject *__pyx_v_data) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("ascii_table", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_7sklearn_5earth_5_util_ascii_table(__pyx_v_header, __pyx_v_data, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.earth._util.ascii_table", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":194 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "numpy.pxd":200 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":203 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":204 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":206 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "numpy.pxd":208 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":209 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + goto __pyx_L4; + } + /*else*/ { + + /* "numpy.pxd":211 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "numpy.pxd":213 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":214 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "numpy.pxd":217 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_3) { + + /* "numpy.pxd":218 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_2 = __pyx_t_1; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (__pyx_t_2) { + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "numpy.pxd":221 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "numpy.pxd":222 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "numpy.pxd":223 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_2 = (__pyx_v_copy_shape != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":226 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "numpy.pxd":227 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "numpy.pxd":228 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_5 = __pyx_v_ndim; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "numpy.pxd":229 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "numpy.pxd":230 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + goto __pyx_L7; + } + /*else*/ { + + /* "numpy.pxd":232 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "numpy.pxd":233 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L7:; + + /* "numpy.pxd":234 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "numpy.pxd":235 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "numpy.pxd":236 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "numpy.pxd":239 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef list stack + */ + __pyx_v_f = NULL; + + /* "numpy.pxd":240 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef list stack + * cdef int offset + */ + __pyx_t_4 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_4); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":244 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "numpy.pxd":246 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_3; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":248 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + goto __pyx_L10; + } + /*else*/ { + + /* "numpy.pxd":251 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L10:; + + /* "numpy.pxd":253 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":254 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_5 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_5; + + /* "numpy.pxd":255 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_2 = __pyx_t_1; + } + if (!__pyx_t_2) { + + /* "numpy.pxd":256 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_1) { + __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_7 = __pyx_t_3; + } else { + __pyx_t_7 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_7; + } else { + __pyx_t_1 = __pyx_t_2; + } + if (__pyx_t_1) { + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + switch (__pyx_v_t) { + + /* "numpy.pxd":258 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + case NPY_BYTE: + __pyx_v_f = __pyx_k__b; + break; + + /* "numpy.pxd":259 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = __pyx_k__B; + break; + + /* "numpy.pxd":260 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = __pyx_k__h; + break; + + /* "numpy.pxd":261 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = __pyx_k__H; + break; + + /* "numpy.pxd":262 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = __pyx_k__i; + break; + + /* "numpy.pxd":263 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = __pyx_k__I; + break; + + /* "numpy.pxd":264 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = __pyx_k__l; + break; + + /* "numpy.pxd":265 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = __pyx_k__L; + break; + + /* "numpy.pxd":266 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = __pyx_k__q; + break; + + /* "numpy.pxd":267 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = __pyx_k__Q; + break; + + /* "numpy.pxd":268 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = __pyx_k__f; + break; + + /* "numpy.pxd":269 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = __pyx_k__d; + break; + + /* "numpy.pxd":270 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = __pyx_k__g; + break; + + /* "numpy.pxd":271 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = __pyx_k__Zf; + break; + + /* "numpy.pxd":272 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = __pyx_k__Zd; + break; + + /* "numpy.pxd":273 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = __pyx_k__Zg; + break; + + /* "numpy.pxd":274 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = __pyx_k__O; + break; + default: + + /* "numpy.pxd":276 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_11), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + + /* "numpy.pxd":277 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "numpy.pxd":278 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":280 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + __pyx_v_info->format = ((char *)malloc(255)); + + /* "numpy.pxd":281 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "numpy.pxd":282 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "numpy.pxd":285 + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + * &offset) # <<<<<<<<<<<<<< + * f[0] = c'\0' # Terminate format string + * + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_9; + + /* "numpy.pxd":286 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + __pyx_L11:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":288 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "numpy.pxd":289 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":290 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + goto __pyx_L3; + } + __pyx_L3:; + + /* "numpy.pxd":291 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":292 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + goto __pyx_L4; + } + __pyx_L4:; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":768 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "numpy.pxd":769 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":771 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "numpy.pxd":772 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":774 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "numpy.pxd":775 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":777 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "numpy.pxd":778 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":780 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "numpy.pxd":781 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":783 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + char *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "numpy.pxd":790 + * cdef int delta_offset + * cdef tuple i + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "numpy.pxd":791 + * cdef tuple i + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "numpy.pxd":794 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":795 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "numpy.pxd":796 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) { + PyObject* sequence = ((PyObject *)__pyx_v_fields); + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + } else if (1) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else + { + Py_ssize_t index = -1; + __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "numpy.pxd":798 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "numpy.pxd":801 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (__pyx_t_7) { + __pyx_t_8 = (__pyx_v_little_endian != 0); + } else { + __pyx_t_8 = __pyx_t_7; + } + if (!__pyx_t_8) { + + /* "numpy.pxd":802 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + __pyx_t_9 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_10 = __pyx_t_9; + } else { + __pyx_t_10 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_10; + } else { + __pyx_t_7 = __pyx_t_8; + } + if (__pyx_t_7) { + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "numpy.pxd":813 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!__pyx_t_7) break; + + /* "numpy.pxd":814 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 120; + + /* "numpy.pxd":815 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "numpy.pxd":816 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1); + } + + /* "numpy.pxd":818 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_11 = 0; + (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize); + + /* "numpy.pxd":820 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_7 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":821 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3); + __pyx_t_3 = 0; + + /* "numpy.pxd":822 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_7 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_7) { + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_16), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + /* "numpy.pxd":826 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 98; + goto __pyx_L13; + } + + /* "numpy.pxd":827 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 66; + goto __pyx_L13; + } + + /* "numpy.pxd":828 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 104; + goto __pyx_L13; + } + + /* "numpy.pxd":829 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 72; + goto __pyx_L13; + } + + /* "numpy.pxd":830 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 105; + goto __pyx_L13; + } + + /* "numpy.pxd":831 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 73; + goto __pyx_L13; + } + + /* "numpy.pxd":832 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 108; + goto __pyx_L13; + } + + /* "numpy.pxd":833 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 76; + goto __pyx_L13; + } + + /* "numpy.pxd":834 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 113; + goto __pyx_L13; + } + + /* "numpy.pxd":835 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 81; + goto __pyx_L13; + } + + /* "numpy.pxd":836 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 102; + goto __pyx_L13; + } + + /* "numpy.pxd":837 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 100; + goto __pyx_L13; + } + + /* "numpy.pxd":838 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 103; + goto __pyx_L13; + } + + /* "numpy.pxd":839 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 102; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":840 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 100; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":841 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 103; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + + /* "numpy.pxd":842 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_7) { + (__pyx_v_f[0]) = 79; + goto __pyx_L13; + } + /*else*/ { + + /* "numpy.pxd":844 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_11), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L13:; + + /* "numpy.pxd":845 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L11; + } + /*else*/ { + + /* "numpy.pxd":849 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_12; + } + __pyx_L11:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "numpy.pxd":850 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "numpy.pxd":965 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "numpy.pxd":967 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "numpy.pxd":968 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":970 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + Py_INCREF(__pyx_v_base); + + /* "numpy.pxd":971 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "numpy.pxd":972 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "numpy.pxd":973 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + __Pyx_RefNannyFinishContext(); +} + +/* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "numpy.pxd":976 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "numpy.pxd":977 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + /*else*/ { + + /* "numpy.pxd":979 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + __pyx_L3:; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyMethodDef __pyx_methods[] = { + {__Pyx_NAMESTR("apply_weights_2d"), (PyCFunction)__pyx_pw_7sklearn_5earth_5_util_1apply_weights_2d, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("apply_weights_slice"), (PyCFunction)__pyx_pw_7sklearn_5earth_5_util_3apply_weights_slice, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("apply_weights_1d"), (PyCFunction)__pyx_pw_7sklearn_5earth_5_util_5apply_weights_1d, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("gcv"), (PyCFunction)__pyx_pw_7sklearn_5earth_5_util_7gcv, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("gcv_adjust"), (PyCFunction)__pyx_pw_7sklearn_5earth_5_util_9gcv_adjust, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("str_pad"), (PyCFunction)__pyx_pw_7sklearn_5earth_5_util_11str_pad, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("ascii_table"), (PyCFunction)__pyx_pw_7sklearn_5earth_5_util_13ascii_table, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_5earth_5_util_12ascii_table)}, + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + __Pyx_NAMESTR("_util"), + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, + {&__pyx_kp_u_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 1, 0, 0}, + {&__pyx_kp_u_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 1, 0, 0}, + {&__pyx_kp_u_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 1, 0, 0}, + {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0}, + {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, + {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, + {&__pyx_kp_u_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 1, 0, 0}, + {&__pyx_kp_u_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0, 0}, + {&__pyx_kp_u_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 1, 0, 0}, + {&__pyx_n_s__B, __pyx_k__B, sizeof(__pyx_k__B), 0, 0, 1, 1}, + {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, + {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, + {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_getbuffer, __pyx_k____pyx_getbuffer, sizeof(__pyx_k____pyx_getbuffer), 0, 0, 1, 1}, + {&__pyx_n_s____pyx_releasebuffer, __pyx_k____pyx_releasebuffer, sizeof(__pyx_k____pyx_releasebuffer), 0, 0, 1, 1}, + {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s__basis_size, __pyx_k__basis_size, sizeof(__pyx_k__basis_size), 0, 0, 1, 1}, + {&__pyx_n_s__column, __pyx_k__column, sizeof(__pyx_k__column), 0, 0, 1, 1}, + {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1}, + {&__pyx_n_s__data_size, __pyx_k__data_size, sizeof(__pyx_k__data_size), 0, 0, 1, 1}, + {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1}, + {&__pyx_n_s__header, __pyx_k__header, sizeof(__pyx_k__header), 0, 0, 1, 1}, + {&__pyx_n_s__length, __pyx_k__length, sizeof(__pyx_k__length), 0, 0, 1, 1}, + {&__pyx_n_s__mse, __pyx_k__mse, sizeof(__pyx_k__mse), 0, 0, 1, 1}, + {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, + {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, + {&__pyx_n_s__penalty, __pyx_k__penalty, sizeof(__pyx_k__penalty), 0, 0, 1, 1}, + {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, + {&__pyx_n_s__string, __pyx_k__string, sizeof(__pyx_k__string), 0, 0, 1, 1}, + {&__pyx_n_s__weights, __pyx_k__weights, sizeof(__pyx_k__weights), 0, 0, 1, 1}, + {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "numpy.pxd":215 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_k_tuple_6 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_5)); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_6); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); + + /* "numpy.pxd":219 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_k_tuple_8 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_7)); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_8); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8)); + + /* "numpy.pxd":257 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_k_tuple_10 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_9)); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_10); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); + + /* "numpy.pxd":799 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_k_tuple_13 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_12)); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_13); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); + + /* "numpy.pxd":803 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_k_tuple_14 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_9)); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_14); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); + + /* "numpy.pxd":823 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_k_tuple_16 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_u_15)); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_16); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16)); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_util(void); /*proto*/ +PyMODINIT_FUNC init_util(void) +#else +PyMODINIT_FUNC PyInit__util(void); /*proto*/ +PyMODINIT_FUNC PyInit__util(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__util(void)", 0); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __Pyx_CyFunction_USED + if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_util"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_d); + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "sklearn.earth._util")) { + if (unlikely(PyDict_SetItemString(modules, "sklearn.earth._util", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + } + #endif + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + /*--- Initialize various global constants etc. ---*/ + if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if (__pyx_module_is_main_sklearn__earth___util) { + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + /*--- Builtin init code ---*/ + if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Constants init code ---*/ + if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + if (__Pyx_ExportFunction("log2", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_log2, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_FLOAT_t)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ExportFunction("apply_weights_2d", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_apply_weights_2d, "PyObject *(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ExportFunction("apply_weights_slice", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_apply_weights_slice, "PyObject *(PyArrayObject *, PyArrayObject *, __pyx_t_7sklearn_5earth_5_util_INDEX_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ExportFunction("apply_weights_1d", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_apply_weights_1d, "PyObject *(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ExportFunction("gcv", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_gcv, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_FLOAT_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ExportFunction("gcv_adjust", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_gcv_adjust, "__pyx_t_7sklearn_5earth_5_util_FLOAT_t (__pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_INDEX_t, __pyx_t_7sklearn_5earth_5_util_FLOAT_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ExportFunction("str_pad", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_str_pad, "PyObject *(PyObject *, PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_ExportFunction("ascii_table", (void (*)(void))__pyx_f_7sklearn_5earth_5_util_ascii_table, "PyObject *(PyObject *, PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Type init code ---*/ + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + + /* "sklearn/earth/_util.pyx":7 + * # cython: profile = False + * + * import numpy as np # <<<<<<<<<<<<<< + * from libc.math cimport sqrt, log + * + */ + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "sklearn/earth/_util.pyx":1 + * # distutils: language = c # <<<<<<<<<<<<<< + * # cython: cdivision = True + * # cython: boundscheck = False + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + + /* "numpy.pxd":975 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + if (__pyx_m) { + __Pyx_AddTraceback("init sklearn.earth._util", __pyx_clineno, __pyx_lineno, __pyx_filename); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init sklearn.earth._util"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* Runtime support code */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif /* CYTHON_REFNANNY */ + +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) /* First char was not a digit */ + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; /* Consume from buffer string */ + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; /* breaks both loops as ctx->enc_count == 0 */ + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; /* empty struct */ + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + if (isspace(*ts)) + continue; + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case 10: + case 13: + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': /* substruct */ + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': /* end of substruct; either repeat or move on */ + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; /* Erase processed last struct element */ + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } /* fall through */ + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 's': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + } else { + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + } + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%s() got an unexpected keyword argument '%s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( + PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, + int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { +#if CYTHON_COMPILING_IN_CPYTHON + PyMappingMethods* mp; +#if PY_MAJOR_VERSION < 3 + PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; + if (likely(ms && ms->sq_slice)) { + if (!has_cstart) { + if (_py_start && (*_py_start != Py_None)) { + cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); + if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstart = 0; + } + if (!has_cstop) { + if (_py_stop && (*_py_stop != Py_None)) { + cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); + if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstop = PY_SSIZE_T_MAX; + } + if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { + Py_ssize_t l = ms->sq_length(obj); + if (likely(l >= 0)) { + if (cstop < 0) { + cstop += l; + if (cstop < 0) cstop = 0; + } + if (cstart < 0) { + cstart += l; + if (cstart < 0) cstart = 0; + } + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + goto bad; + } + } + return ms->sq_slice(obj, cstart, cstop); + } +#endif + mp = Py_TYPE(obj)->tp_as_mapping; + if (likely(mp && mp->mp_subscript)) +#endif + { + PyObject* result; + PyObject *py_slice, *py_start, *py_stop; + if (_py_slice) { + py_slice = *_py_slice; + } else { + PyObject* owned_start = NULL; + PyObject* owned_stop = NULL; + if (_py_start) { + py_start = *_py_start; + } else { + if (has_cstart) { + owned_start = py_start = PyInt_FromSsize_t(cstart); + if (unlikely(!py_start)) goto bad; + } else + py_start = Py_None; + } + if (_py_stop) { + py_stop = *_py_stop; + } else { + if (has_cstop) { + owned_stop = py_stop = PyInt_FromSsize_t(cstop); + if (unlikely(!py_stop)) { + Py_XDECREF(owned_start); + goto bad; + } + } else + py_stop = Py_None; + } + py_slice = PySlice_New(py_start, py_stop, Py_None); + Py_XDECREF(owned_start); + Py_XDECREF(owned_stop); + if (unlikely(!py_slice)) goto bad; + } +#if CYTHON_COMPILING_IN_CPYTHON + result = mp->mp_subscript(obj, py_slice); +#else + result = PyObject_GetItem(obj, py_slice); +#endif + if (!_py_slice) { + Py_DECREF(py_slice); + } + return result; + } + PyErr_Format(PyExc_TypeError, + "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); +bad: + return NULL; +} + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + #if PY_VERSION_HEX < 0x02050000 + if (PyClass_Check(type)) { + #else + if (PyType_Check(type)) { + #endif +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + #if PY_VERSION_HEX < 0x02050000 + if (PyInstance_Check(type)) { + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + Py_INCREF(type); + } else { + type = 0; + PyErr_SetString(PyExc_TypeError, + "raise: exception must be an old-style class or instance"); + goto raise_error; + } + #else + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + #endif + } + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else /* Python 3+ */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + index, (index == 1) ? "" : "s"); +} + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *getbuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_getbuffer); + if (getbuffer_cobj) { + getbufferproc func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj); + Py_DECREF(getbuffer_cobj); + if (!func) + goto fail; + return func(obj, view, flags); + } else { + PyErr_Clear(); + } + } + #endif + PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } + #if PY_VERSION_HEX < 0x02060000 + if (obj->ob_type->tp_dict) { + PyObject *releasebuffer_cobj = PyObject_GetItem( + obj->ob_type->tp_dict, __pyx_n_s____pyx_releasebuffer); + if (releasebuffer_cobj) { + releasebufferproc func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj); + Py_DECREF(releasebuffer_cobj); + if (!func) + goto fail; + func(obj, view); + return; + } else { + PyErr_Clear(); + } + } + #endif + goto nofail; +#if PY_VERSION_HEX < 0x02060000 +fail: +#endif + PyErr_WriteUnraisable(obj); +nofail: + Py_DECREF(obj); + view->obj = NULL; +} +#endif /* PY_MAJOR_VERSION < 3 */ + + + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + #if PY_VERSION_HEX >= 0x02050000 + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; /* try absolute import on failure */ + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } + #else + if (level>0) { + PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); + goto bad; + } + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, NULL); + #endif +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +static CYTHON_INLINE npy_ulonglong __Pyx_PyInt_from_py_npy_ulonglong(PyObject* x) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if (sizeof(npy_ulonglong) == sizeof(char)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedChar(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedChar(x); + } else if (sizeof(npy_ulonglong) == sizeof(short)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedShort(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedShort(x); + } else if (sizeof(npy_ulonglong) == sizeof(int)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedInt(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedInt(x); + } else if (sizeof(npy_ulonglong) == sizeof(long)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLong(x); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return (npy_ulonglong)__Pyx_PyInt_AsUnsignedLongLong(x); + else + return (npy_ulonglong)__Pyx_PyInt_AsSignedLongLong(x); + } else { + #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); + #else + npy_ulonglong val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } + #endif + return (npy_ulonglong)-1; + } +} + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_ulonglong(npy_ulonglong val) { + const npy_ulonglong neg_one = (npy_ulonglong)-1, const_zero = (npy_ulonglong)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(npy_ulonglong) == sizeof(char)) || + (sizeof(npy_ulonglong) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(npy_ulonglong) == sizeof(int)) || + (sizeof(npy_ulonglong) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(npy_ulonglong) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); + else + return PyLong_FromLongLong((PY_LONG_LONG)val); + } else { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + return _PyLong_FromByteArray(bytes, sizeof(npy_ulonglong), + little, !is_unsigned); + } +} + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { + const unsigned char neg_one = (unsigned char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned char" : + "value too large to convert to unsigned char"); + } + return (unsigned char)-1; + } + return (unsigned char)val; + } + return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { + const unsigned short neg_one = (unsigned short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned short" : + "value too large to convert to unsigned short"); + } + return (unsigned short)-1; + } + return (unsigned short)val; + } + return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { + const unsigned int neg_one = (unsigned int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(unsigned int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(unsigned int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to unsigned int" : + "value too large to convert to unsigned int"); + } + return (unsigned int)-1; + } + return (unsigned int)val; + } + return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); +} + +static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { + const char neg_one = (char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to char" : + "value too large to convert to char"); + } + return (char)-1; + } + return (char)val; + } + return (char)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { + const short neg_one = (short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to short" : + "value too large to convert to short"); + } + return (short)-1; + } + return (short)val; + } + return (short)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { + const signed char neg_one = (signed char)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed char) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed char)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed char" : + "value too large to convert to signed char"); + } + return (signed char)-1; + } + return (signed char)val; + } + return (signed char)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { + const signed short neg_one = (signed short)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed short) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed short)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed short" : + "value too large to convert to signed short"); + } + return (signed short)-1; + } + return (signed short)val; + } + return (signed short)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { + const signed int neg_one = (signed int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(signed int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(signed int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to signed int" : + "value too large to convert to signed int"); + } + return (signed int)-1; + } + return (signed int)val; + } + return (signed int)__Pyx_PyInt_AsSignedLong(x); +} + +static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { + const int neg_one = (int)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (sizeof(int) < sizeof(long)) { + long val = __Pyx_PyInt_AsLong(x); + if (unlikely(val != (long)(int)val)) { + if (!unlikely(val == -1 && PyErr_Occurred())) { + PyErr_SetString(PyExc_OverflowError, + (is_unsigned && unlikely(val < 0)) ? + "can't convert negative value to int" : + "value too large to convert to int"); + } + return (int)-1; + } + return (int)val; + } + return (int)__Pyx_PyInt_AsLong(x); +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { + const unsigned long neg_one = (unsigned long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long)-1; + } + return (unsigned long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned long)PyLong_AsLong(x); + } + } else { + unsigned long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned long)-1; + val = __Pyx_PyInt_AsUnsignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { + const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned PY_LONG_LONG"); + return (unsigned PY_LONG_LONG)-1; + } + return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + unsigned PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (unsigned PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsUnsignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { + const long neg_one = (long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long)-1; + } + return (long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (long)PyLong_AsLong(x); + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (long)-1; + val = __Pyx_PyInt_AsLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { + const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to PY_LONG_LONG"); + return (PY_LONG_LONG)-1; + } + return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { + const signed long neg_one = (signed long)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed long"); + return (signed long)-1; + } + return (signed long)PyLong_AsUnsignedLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed long)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed long)PyLong_AsLong(x); + } + } else { + signed long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed long)-1; + val = __Pyx_PyInt_AsSignedLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS +#include "longintrepr.h" +#endif +#endif +static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { + const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)val; + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to signed PY_LONG_LONG"); + return (signed PY_LONG_LONG)-1; + } + return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +#if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + } + } +#endif +#endif + return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + } + } else { + signed PY_LONG_LONG val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (signed PY_LONG_LONG)-1; + val = __Pyx_PyInt_AsSignedLongLong(tmp); + Py_DECREF(tmp); + return val; + } +} + +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + #if PY_VERSION_HEX < 0x02050000 + return PyErr_Warn(NULL, message); + #else + return PyErr_WarnEx(NULL, message, 1); + #endif + } + return 0; +} + +static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__"); + if (!d) { + PyErr_Clear(); + d = PyDict_New(); + if (!d) + goto bad; + Py_INCREF(d); + if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0) + goto bad; + } + tmp.fp = f; +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + cobj = PyCapsule_New(tmp.p, sig, 0); +#else + cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0); +#endif + if (!cobj) + goto bad; + if (PyDict_SetItemString(d, name, cobj) < 0) + goto bad; + Py_DECREF(cobj); + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(cobj); + Py_XDECREF(d); + return -1; +} + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility", + module_name, class_name); + #if PY_VERSION_HEX < 0x02050000 + if (PyErr_Warn(NULL, warning) < 0) goto bad; + #else + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + #endif + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s has the wrong size, try recompiling", + module_name, class_name); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = (start + end) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, /*int firstlineno,*/ + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_globals = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else /* Python 3+ has unicode identifiers */ + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else /* PY_VERSION_HEX < 0x03030000 */ + if (PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_DATA_SIZE(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ + return PyUnicode_AsUTF8AndSize(o, length); +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ +#endif /* PY_VERSION_HEX < 0x03030000 */ + } else +#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (r < 0) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return Py_INCREF(x), x; + m = Py_TYPE(x)->tp_as_number; +#if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%s__ returned non-%s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject* x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { +#if PY_VERSION_HEX < 0x02050000 + if (ival <= LONG_MAX) + return PyInt_FromLong((long)ival); + else { + unsigned char *bytes = (unsigned char *) &ival; + int one = 1; int little = (int)*(unsigned char*)&one; + return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); + } +#else + return PyInt_FromSize_t(ival); +#endif +} +static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { + unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); + if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t)-1; + } + return (size_t)val; +} + + +#endif /* Py_PYTHON_H */ diff --git a/sklearn/earth/_util.pxd b/sklearn/earth/_util.pxd new file mode 100644 index 0000000000000..547f5e46f6651 --- /dev/null +++ b/sklearn/earth/_util.pxd @@ -0,0 +1,21 @@ +cimport numpy as cnp +ctypedef cnp.float64_t FLOAT_t +ctypedef cnp.intp_t INT_t +ctypedef cnp.ulong_t INDEX_t +ctypedef cnp.uint8_t BOOL_t + +cdef FLOAT_t log2(FLOAT_t x) + +cpdef apply_weights_2d(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights) + +cpdef apply_weights_slice(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights, INDEX_t column) + +cpdef apply_weights_1d(cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights) + +cpdef FLOAT_t gcv(FLOAT_t mse, INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty) + +cpdef FLOAT_t gcv_adjust(INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty) + +cpdef str_pad(string, length) + +cpdef ascii_table(header, data) diff --git a/sklearn/earth/_util.pyx b/sklearn/earth/_util.pyx new file mode 100644 index 0000000000000..974a8ff59637f --- /dev/null +++ b/sklearn/earth/_util.pyx @@ -0,0 +1,80 @@ +# distutils: language = c +# cython: cdivision = True +# cython: boundscheck = False +# cython: wraparound = False +# cython: profile = False + +import numpy as np +from libc.math cimport sqrt, log + +cdef FLOAT_t log2(FLOAT_t x): + return log(x) / log(2.0) + +cpdef apply_weights_2d(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights): + cdef INDEX_t i + cdef INDEX_t j + cdef INDEX_t m = B.shape[0] + cdef INDEX_t n = B.shape[1] + for i in range(m): + for j in range(n): + B[i, j] *= sqrt(weights[i]) + +cpdef apply_weights_slice(cnp.ndarray[FLOAT_t, ndim=2] B, cnp.ndarray[FLOAT_t, ndim=1] weights, INDEX_t column): + cdef INDEX_t i + cdef INDEX_t j + cdef INDEX_t m = B.shape[0] + cdef INDEX_t n = B.shape[1] + for i in range(m): + B[i, column] *= sqrt(weights[i]) + +cpdef apply_weights_1d(cnp.ndarray[FLOAT_t, ndim=1] y, cnp.ndarray[FLOAT_t, ndim=1] weights): + cdef INDEX_t i + cdef INDEX_t m = y.shape[0] + for i in range(m): + y[i] *= sqrt(weights[i]) + +cpdef FLOAT_t gcv(FLOAT_t mse, INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): + return mse * gcv_adjust(basis_size, data_size, penalty) + +cpdef FLOAT_t gcv_adjust(INDEX_t basis_size, INDEX_t data_size, FLOAT_t penalty): + return 1.0 / ((1 - ((basis_size + penalty * (basis_size - 1)) / data_size)) ** 2) + +cpdef str_pad(string, length): + if len(string) >= length: + return string[0:length] + pad = length - len(string) + return string + ' ' * pad + +cpdef ascii_table(header, data): + ''' + header - list of strings representing the header row + data - list of lists of strings representing data rows + ''' + m = len(data) + n = len(header) + column_widths = [len(head) for head in header] + for i, row in enumerate(data): + for j, col in enumerate(row): + if len(col) > column_widths[j]: + column_widths[j] = len(col) + + for j in range(n): + column_widths[j] += 1 + + result = '' + for j, col_width in enumerate(column_widths): + result += '-' * col_width + '-' + result += '\n' + for j, head in enumerate(header): + result += str_pad(head, column_widths[j]) + ' ' + result += '\n' + for j, col_width in enumerate(column_widths): + result += '-' * col_width + '-' + for i, row in enumerate(data): + result += '\n' + for j, item in enumerate(row): + result += str_pad(item, column_widths[j]) + ' ' + result += '\n' + for j, col_width in enumerate(column_widths): + result += '-' * col_width + '-' + return result diff --git a/sklearn/earth/earth.py b/sklearn/earth/earth.py new file mode 100644 index 0000000000000..eda7c172e0941 --- /dev/null +++ b/sklearn/earth/earth.py @@ -0,0 +1,641 @@ +from ._forward import ForwardPasser +from ._pruning import PruningPasser +from ._util import ascii_table, apply_weights_2d, apply_weights_1d +from ..base import RegressorMixin, BaseEstimator, TransformerMixin +from ..utils.validation import assert_all_finite, safe_asarray +import numpy as np +from scipy import sparse + + +class EarthRegressor(BaseEstimator, RegressorMixin, TransformerMixin): + + ''' + Multivariate Adaptive Regression Splines + + A flexible regression method that automatically searches for interactions and non-linear + relationships. EarthRegressor models can be thought of as linear models in a higher dimensional + basis space (specifically, a multivariate truncated power spline basis). Each term in an + EarthRegressor model is a product of so called "hinge functions". A hinge function is a function + that's equal to its argument where that argument is greater than zero and is zero everywhere + else. + + The multivariate adaptive regression splines algorithm has two stages. First, the + forward pass searches for terms in the truncated power spline basis that locally minimize + the squared error loss of the training set. Next, a pruning pass selects a subset of those + terms that produces a locally minimal generalized cross-validation (GCV) score. The GCV + score is not actually based on cross-validation, but rather is meant to approximate a true + cross-validation score by penalizing model complexity. The final result is a set of terms + that is nonlinear in the original feature space, may include interactions, and is likely to + generalize well. + + The EarthRegressor class supports dense input only. Data structures from the pandas and patsy + modules are supported, but are copied into numpy arrays for computation. No copy is + made if the inputs are numpy float64 arrays. EarthRegressor objects can be serialized using the + pickle module and copied using the copy module. + + + Parameters + ---------- + max_terms : int, optional (default=2*n + 10, where n is the number of features) + The maximum number of terms generated by the forward pass. + + + max_degree : int, optional (default=1) + The maximum degree of terms generated by the forward pass. + + + penalty : float, optional (default=3.0) + A smoothing parameter used to calculate GCV and GRSQ. Used during the pruning pass + and to determine whether to add a hinge or linear basis function during the forward + pass. See the d parameter in equation 32, Friedman, 1991. + + + endspan_alpha : float, optional, probability between 0 and 1 (default=0.05) + A parameter controlling the calculation of the endspan parameter (below). The + endspan parameter is calculated as round(3 - log2(endspan_alpha/n)), where n is the + number of features. The endspan_alpha parameter represents the probability of a run + of positive or negative error values on either end of the data vector of any feature + in the data set. See equation 45, Friedman, 1991. + + + endspan : int, optional (default=-1) + The number of extreme data values of each feature not eligible as knot locations. + If endspan is set to -1 (default) then the endspan parameter is calculated based on + endspan_alpah (above). If endspan is set to a positive integer then endspan_alpha + is ignored. + + + minspan_alpha : float, optional, probability between 0 and 1 (default=0.05) + A parameter controlling the calculation of the minspan parameter (below). The + minspan parameter is calculated as + + (int) -log2(-(1.0/(n*count))*log(1.0-minspan_alpha)) / 2.5 + + where n is the number of features and count is the number of points at which the + parent term is non-zero. The minspan_alpha parameter represents the probability of + a run of positive or negative error values between adjacent knots separated by + minspan intervening data points. See equation 43, Friedman, 1991. + + + minspan : int, optional (default=-1) + The minimal number of data points between knots. If minspan is set to -1 (default) + then the minspan parameter is calculated based on minspan_alpha (above). If minspan + is set to a positive integer then minspan_alpha is ignored. + + + thresh : float, optional (defaul=0.001) + Parameter used when evaluating stopping conditions for the forward pass. If either + RSQ > 1 - thresh or if RSQ increases by less than thresh for a forward pass iteration + then the forward pass is terminated. + + + min_search_points : int, optional (default=100) + Used to calculate check_every (below). The minimum samples necessary for check_every + to be greater than 1. The check_every parameter is calculated as + + (int) m / min_search_points + + if m > min_search_points, where m is the number of samples in the training set. If + m <= min_search_points then check_every is set to 1. + + + check_every : int, optional (default=-1) + If check_every > 0, only one of every check_every sorted data points is considered as + a candidate knot. If check_every is set to -1 then the check_every parameter is + calculated based on min_search_points (above). + + + allow_linear : bool, optional (default=True) + If True, the forward pass will check the GCV of each new pair of terms and, if it's not + an improvement on a single term with no knot (called a linear term, although it may + actually be a product of a linear term with some other parent term), then only that + single, knotless term will be used. If False, that behavior is disabled and all terms + will have knots except those with variables specified by the linvars argument (see the + fit method). + + + Attributes + ---------- + `coef_` : array, shape = [pruned basis length] + The weights of the model terms that have not been pruned. + + + `basis_` : _basis.Basis + An object representing model terms. Each term is a product of constant, linear, and hinge + functions of the input features. + + + `forward_pass_record_` : _record.ForwardPassRecord + An object containing information about the forward pass, such as training loss function + values after each iteration and the final stopping condition. + + + `pruning_pass_record_` : _record.PruningPassRecord + An object containing information about the pruning pass, such as training loss function + values after each iteration and the selected optimal iteration. + + + **References:** + Friedman, Jerome. Multivariate Adaptive Regression Splines. Annals of Statistics. Volume 19, + Number 1 (1991), 1-67. + + ''' + + forward_pass_arg_names = set( + ['endspan', 'minspan', 'endspan_alpha', 'minspan_alpha', + 'max_terms', 'max_degree', 'thresh', 'penalty', 'check_every', + 'min_search_points', 'allow_linear']) + pruning_pass_arg_names = set(['penalty']) + + def __init__( + self, endspan=None, minspan=None, endspan_alpha=None, minspan_alpha=None, max_terms=None, max_degree=None, + thresh=None, penalty=None, check_every=None, min_search_points=None, allow_linear=None): + kwargs = {} + call = locals() + for name in self._get_param_names(): + if call[name] is not None: + kwargs[name] = call[name] + + self.set_params(**kwargs) + + def __eq__(self, other): + if self.__class__ is not other.__class__: + return False + keys = set(self.__dict__.keys() + other.__dict__.keys()) + for k in keys: + try: + v_self = self.__dict__[k] + v_other = other.__dict__[k] + except KeyError: + return False + try: + if v_self != v_other: + return False + except ValueError: # Case of numpy arrays + if np.any(v_self != v_other): + return False + return True + + def _pull_forward_args(self, **kwargs): + ''' + Pull named arguments relevant to the forward pass. + ''' + result = {} + for name in self.forward_pass_arg_names: + if name in kwargs: + result[name] = kwargs[name] + return result + + def _pull_pruning_args(self, **kwargs): + ''' + Pull named arguments relevant to the pruning pass. + ''' + result = {} + for name in self.pruning_pass_arg_names: + if name in kwargs: + result[name] = kwargs[name] + return result + + def _pull_unknown_args(self, **kwargs): + ''' + Pull unknown named arguments. Usually an exception is raised if any are + actually found, but raising exceptions is the responsibility of the caller. + ''' + result = {} + known_args = self.forward_pass_arg_names | self.pruning_pass_arg_names + for name in kwargs.iterkeys(): + if name not in known_args: + result[name] = kwargs[name] + return result + + def _scrape_labels(self, X): + ''' + Try to get labels from input data (for example, if X is a pandas DataFrame). Return None + if no labels can be extracted. + ''' + try: + labels = list(X.columns) + except AttributeError: + try: + labels = list(X.design_info.column_names) + except AttributeError: + try: + labels = list(X.dtype.names) + except TypeError: + labels = None + + return labels + + def _scrub_x(self, X, **kwargs): + ''' + Sanitize input predictors and extract column names if appropriate. + ''' + # Check for sparseness + if sparse.issparse(X): + raise TypeError('A sparse matrix was passed, but dense data ' + 'is required. Use X.toarray() to convert to dense.') + + # Convert to internally used data type + X = safe_asarray(X, dtype=np.float64) + if len(X.shape) == 1: + X = X.reshape((X.shape[0], 1)) + + # Ensure correct number of columns + if hasattr(self, 'basis_') and self.basis_ is not None: + if X.shape[1] != self.basis_.num_variables: + raise ValueError('Wrong number of columns in X') + + return X + + def _scrub(self, X, y, sample_weight, **kwargs): + ''' + Sanitize input data. + ''' + # Check for sparseness + if sparse.issparse(y): + raise TypeError('A sparse matrix was passed, but dense data ' + 'is required. Use y.toarray() to convert to dense.') + if sparse.issparse(sample_weight): + raise TypeError('A sparse matrix was passed, but dense data ' + 'is required. Use sample_weight.toarray() to convert to dense.') + + # Check whether X is the output of patsy.dmatrices + if y is None and isinstance(X, tuple): + y, X = X + + # Handle X separately + X = self._scrub_x(X, **kwargs) + + # Convert y to internally used data type + y = safe_asarray(y, dtype=np.float64) + y = y.reshape(y.shape[0]) + + # Deal with sample_weight + if sample_weight is None: + sample_weight = np.ones(y.shape[0], dtype=y.dtype) + else: + sample_weight = safe_asarray(sample_weight) + sample_weight = sample_weight.reshape(sample_weight.shape[0]) + + # Make sure dimensions match + if y.shape[0] != X.shape[0]: + raise ValueError('X and y do not have compatible dimensions.') + if y.shape != sample_weight.shape: + raise ValueError( + 'y and sample_weight do not have compatible dimensions.') + + # Make sure everything is finite + assert_all_finite(X) + assert_all_finite(y) + assert_all_finite(sample_weight) + + return X, y, sample_weight + + def fit(self, X, y=None, sample_weight=None, xlabels=None, linvars=[]): + ''' + Fit an EarthRegressor model to the input data X and y. + + + Parameters + ---------- + X : array-like, shape = [m, n] where m is the number of samples and n is the number of features + The training predictors. The X parameter can be a numpy array, a pandas DataFrame, a patsy + DesignMatrix, or a tuple of patsy DesignMatrix objects as output by patsy.dmatrices. + + + y : array-like, optional (default=None), shape = [m] where m is the number of samples + The training response. The y parameter can be a numpy array, a pandas DataFrame with one + column, a Patsy DesignMatrix, or can be left as None (default) if X was the output of a + call to patsy.dmatrices (in which case, X contains the response). + + + sample_weight : array-like, optional (default=None), shape = [m] where m is the number of samples + Sample weights for training. Weights must be greater than or equal to zero. Rows with + greater weights contribute more strongly to the fitted model. Rows with zero weight do + not contribute at all. Weights are useful when dealing with heteroscedasticity. In such + cases, the weight should be proportional to the inverse of the (known) variance. + + + linvars : iterable of strings or ints, optional (empty by default) + Used to specify features that may only enter terms as linear basis functions (without + knots). Can include both column numbers and column names (see xlabels, below). If left + empty, some variables may still enter linearly during the forward pass if no knot would + provide a reduction in GCV compared to the linear function. Note that this feature differs + from the R package earth. + + + xlabels : iterable of strings, optional (empty by default) + The xlabels argument can be used to assign names to data columns. This argument is not + generally needed, as names can be captured automatically from most standard data + structures. If included, must have length n, where n is the number of features. Note + that column order is used to compute term values and make predictions, not column names. + + + ''' + + # Format and label the data + if xlabels is None: + xlabels = self._scrape_labels(X) + self.linvars_ = linvars + X, y, sample_weight = self._scrub(X, y, sample_weight) + + # Do the actual work + self.forward_pass(X, y, sample_weight, xlabels, linvars) + self.pruning_pass(X, y, sample_weight) + self.linear_fit(X, y, sample_weight) + return self + + def forward_pass( + self, X, y=None, sample_weight=None, xlabels=None, linvars=[]): + ''' + Perform the forward pass of the multivariate adaptive regression splines algorithm. Users + will normally want to call the fit method instead, which performs the forward pass, the pruning + pass, and a linear fit to determine the final model coefficients. + + + Parameters + ---------- + X : array-like, shape = [m, n] where m is the number of samples and n is the number of features + The training predictors. The X parameter can be a numpy array, a pandas DataFrame, a patsy + DesignMatrix, or a tuple of patsy DesignMatrix objects as output by patsy.dmatrices. + + + y : array-like, optional (default=None), shape = [m] where m is the number of samples + The training response. The y parameter can be a numpy array, a pandas DataFrame with one + column, a Patsy DesignMatrix, or can be left as None (default) if X was the output of a + call to patsy.dmatrices (in which case, X contains the response). + + + sample_weight : array-like, optional (default=None), shape = [m] where m is the number of samples + Sample weights for training. Weights must be greater than or equal to zero. Rows with + greater weights contribute more strongly to the fitted model. Rows with zero weight do + not contribute at all. Weights are useful when dealing with heteroscedasticity. In such + cases, the weight should be proportional to the inverse of the (known) variance. + + + linvars : iterable of strings or ints, optional (empty by default) + Used to specify features that may only enter terms as linear basis functions (without + knots). Can include both column numbers an column names (see xlabels, below). + + + xlabels : iterable of strings, optional (empty by default) + The xlabels argument can be used to assign names to data columns. This argument is not + generally needed, as names can be captured automatically from most standard data + structures. If included, must have length n, where n is the number of features. Note + that column order is used to compute term values and make predictions, not column names. + + + ''' + + # Label and format data + if xlabels is None: + xlabels = self._scrape_labels(X) + X, y, sample_weight = self._scrub(X, y, sample_weight) + + # Do the actual work + args = self._pull_forward_args(**self.__dict__) + forward_passer = ForwardPasser( + X, y, sample_weight, xlabels=xlabels, linvars=linvars, **args) + forward_passer.run() + self.forward_pass_record_ = forward_passer.trace() + self.basis_ = forward_passer.get_basis() + + def pruning_pass(self, X, y=None, sample_weight=None): + ''' + Perform the pruning pass of the multivariate adaptive regression splines algorithm. Users + will normally want to call the fit method instead, which performs the forward pass, the pruning + pass, and a linear fit to determine the final model coefficients. + + + Parameters + ---------- + X : array-like, shape = [m, n] where m is the number of samples and n is the number of features + The training predictors. The X parameter can be a numpy array, a pandas DataFrame, a patsy + DesignMatrix, or a tuple of patsy DesignMatrix objects as output by patsy.dmatrices. + + + y : array-like, optional (default=None), shape = [m] where m is the number of samples + The training response. The y parameter can be a numpy array, a pandas DataFrame with one + column, a Patsy DesignMatrix, or can be left as None (default) if X was the output of a + call to patsy.dmatrices (in which case, X contains the response). + + + sample_weight : array-like, optional (default=None), shape = [m] where m is the number of samples + Sample weights for training. Weights must be greater than or equal to zero. Rows with + greater weights contribute more strongly to the fitted model. Rows with zero weight do + not contribute at all. Weights are useful when dealing with heteroscedasticity. In such + cases, the weight should be proportional to the inverse of the (known) variance. + + + ''' + # Format data + X, y, sample_weight = self._scrub(X, y, sample_weight) + + # Pull arguments from self + args = self._pull_pruning_args(**self.__dict__) + + # Do the actual work + pruning_passer = PruningPasser( + self.basis_, X, y, sample_weight, **args) + pruning_passer.run() + self.pruning_pass_record_ = pruning_passer.trace() + + def unprune(self, X, y=None): + '''Unprune all pruned basis functions and fit coefficients to X and y using the unpruned basis.''' + for bf in self.basis_: + bf.unprune() + del self.pruning_pass_record_ + self.linear_fit(X, y) + + def forward_trace(self): + '''Return information about the forward pass.''' + try: + return self.forward_pass_record_ + except AttributeError: + return None + + def pruning_trace(self): + '''Return information about the pruning pass.''' + try: + return self.pruning_pass_record_ + except AttributeError: + return None + + def trace(self): + '''Return information about the forward and pruning passes.''' + return EarthRegressorTrace(self.forward_trace(), self.pruning_trace()) + + def summary(self): + '''Return a string describing the model.''' + result = '' + if self.forward_trace() is None: + result += 'Untrained EarthRegressor Model' + return result + elif self.pruning_trace() is None: + result += 'Unpruned EarthRegressor Model\n' + else: + result += 'EarthRegressor Model\n' + header = ['Basis Function', 'Pruned', 'Coefficient'] + data = [] + i = 0 + for bf in self.basis_: + data.append([str(bf), 'Yes' if bf.is_pruned() else 'No', '%g' % + self.coef_[i] if not bf.is_pruned() else 'None']) + if not bf.is_pruned(): + i += 1 + result += ascii_table(header, data) + if self.pruning_trace() is not None: + record = self.pruning_trace() + selection = record.get_selected() + else: + record = self.forward_trace() + selection = len(record) - 1 + result += '\n' + result += 'MSE: %.4f, GCV: %.4f, RSQ: %.4f, GRSQ: %.4f' % ( + record.mse(selection), record.gcv(selection), record.rsq(selection), record.grsq(selection)) + return result + + def linear_fit(self, X, y=None, sample_weight=None): + ''' + Solve the linear least squares problem to determine the coefficients of the unpruned basis functions. + + + Parameters + ---------- + X : array-like, shape = [m, n] where m is the number of samples and n is the number of features + The training predictors. The X parameter can be a numpy array, a pandas DataFrame, a patsy + DesignMatrix, or a tuple of patsy DesignMatrix objects as output by patsy.dmatrices. + + + y : array-like, optional (default=None), shape = [m] where m is the number of samples + The training response. The y parameter can be a numpy array, a pandas DataFrame with one + column, a Patsy DesignMatrix, or can be left as None (default) if X was the output of a + call to patsy.dmatrices (in which case, X contains the response). + + + sample_weight : array-like, optional (default=None), shape = [m] where m is the number of samples + Sample weights for training. Weights must be greater than or equal to zero. Rows with + greater weights contribute more strongly to the fitted model. Rows with zero weight do + not contribute at all. Weights are useful when dealing with heteroscedasticity. In such + cases, the weight should be proportional to the inverse of the (known) variance. + ''' + + # Format data + X, y, sample_weight = self._scrub(X, y, sample_weight) + + # Transform into basis space + B = self.transform(X) + + # Apply weights to B + apply_weights_2d(B, sample_weight) + + # Apply weights to y + weighted_y = y.copy() + apply_weights_1d(weighted_y, sample_weight) + + # Solve the linear least squares problem + self.coef_ = np.linalg.lstsq(B, weighted_y)[0] + + def predict(self, X): + ''' + Predict the response based on the input data X. + + + Parameters + ---------- + X : array-like, shape = [m, n] where m is the number of samples and n is the number of features + The training predictors. The X parameter can be a numpy array, a pandas DataFrame, or a + patsy DesignMatrix. + + ''' + X = self._scrub_x(X) + B = self.transform(X) + return np.dot(B, self.coef_) + + def score(self, X, y=None, sample_weight=None): + ''' + Calculate the generalized r^2 of the model on data X and y. + + + Parameters + ---------- + X : array-like, shape = [m, n] where m is the number of samples and n is the number of features + The training predictors. The X parameter can be a numpy array, a pandas DataFrame, a patsy + DesignMatrix, or a tuple of patsy DesignMatrix objects as output by patsy.dmatrices. + + + y : array-like, optional (default=None), shape = [m] where m is the number of samples + The training response. The y parameter can be a numpy array, a pandas DataFrame with one + column, a Patsy DesignMatrix, or can be left as None (default) if X was the output of a + call to patsy.dmatrices (in which case, X contains the response). + + sample_weight : array-like, optional (default=None), shape = [m] where m is the number of samples + Sample weights for training. Weights must be greater than or equal to zero. Rows with + greater weights contribute more strongly to the fitted model. Rows with zero weight do + not contribute at all. Weights are useful when dealing with heteroscedasticity. In such + cases, the weight should be proportional to the inverse of the (known) variance. + ''' + X, y, sample_weight = self._scrub(X, y, sample_weight) + y_hat = self.predict(X) + m, _ = X.shape + residual = y - y_hat + mse = np.sum(sample_weight * (residual ** 2)) / m + mse0 = np.sum( + sample_weight * ((y - np.average(y, weights=sample_weight)) ** 2)) / m + return 1 - (mse / mse0) + + def transform(self, X): + ''' + Transform X into the basis space. Normally, users will call the predict method instead, which + both transforms into basis space calculates the weighted sum of basis terms to produce a + prediction of the response. Users may wish to call transform directly in some cases. For + example, users may wish to apply other statistical or machine learning algorithms, such as + generalized linear regression, in basis space. + + + Parameters + ---------- + X : array-like, shape = [m, n] where m is the number of samples and n is the number of features + The training predictors. The X parameter can be a numpy array, a pandas DataFrame, or a + patsy DesignMatrix. + ''' + X = self._scrub_x(X) + B = np.empty(shape=(X.shape[0], self.basis_.plen())) + self.basis_.transform(X, B) + return B + + def get_penalty(self): + '''Get the penalty parameter being used. Default is 3.''' + if 'penalty' in self.__dict__ and self.penalty is not None: + return self.penalty + else: + return 3.0 + + def __repr__(self): + result = 'EarthRegressor(' + first = True + for k, v in self.get_params().iteritems(): + if not first: + result += ', ' + else: + first = False + result += '%s=%s' % (str(k), str(v)) + result += ')' + return result + + def __str__(self): + return self.__repr__() + + +class EarthRegressorTrace(object): + + def __init__(self, forward_trace, pruning_trace): + self.forward_trace = forward_trace + self.pruning_trace = pruning_trace + + def __eq__(self, other): + return self.__class__ is other.__class__ and self.forward_trace == other.forward_trace and \ + self.pruning_trace == other.pruning_trace + + def __str__(self): + return str(self.forward_trace) + '\n' + str(self.pruning_trace) diff --git a/sklearn/earth/setup.py b/sklearn/earth/setup.py new file mode 100644 index 0000000000000..f1d6071494691 --- /dev/null +++ b/sklearn/earth/setup.py @@ -0,0 +1,28 @@ +import numpy +from numpy.distutils.misc_util import Configuration + + +def configuration(parent_package="", top_path=None): + config = Configuration("earth", parent_package, top_path) + config.add_extension("_basis", + sources=["_basis.c"], + include_dirs=[numpy.get_include()]) + config.add_extension("_forward", + sources=["_forward.c"], + include_dirs=[numpy.get_include()]) + config.add_extension("_pruning", + sources=["_pruning.c"], + include_dirs=[numpy.get_include()]) + config.add_extension("_record", + sources=["_record.c"], + include_dirs=[numpy.get_include()]) + config.add_extension("_util", + sources=["_util.c"], + include_dirs=[numpy.get_include()]) + config.add_subpackage("tests") + + return config + +if __name__ == "__main__": + from numpy.distutils.core import setup + setup(**configuration().todict()) diff --git a/sklearn/earth/tests/__init__.py b/sklearn/earth/tests/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/sklearn/earth/tests/earth_linvars_regress.txt b/sklearn/earth/tests/earth_linvars_regress.txt new file mode 100644 index 0000000000000..ae3862ad029ae --- /dev/null +++ b/sklearn/earth/tests/earth_linvars_regress.txt @@ -0,0 +1,47 @@ +Forward Pass +--------------------------------------------------------------- +iter parent var knot mse terms gcv rsq grsq +--------------------------------------------------------------- +0 - - - 1.373069 1 1.401 0.000 0.000 +1 0 1 -1 0.861043 2 0.915 0.373 0.347 +2 0 2 -1 0.774582 3 0.858 0.436 0.387 +3 0 3 -1 0.764313 4 0.884 0.443 0.369 +4 0 6 -1 0.753043 5 0.909 0.452 0.351 +5 0 5 -1 0.740056 6 0.934 0.461 0.333 +6 0 7 -1 0.734362 7 0.970 0.465 0.307 +7 0 8 -1 0.732358 8 1.014 0.467 0.276 +8 0 4 -1 0.731261 9 1.061 0.467 0.242 +--------------------------------------------------------------- +Stopping Condition 2: Improvement below threshold + +Pruning Pass +-------------------------------------------- +iter bf terms mse gcv rsq grsq +-------------------------------------------- +0 - 9 0.73 1.061 0.467 0.242 +1 8 8 0.73 1.014 0.467 0.276 +2 7 7 0.73 0.970 0.465 0.307 +3 6 6 0.74 0.934 0.461 0.333 +4 5 5 0.75 0.909 0.452 0.351 +5 4 4 0.76 0.884 0.443 0.369 +6 3 3 0.77 0.858 0.436 0.387 +7 2 2 0.86 0.915 0.373 0.347 +8 1 1 1.37 1.401 0.000 0.000 +-------------------------------------------- +Selected iteration: 6 + +EarthRegressor Model +------------------------------------- +Basis Function Pruned Coefficient +------------------------------------- +(Intercept) No 0.657403 +x1 No 0.757872 +x2 No 0.325515 +x3 Yes None +x6 Yes None +x5 Yes None +x7 Yes None +x8 Yes None +x4 Yes None +------------------------------------- +MSE: 0.7746, GCV: 0.8583, RSQ: 0.4359, GRSQ: 0.3874 \ No newline at end of file diff --git a/sklearn/earth/tests/earth_regress.txt b/sklearn/earth/tests/earth_regress.txt new file mode 100644 index 0000000000000..d7aded29e176f --- /dev/null +++ b/sklearn/earth/tests/earth_regress.txt @@ -0,0 +1,51 @@ +Forward Pass +--------------------------------------------------------------- +iter parent var knot mse terms gcv rsq grsq +--------------------------------------------------------------- +0 - - - 1.373069 1 1.401 0.000 0.000 +1 0 1 15 0.813502 3 0.901 0.408 0.357 +2 0 2 -1 0.738195 4 0.854 0.462 0.391 +3 0 8 11 0.702052 6 0.886 0.489 0.367 +4 0 6 -1 0.690954 7 0.913 0.497 0.348 +5 0 5 -1 0.679718 8 0.941 0.505 0.328 +6 0 3 -1 0.670745 9 0.974 0.511 0.305 +7 0 7 -1 0.666258 10 1.015 0.515 0.275 +8 0 0 -1 0.666124 11 1.067 0.515 0.238 +--------------------------------------------------------------- +Stopping Condition 2: Improvement below threshold + +Pruning Pass +-------------------------------------------- +iter bf terms mse gcv rsq grsq +-------------------------------------------- +0 - 11 0.67 1.067 0.515 0.238 +1 10 10 0.67 1.015 0.515 0.275 +2 9 9 0.67 0.974 0.511 0.305 +3 8 8 0.68 0.941 0.505 0.328 +4 7 7 0.69 0.913 0.497 0.348 +5 6 6 0.70 0.886 0.489 0.367 +6 5 5 0.72 0.871 0.475 0.379 +7 4 4 0.74 0.854 0.462 0.391 +8 3 3 0.81 0.901 0.408 0.357 +9 1 2 0.92 0.979 0.329 0.301 +10 2 1 1.37 1.401 0.000 0.000 +-------------------------------------------- +Selected iteration: 7 + +EarthRegressor Model +------------------------------------- +Basis Function Pruned Coefficient +------------------------------------- +(Intercept) No 1.17194 +h(x1-0.949246) No 2.00084 +h(0.949246-x1) No -0.630635 +x2 No 0.305197 +h(x8-1.38526) Yes None +h(1.38526-x8) Yes None +x6 Yes None +x5 Yes None +x3 Yes None +x7 Yes None +x0 Yes None +------------------------------------- +MSE: 0.7382, GCV: 0.8535, RSQ: 0.4624, GRSQ: 0.3908 \ No newline at end of file diff --git a/sklearn/earth/tests/forward_regress.txt b/sklearn/earth/tests/forward_regress.txt new file mode 100644 index 0000000000000..41d8931bf8780 --- /dev/null +++ b/sklearn/earth/tests/forward_regress.txt @@ -0,0 +1,27 @@ +(Intercept) +h(x1-0.949246) +h(0.949246-x1) +x2 +h(x8-1.38526) +h(1.38526-x8) +x6 +x5 +x3 +x7 +x0 + +Forward Pass +--------------------------------------------------------------- +iter parent var knot mse terms gcv rsq grsq +--------------------------------------------------------------- +0 - - - 1.373069 1 1.401 0.000 0.000 +1 0 1 15 0.813502 3 0.901 0.408 0.357 +2 0 2 -1 0.738195 4 0.854 0.462 0.391 +3 0 8 11 0.702052 6 0.886 0.489 0.367 +4 0 6 -1 0.690954 7 0.913 0.497 0.348 +5 0 5 -1 0.679718 8 0.941 0.505 0.328 +6 0 3 -1 0.670745 9 0.974 0.511 0.305 +7 0 7 -1 0.666258 10 1.015 0.515 0.275 +8 0 0 -1 0.666124 11 1.067 0.515 0.238 +--------------------------------------------------------------- +Stopping Condition 2: Improvement below threshold diff --git a/sklearn/earth/tests/pathological_data/issue_44.csv b/sklearn/earth/tests/pathological_data/issue_44.csv new file mode 100644 index 0000000000000..b3a18d550528d --- /dev/null +++ b/sklearn/earth/tests/pathological_data/issue_44.csv @@ -0,0 +1,101 @@ +x,y +-3.7373737373737375,1.7991218849952073 +-0.50505050505050519,-0.91104074841082883 +2.3232323232323235,1.7489750942002336 +-9.3939393939393945,0.93746398352941285 +-1.9191919191919189,0.37906368380023697 +-4.5454545454545459,2.0671407475807846 +-2.3232323232323235,2.8903231496524264 +-2.1212121212121207,0.95421401743510981 +5.1515151515151523,-0.28835274505737712 +6.5656565656565631,2.4349616731309003 +8.3838383838383841,2.0015189624872649 +-4.3434343434343443,2.0839886262250777 +-5.1515151515151523,4.0035426047149203 +4.9494949494949498,1.0301181262384298 +10.0,2.0990912639096395 +5.9595959595959584,1.4837216429432181 +-4.1414141414141419,3.1115350771447017 +5.5555555555555554,-0.49432035860384549 +9.7979797979797993,2.2570162633565838 +2.9292929292929286,0.19922300098316129 +-4.7474747474747474,2.2411649234982853 +8.1818181818181817,3.8319133058008834 +0.10101010101010033,-1.1655342778993465 +-7.3737373737373728,1.5936860907276955 +0.50505050505050519,2.7824955819904238 +4.7474747474747474,0.37375342310356208 +-7.7777777777777777,1.3319391790079955 +0.70707070707070763,2.7447709715653392 +0.90909090909090795,1.2593630603714561 +-2.9292929292929286,1.4730041828646854 +1.5151515151515156,1.9517355390216784 +7.5757575757575744,2.5204906997403671 +3.737373737373737,0.82513781953866294 +1.7171717171717162,1.5521287384776057 +3.9393939393939386,0.41909788678935839 +8.787878787878789,0.83357749049159235 +2.5252525252525242,0.97158776816516124 +3.333333333333333,2.796727214906336 +1.9191919191919189,1.5770991785524595 +7.3737373737373728,2.812545924932186 +8.9898989898989896,2.3399323489969777 +-8.1818181818181817,0.22251629284196264 +-6.3636363636363633,0.65508003936260206 +-2.5252525252525246,1.1781202228906005 +7.7777777777777777,1.1361770487748726 +-6.9696969696969697,0.49658600871033542 +7.171717171717173,1.2870810571346567 +-1.1111111111111107,-0.92633728764534862 +-1.5151515151515156,-0.30285092335205799 +-6.1616161616161618,2.2600448186850697 +9.1919191919191903,2.0528078501883256 +9.5959595959595987,0.36719227705824703 +-5.5555555555555554,1.5554954537126158 +4.3434343434343443,-1.2471684340825608 +-0.10101010101010033,1.6055254760143964 +6.9696969696969688,1.9399379619451884 +4.545454545454545,0.86004045773468585 +-9.7979797979797958,2.8053907657933528 +-6.7676767676767682,-0.2256450948986943 +-3.9393939393939386,3.489343493164955 +-5.9595959595959593,2.5238295345305537 +-1.3131313131313131,0.23652412699589609 +-1.7171717171717178,-1.6686836205834381 +-9.1919191919191938,-0.55397857306368992 +-4.9494949494949498,1.0493231114754551 +-0.30303030303030282,-1.0878104111406399 +-9.5959595959595987,-0.55743666312264351 +-0.90909090909090995,1.8446458659377187 +5.3535353535353529,0.59548081377866657 +-7.1717171717171713,-0.46557755831965858 +0.30303030303030282,0.95943699775297564 +-5.7575757575757578,1.8185702673284407 +1.1111111111111107,2.1419245861795222 +2.7272727272727262,-1.3093855134880783 +-5.3535353535353538,1.6946451925769861 +3.1313131313131315,0.32016804097713369 +-3.333333333333333,2.2084032577385755 +9.3939393939393945,2.5342019954452182 +-7.9797979797979792,-0.48297953030589919 +8.5858585858585847,1.7297261905989889 +-2.7272727272727275,-0.9646357159778064 +-8.3838383838383841,-0.38537725554562052 +6.7676767676767682,3.3939003736405828 +6.1616161616161627,-0.077379083453575012 +6.3636363636363633,2.3902476491581792 +-8.5858585858585847,-0.19404572628702388 +2.1212121212121207,1.3602855988564588 +-3.5353535353535355,0.93983489736420145 +-10.0,2.3799875617530448 +-8.7878787878787872,-0.52460655837426085 +-7.5757575757575761,-0.28301040599130989 +5.7575757575757578,2.206172182722522 +4.1414141414141419,1.401220881354313 +7.9797979797979792,1.5959670945663329 +-6.5656565656565657,-0.45038856153592982 +-3.1313131313131315,2.1499146748068823 +-0.70707070707070763,-0.86787179551703342 +1.3131313131313131,0.1139238155075194 +-8.9898989898989896,0.19646334195105306 +3.5353535353535346,1.1596893484229858 diff --git a/sklearn/earth/tests/pathological_data/issue_44.txt b/sklearn/earth/tests/pathological_data/issue_44.txt new file mode 100644 index 0000000000000..858e5c9a3ab38 --- /dev/null +++ b/sklearn/earth/tests/pathological_data/issue_44.txt @@ -0,0 +1,8 @@ +EarthRegressor Model +------------------------------------- +Basis Function Pruned Coefficient +------------------------------------- +(Intercept) No 1.13135 +x Yes None +------------------------------------- +MSE: 1.6432, GCV: 1.6765, RSQ: -0.0000, GRSQ: -0.0000 \ No newline at end of file diff --git a/sklearn/earth/tests/pathological_data/issue_50.csv b/sklearn/earth/tests/pathological_data/issue_50.csv new file mode 100644 index 0000000000000..5f76b259cb6cb --- /dev/null +++ b/sklearn/earth/tests/pathological_data/issue_50.csv @@ -0,0 +1,8 @@ +x,y +24.040128,-125.66847999999999 +40.17048,-131.51711999999998 +41.10344,-133.78176 +41.972224,-133.5096 +44.720591999999996,-133.60592 +45.825248,-138.48239999999998 +50.725696,-142.98031999999998 diff --git a/sklearn/earth/tests/pathological_data/issue_50.txt b/sklearn/earth/tests/pathological_data/issue_50.txt new file mode 100644 index 0000000000000..78fbf8cb5a76e --- /dev/null +++ b/sklearn/earth/tests/pathological_data/issue_50.txt @@ -0,0 +1,11 @@ +EarthRegressor Model +------------------------------------- +Basis Function Pruned Coefficient +------------------------------------- +(Intercept) No -134.994 +h(x-44.7206) No -1.42112 +h(44.7206-x) No 0.461161 +h(x-40.1705) Yes None +h(40.1705-x) Yes None +------------------------------------- +MSE: 1191.2154, GCV: 6485.5061, RSQ: 0.9507, GRSQ: 0.8028 \ No newline at end of file diff --git a/sklearn/earth/tests/pathological_data/issue_50_weight.csv b/sklearn/earth/tests/pathological_data/issue_50_weight.csv new file mode 100644 index 0000000000000..5a1c36948b39f --- /dev/null +++ b/sklearn/earth/tests/pathological_data/issue_50_weight.csv @@ -0,0 +1,8 @@ +sample_weight +1062.711799884992 +871.4544949444627 +839.5063272968255 +954.8189050502953 +827.1006200543013 +1244.6183968904068 +802.2168136248937 \ No newline at end of file diff --git a/sklearn/earth/tests/pathological_data/readme.txt b/sklearn/earth/tests/pathological_data/readme.txt new file mode 100644 index 0000000000000..c5043e9b4454c --- /dev/null +++ b/sklearn/earth/tests/pathological_data/readme.txt @@ -0,0 +1,15 @@ +Pathological Data Sets + +The data sets contained in this folder have revealed bugs in the past. They now serve as +regression tests to prevent the same bugs from arising again in the future. + +issue_44: +This data set caused a segfault during fitting due to the use of a negative index in Cython +with wraparound = False. + +issue_50: +This data set exposed a bug that occurred when using the sample_weight parameter. The problem +was that the apply methods of the BasisFunctions were not applying the weights, and the +next_pair method of the ForwardPasser class assumed they were. Now next_pair applies the +weights after calling apply. The same data set exposed issue 51, in which user-specified +endspans were not used. This test case covers both issues. \ No newline at end of file diff --git a/sklearn/earth/tests/test_basis.py b/sklearn/earth/tests/test_basis.py new file mode 100644 index 0000000000000..29e3c0fdeb4e8 --- /dev/null +++ b/sklearn/earth/tests/test_basis.py @@ -0,0 +1,130 @@ +''' +Created on Feb 17, 2013 + +@author: jasonrudy +''' +from nose.tools import assert_true, assert_false, assert_equal +from .._basis import Basis, ConstantBasisFunction, HingeBasisFunction, \ + LinearBasisFunction +import numpy +import pickle +import os + + +class BaseTestClass(object): + + def __init__(self): + numpy.random.seed(0) + data = numpy.genfromtxt( + os.path.join(os.path.dirname(__file__), 'test_data.csv'), + delimiter=',', skip_header=1) + self.y = numpy.array(data[:, 5]) + self.X = numpy.array(data[:, 0:5]) + + +class TestConstantBasisFunction(BaseTestClass): + + def __init__(self): + super(self.__class__, self).__init__() + self.bf = ConstantBasisFunction() + + def test_apply(self): + m, n = self.X.shape + B = numpy.empty(shape=(m, 10)) + + assert_false(numpy.all(B[:, 0] == 1)) + self.bf.apply(self.X, B[:, 0]) + assert_true(numpy.all(B[:, 0] == 1)) + + def test_pickle_compatibility(self): + bf_copy = pickle.loads(pickle.dumps(self.bf)) + assert_true(self.bf == bf_copy) + + +class TestHingeBasisFunction(BaseTestClass): + + def __init__(self): + super(self.__class__, self).__init__() + self.parent = ConstantBasisFunction() + self.bf = HingeBasisFunction(self.parent, 1.0, 10, 1, False) + + def test_getters(self): + assert not self.bf.get_reverse() + assert self.bf.get_knot() == 1.0 + assert self.bf.get_variable() == 1 + assert self.bf.get_knot_idx() == 10 + assert self.bf.get_parent() == self.parent + + def test_apply(self): + m, n = self.X.shape + B = numpy.ones(shape=(m, 10)) + self.bf.apply(self.X, B[:, 0]) + assert_true( + numpy.all(B[:, 0] == (self.X[:, 1] - 1.0) * (self.X[:, 1] > 1.0))) + + def test_degree(self): + assert_equal(self.bf.degree(), 1) + + def test_pickle_compatibility(self): + bf_copy = pickle.loads(pickle.dumps(self.bf)) + assert_true(self.bf == bf_copy) + + +class TestLinearBasisFunction(BaseTestClass): + + def __init__(self): + super(self.__class__, self).__init__() + parent = ConstantBasisFunction() + self.bf = LinearBasisFunction(parent, 1) + + def test_apply(self): + m, n = self.X.shape + B = numpy.ones(shape=(m, 10)) + self.bf.apply(self.X, B[:, 0]) + assert_true(numpy.all(B[:, 0] == self.X[:, 1])) + + def test_degree(self): + assert_equal(self.bf.degree(), 1) + + def test_pickle_compatibility(self): + bf_copy = pickle.loads(pickle.dumps(self.bf)) + assert_true(self.bf == bf_copy) + + +class TestBasis(BaseTestClass): + + def __init__(self): + super(self.__class__, self).__init__() + self.basis = Basis(self.X.shape[1]) + self.parent = ConstantBasisFunction() + self.bf = HingeBasisFunction(self.parent, 1.0, 10, 1, False) + self.basis.append(self.parent) + self.basis.append(self.bf) + + def test_add(self): + assert_equal(len(self.basis), 2) + + def test_translate_and_scale(self): + m, n = self.X.shape + numpy.random.seed(1) + B = numpy.empty(shape=(m, self.basis.plen())) + self.basis.transform(self.X, B) + B_ = numpy.empty(shape=(m, self.basis.plen())) + mu = numpy.mean(self.X, axis=0) + sigma = numpy.std(self.X, axis=0) + coeff = numpy.random.normal(size=B.shape[1]) + X_ = self.X * sigma + mu + coeff_ = coeff.copy() + self.basis.translate(sigma, mu) + self.basis.scale(sigma, mu, coeff_) + self.basis.transform(X_, B_) + assert_true( + numpy.all((numpy.dot(B, coeff) - numpy.dot(B_, coeff_)) ** 2 < 1e-12)) + + def test_pickle_compat(self): + basis_copy = pickle.loads(pickle.dumps(self.basis)) + assert_true(self.basis == basis_copy) + +if __name__ == '__main__': + import nose + nose.run(argv=[__file__, '-s', '-v']) diff --git a/sklearn/earth/tests/test_data.csv b/sklearn/earth/tests/test_data.csv new file mode 100644 index 0000000000000..81ded171c0d05 --- /dev/null +++ b/sklearn/earth/tests/test_data.csv @@ -0,0 +1,101 @@ +,x1,x2,x3,x4,y +0,43.599490214200372,168.01752905539175,0.54966247787870914,5.3532239261827685,1.1297150506376397 +1,42.036780208748901,665.30797852674027,0.2046486340378425,7.192709663506637,1.2713369428242232 +2,29.965467367452312,561.56026190867692,0.6211338327692949,6.2914209427703902,1.4850975083257041 +3,13.457994534493356,964.65939760630852,0.18443986564691528,8.8533514781667346,1.4953000345937923 +4,85.397529263948883,933.06293121890087,0.846561485357468,1.7964547700906099,1.4631020455675685 +5,50.524609012170394,232.31757947498625,0.42812232759738944,1.9653091566061256,1.1007702782292474 +6,12.715997170127746,1100.523659094282,0.22601200060423587,2.0694568430998297,1.5197173280758225 +7,22.03062070705597,697.14978338305832,0.46778748458230024,3.0174322626496535,1.5033445601444178 +8,64.040672521491487,914.82020234450215,0.50523672001854913,4.8689265111855935,1.4331168743198677 +9,79.363745444157701,1073.1748771988184,0.16229859850231387,8.0075234660715626,1.1432487611454192 +10,96.455108008925521,942.49145512022062,0.88952006394614491,4.4161365267110968,1.4562484984016864 +11,56.714412762770927,824.11483997236769,0.436747263026799,8.7655918499710026,1.414510544111284 +12,53.560417349765629,1683.72388440954,0.54420816014810214,1.820949222750248,1.5124095787831815 +13,36.634240167502043,1515.6370663391237,0.40627504304795081,1.2720236589484959,1.5113725053014444 +14,24.717723899735333,235.35264229889736,0.99385201142127289,10.705803133771735,1.4655130013848647 +15,80.02583511325868,1108.8091147978175,0.76495986045168152,2.6922544658417795,1.4767263034461056 +16,29.302323181943979,981.79412176895062,0.3566242811227589,1.4567896524540005,1.4873012780322354 +17,98.315344535721266,846.67353972446074,0.50400043937915262,4.2354131753469879,1.3443519921907898 +18,25.974475274713704,757.69792530898212,0.83201689963450087,8.3674705628711301,1.5296175850152098 +19,37.921056694163745,146.92919419462237,0.79740493903259357,3.6938879759630119,1.2577693248791448 +20,58.268488852903452,167.40444477138499,0.66220201926832578,4.8752342587328146,1.0868547000197621 +21,49.707379873451259,803.46557407006787,0.35087190130164048,6.509779053244193,1.3962687049291784 +22,97.29106898748249,309.89810937521673,0.31325852842971358,1.4179770981531006,0.78429139704278905 +23,73.839975862090029,1199.7944712348387,0.21463574639995364,5.1675344019533709,1.2915519005124272 +24,64.384193414819507,1206.278241921543,0.17047713348377069,9.8165223574854856,1.2673762639361186 +25,77.800815980846821,344.49507542459531,0.86891662643207879,8.4877787827685438,1.3165122722672742 +26,79.858565409908095,1013.287786221621,0.22083791506146189,10.184586465896006,1.2280106041472256 +27,59.208457766637636,691.28771196765126,0.26377852928001977,10.13915477165132,1.2568334102951819 +28,41.973546130682074,1008.1357886623166,0.60844215780504962,9.2624982843415786,1.5024742715099091 +29,62.356318456213074,414.34567303306642,0.59125735265354584,5.8926616699485912,1.3215571295292234 +30,54.790778009037666,1268.4203030312453,0.24581116390413071,2.8662714558648021,1.3968435575605214 +31,11.058314779616108,573.3746240396913,0.010250039399590904,7.2935972282958215,0.48848512011765227 +32,29.517230521974248,431.62028327847486,0.095288052260803724,3.8375580746525464,0.948291052430141 +33,21.492438413069525,592.2340141355902,0.47140985746967901,6.4949682108840801,1.493964996060547 +34,84.511311557470165,1740.5210094161948,0.048868086229351348,3.3211825143616394,0.78860895398958175 +35,64.331142724823522,389.4400333896524,0.8701458933690015,3.1740242630502591,1.3831880046821949 +36,74.175503888344892,1192.4564185889287,0.79888551150462961,1.312475622652616,1.4930896449101998 +37,22.957402874434518,1276.7630450157669,0.087562509001122835,1.3058948319431931,1.368261016889893 +38,35.713493369956076,1089.1481873897621,0.052222727384160228,1.6566366620637754,1.0101147923717795 +39,4.3501186059715646,771.19312047180301,0.66842704601605774,2.9802711181616961,1.5623576569691324 +40,87.626645170415912,832.02671712936331,0.61964146370996465,3.9042674293498836,1.4024404901819352 +41,61.525457346427629,1683.5894947019638,0.44801471652408964,3.0704983825331427,1.4894072650971031 +42,42.536729190538644,851.9327531051822,0.50761748667196138,6.2573324981095793,1.4727508306732644 +43,4.2429191882546125,394.26335861902976,0.45022717961737324,8.0797117061892081,1.5468981531588779 +44,77.758790830553366,1395.1610647361344,0.50277875250922144,10.567475933072476,1.460393868002404 +45,33.187371253987585,912.1873275789045,0.74837399934103632,9.5783951843951396,1.5222195816705415 +46,41.446005513291148,1512.0986444671671,0.44457094175070921,8.1574708428635425,1.5092202298531809 +47,0.84483635788197287,166.83346202488673,0.94045049354208854,2.0213794823119349,1.5654116764743224 +48,66.196779043970764,588.40317224341504,0.20084234377544541,4.8833418211475914,1.0601903754929445 +49,92.590159650849927,1057.2797254435752,0.91671461195788251,8.0226424081972496,1.4755551186558762 +50,50.121645168708696,952.42141882934163,0.21882078632937274,1.0466352273504989,1.3347814583500877 +51,41.783624400271577,1046.0107958571264,0.87656186842332706,7.7758484022790944,1.5252569521812418 +52,84.233304610347119,1638.6668835657422,0.94111587363362226,9.1601915192439396,1.5162307488602251 +53,13.139460547944381,691.9282666193011,0.2085024945255225,9.6738153715652349,1.4799705457454786 +54,79.233021930625796,695.80262118445432,0.56914053205563542,9.0513154025570159,1.373325112134129 +55,83.316124473397622,461.85405604761195,0.7306802005261156,9.0341416415944895,1.3287501970473858 +56,4.3129036353362737,300.76807022306298,0.43508364985882764,3.208812218607441,1.537849657136791 +57,88.062206616568076,1301.3655484690632,0.713007293546981,8.6985965699270196,1.4761731652796777 +58,33.074702616940478,499.12785574456325,0.62634395920102637,5.1447924952538919,1.4653918027366943 +59,93.678107223418593,1175.192081886714,0.3869003430123682,9.5511966080419057,1.3676095804869888 +60,38.079258371620803,416.9556655484522,0.78165942566608138,5.7220858741580143,1.4544863401972903 +61,25.948040440427711,1256.7866259336176,0.98048507899877846,3.4625358896778984,1.5497421662642135 +62,79.024380259404523,1371.0360436135713,0.12003979217741401,9.3890259455900065,1.1231452260421266 +63,46.173890475653167,331.14371718490827,0.53634347309606856,3.9651275079462902,1.3164476345244571 +64,17.57241932567306,255.10941472150532,0.19889909182949916,5.2958861905641381,1.2374029218521734 +65,64.181176362883164,268.40879494821309,0.71573058777096521,2.0174481096338206,1.2483635075582606 +66,17.559907090882188,1290.9659113904681,0.88526367441048914,10.831383610430724,1.5554324559039934 +67,65.290695070121458,906.10727496154846,0.087787554884994456,6.5895079469727671,0.88349792606034916 +68,18.115022940864645,966.00540791086814,0.60893014893439157,9.3321249012260417,1.540010225121146 +69,32.375058225614652,1741.0966877926312,0.99495025996779318,9.2615081943979671,1.5521094914523137 +70,69.41525454251834,1324.2073630319194,0.8752688098046626,10.515101483457324,1.5109773403955418 +71,85.226292659755117,1172.7191296517713,0.073498384714436593,7.2338471429583864,0.79103662938713226 +72,35.321389178551854,394.85070848243845,0.89316618656704339,9.2489048120667938,1.4709741466986235 +73,52.663842385283331,882.76747093432482,0.48930128812712559,3.60720019719452,1.4494708771682183 +74,40.263792313314738,839.01992696466721,0.015056134248370046,9.9290588307871577,0.30401221390383193 +75,2.9149317847511735,734.83202953690954,0.09587331469277216,2.969643203500385,1.5294442092384655 +76,94.242061239714317,732.18275455239154,0.72900080182147697,2.2616010862902147,1.3960352705744583 +77,25.128292170720933,1565.274520614033,0.90329615048901546,3.87635258215888,1.5530259502567871 +78,96.711313151229632,1217.0896077711188,0.50300677353432655,4.7800240864855548,1.414118748214515 +79,33.73682942964583,1680.8952215019413,0.69333382858922288,6.3410170007333724,1.5418562287011579 +80,4.3489697936277434,530.06979251124858,0.94317072266720825,6.568601662432533,1.5620976675187246 +81,35.751823235523204,141.1021036455474,0.25354826722492296,3.5422669015053678,0.78571091574943486 +82,17.068552603402608,689.23268976152656,0.20264905134772382,1.6290154018084104,1.4491942594415783 +83,9.7960395886258596,937.13175163872779,0.069660590412445433,10.351535633514883,1.4218482165198603 +84,20.609763517058365,884.0140824788291,0.41466825710663691,3.9133771843298231,1.5146325379560737 +85,32.352851482004418,471.33548120389071,0.28026828777019874,2.1710503569658961,1.3306112118673223 +86,68.925187477754406,1178.5798517678015,0.31152940334298462,9.802989561574968,1.3852319082884261 +87,38.637572509456085,1123.9564075595154,0.52316932617519518,4.2505680361012992,1.5051826484433741 +88,92.979042306516263,1511.3094300825874,0.84112294801990795,10.542886365563277,1.4977834382425299 +89,0.24824262680964715,929.60333613098521,0.93791311906460373,2.3442675982313901,1.5705116078990755 +90,24.499413841416974,950.74709217600264,0.67842150982188265,4.3275995761694919,1.5328314042906843 +91,30.636467159000723,1393.0290357968324,0.032853938228447621,8.8579786252172905,0.98089726746506534 +92,42.85402814602093,1153.2312807768033,0.70550302490679973,1.9846862942141765,1.5181733452638007 +93,90.384616487488657,1469.0165275332865,0.37538143725374984,2.9479432849585923,1.4083347621930655 +94,6.280543805583938,629.8159444446452,0.71319196060205603,9.1318171617989297,1.5568149793762627 +95,32.658830121723945,485.53547264576639,0.32739418364654083,10.643668363057484,1.3681645174548087 +96,9.6090700177030914,390.61115652266483,0.69423911895276047,2.3976349904776564,1.5353763989585334 +97,26.662589262979463,1437.7544447801224,0.30061178385836629,6.9701654887125475,1.5091848395920116 +98,57.281228776535677,559.29964147614896,0.24873428889263027,3.8967549066201626,1.1802018969155548 +99,87.594007242403123,156.30754331038852,0.09163641211230289,4.4120995915425212,0.16207038454185166 diff --git a/sklearn/earth/tests/test_earth.py b/sklearn/earth/tests/test_earth.py new file mode 100644 index 0000000000000..e1336a80ef177 --- /dev/null +++ b/sklearn/earth/tests/test_earth.py @@ -0,0 +1,199 @@ +import numpy +from .._basis import Basis, ConstantBasisFunction, HingeBasisFunction, LinearBasisFunction +from .. import EarthRegressor +import pickle +import copy +import os +from .testing_utils import if_statsmodels, if_pandas, if_patsy +from nose.tools import assert_equal, assert_not_equal, assert_true, assert_false, \ + assert_almost_equal, assert_list_equal + + +class TestEarth(object): + + def __init__(self): + numpy.random.seed(0) + self.basis = Basis(10) + constant = ConstantBasisFunction() + self.basis.append(constant) + bf1 = HingeBasisFunction(constant, 0.1, 10, 1, False, 'x1') + bf2 = HingeBasisFunction(constant, 0.1, 10, 1, True, 'x1') + bf3 = LinearBasisFunction(bf1, 2, 'x2') + self.basis.append(bf1) + self.basis.append(bf2) + self.basis.append(bf3) + self.X = numpy.random.normal(size=(100, 10)) + self.B = numpy.empty(shape=(100, 4), dtype=numpy.float64) + self.basis.transform(self.X, self.B) + self.beta = numpy.random.normal(size=4) + self.y = numpy.empty(shape=100, dtype=numpy.float64) + self.y[:] = numpy.dot( + self.B, + self.beta) + numpy.random.normal(size=100) + self.earth = EarthRegressor(penalty=1) + + def test_get_params(self): + assert_equal( + EarthRegressor().get_params(), {'penalty': None, 'min_search_points': None, + 'endspan_alpha': None, 'check_every': None, + 'max_terms': None, 'max_degree': + None, 'minspan_alpha': None, + 'thresh': None, 'minspan': None, 'endspan': None, + 'allow_linear': None}) + assert_equal( + EarthRegressor( + max_degree=3).get_params(), {'penalty': None, 'min_search_points': None, + 'endspan_alpha': None, + 'check_every': None, + 'max_terms': None, 'max_degree': + 3, 'minspan_alpha': None, + 'thresh': None, 'minspan': None, 'endspan': None, + 'allow_linear': None}) + + @if_statsmodels + def test_linear_fit(self): + from statsmodels.regression.linear_model import GLS, OLS + self.earth.fit(self.X, self.y) + self.earth.linear_fit(self.X, self.y) + soln = OLS(self.y, self.earth.transform(self.X)).fit().params + assert_almost_equal(numpy.mean((self.earth.coef_ - soln) ** 2), 0.0) + + sample_weight = 1.0 / (numpy.random.normal(size=self.y.shape) ** 2) + self.earth.fit(self.X, self.y) + self.earth.linear_fit(self.X, self.y, sample_weight) + soln = GLS( + self.y, + self.earth.transform(self.X), + 1.0 / sample_weight).fit().params + assert_almost_equal(numpy.mean((self.earth.coef_ - soln) ** 2), 0.0) + + def test_sample_weight(self): + group = numpy.random.binomial(1, .5, size=1000) == 1 + sample_weight = 1 / (group * 100 + 1.0) + x = numpy.random.uniform(-10, 10, size=1000) + y = numpy.abs(x) + y[group] = numpy.abs(x[group] - 5) + y += numpy.random.normal(0, 1, size=1000) + model = EarthRegressor().fit(x, y, sample_weight=sample_weight) + + # Check that the model fits better for the more heavily weighted group + assert_true( + model.score(x[group], + y[group]) < model.score(x[numpy.logical_not(group)], + y[numpy.logical_not(group)])) + + # Make sure that the score function gives the same answer as the trace + assert_almost_equal( + model.score(x, + y, + sample_weight=sample_weight), + model.pruning_trace().rsq(model.pruning_trace().get_selected())) + + # Uncomment below to see what this test situation looks like +# from matplotlib import pyplot +# print model.summary() +# print model.score(x,y,sample_weight = sample_weight) +# pyplot.figure() +# pyplot.plot(x,y,'b.') +# pyplot.plot(x,model.predict(x),'r.') +# pyplot.show() + + def test_fit(self): + self.earth.fit(self.X, self.y) + res = str(self.earth.trace()) + '\n' + self.earth.summary() +# with open('earth_regress.txt','w') as fl: +# fl.write(res) + with open(os.path.join(os.path.dirname(__file__), 'earth_regress.txt'), 'r') as fl: + prev = fl.read() + assert_equal(res, prev) + + def test_linvars(self): + self.earth.fit(self.X, self.y, linvars=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) + res = str(self.earth.trace()) + '\n' + self.earth.summary() +# with open('earth_linvars_regress.txt','w') as fl: +# fl.write(res) + with open(os.path.join(os.path.dirname(__file__), 'earth_linvars_regress.txt'), 'r') as fl: + prev = fl.read() + assert_equal(res, prev) + + def test_score(self): + model = self.earth.fit(self.X, self.y) + record = model.pruning_trace() + rsq = record.rsq(record.get_selected()) + assert_almost_equal(rsq, model.score(self.X, self.y)) + + @if_pandas + def test_pathological_cases(self): + import pandas + directory = os.path.join( + os.path.dirname(os.path.abspath(__file__)), 'pathological_data') + cases = {'issue_44': {}, + 'issue_50': {'penalty': 0.5, 'minspan': 1, 'allow_linear': False, + 'endspan': 1, 'check_every': 1, 'sample_weight': 'issue_50_weight.csv'}} + for case, settings in cases.iteritems(): + data = pandas.read_csv(os.path.join(directory, case + '.csv')) + y = data['y'] + del data['y'] + X = data + if 'sample_weight' in settings: + sample_weight = pandas.read_csv(os.path.join(directory, settings['sample_weight']))['sample_weight'] + del settings['sample_weight'] + else: + sample_weight = None + model = EarthRegressor(**settings).fit(X, y, sample_weight = sample_weight) +# with open(os.path.join(directory, case + '.txt'), 'w') as outfile: +# outfile.write(model.summary()) + with open(os.path.join(directory, case + '.txt'), 'r') as infile: + correct = infile.read() + assert_equal(model.summary(), correct) + + @if_pandas + def test_pandas_compatibility(self): + import pandas + X = pandas.DataFrame(self.X) + y = pandas.DataFrame(self.y) + colnames = ['xx' + str(i) for i in range(X.shape[1])] + X.columns = colnames + model = self.earth.fit(X, y) + assert_list_equal( + colnames, + model.forward_trace()._getstate()['xlabels']) + + @if_patsy + @if_pandas + def test_patsy_compatibility(self): + import pandas + import patsy + X = pandas.DataFrame(self.X) + y = pandas.DataFrame(self.y) + colnames = ['xx' + str(i) for i in range(X.shape[1])] + X.columns = colnames + X['y'] = y + y, X = patsy.dmatrices( + 'y ~ xx0 + xx1 + xx2 + xx3 + xx4 + xx5 + xx6 + xx7 + xx8 + xx9 - 1', data=X) + model = self.earth.fit(X, y) + assert_list_equal( + colnames, + model.forward_trace()._getstate()['xlabels']) + + def test_pickle_compatibility(self): + model = self.earth.fit(self.X, self.y) + model_copy = pickle.loads(pickle.dumps(model)) + assert_true(model_copy == model) + assert_true( + numpy.all(model.predict(self.X) == model_copy.predict(self.X))) + assert_true(model.basis_[0] is model.basis_[1]._get_root()) + assert_true(model_copy.basis_[0] is model_copy.basis_[1]._get_root()) + + def test_copy_compatibility(self): + model = self.earth.fit(self.X, self.y) + model_copy = copy.copy(model) + assert_true(model_copy == model) + assert_true( + numpy.all(model.predict(self.X) == model_copy.predict(self.X))) + assert_true(model.basis_[0] is model.basis_[1]._get_root()) + assert_true(model_copy.basis_[0] is model_copy.basis_[1]._get_root()) + +if __name__ == '__main__': + import nose + nose.run(argv=[__file__, '-s', '-v']) diff --git a/sklearn/earth/tests/test_forward.py b/sklearn/earth/tests/test_forward.py new file mode 100644 index 0000000000000..610f0cd81af16 --- /dev/null +++ b/sklearn/earth/tests/test_forward.py @@ -0,0 +1,61 @@ +from .._forward import ForwardPasser +from .._basis import Basis, ConstantBasisFunction, HingeBasisFunction, LinearBasisFunction +import numpy +import os +from nose.tools import assert_true, assert_equal + + +class TestForwardPasser(object): + + def __init__(self): + numpy.random.seed(0) + self.basis = Basis(10) + constant = ConstantBasisFunction() + self.basis.append(constant) + bf1 = HingeBasisFunction(constant, 0.1, 10, 1, False, 'x1') + bf2 = HingeBasisFunction(constant, 0.1, 10, 1, True, 'x1') + bf3 = LinearBasisFunction(bf1, 2, 'x2') + self.basis.append(bf1) + self.basis.append(bf2) + self.basis.append(bf3) + self.X = numpy.random.normal(size=(100, 10)) + self.B = numpy.empty(shape=(100, 4), dtype=numpy.float64) + self.basis.transform(self.X, self.B) + self.beta = numpy.random.normal(size=4) + self.y = numpy.empty(shape=100, dtype=numpy.float64) + self.y[:] = numpy.dot( + self.B, + self.beta) + numpy.random.normal(size=100) + self.forwardPasser = ForwardPasser( + self.X, + self.y, + numpy.ones(self.y.shape), + max_terms=1000, + penalty=1) + + def test_orthonormal_update(self): + numpy.set_printoptions(precision=4) + m, n = self.X.shape + B_orth = self.forwardPasser.get_B_orth() + v = numpy.random.normal(size=m) + for i in range(1, 10): + v_ = numpy.random.normal(size=m) + B_orth[:, i] = 10 * v_ + v + v = v_ + self.forwardPasser.orthonormal_update(i) + assert_true( + numpy.max(numpy.abs(numpy.dot(B_orth[:, 0:i + 1].transpose(), B_orth[:, 0:i + 1]) - numpy.eye(i + 1))) < .0000001) + + def test_run(self): + self.forwardPasser.run() + res = str(self.forwardPasser.get_basis()) + \ + '\n' + str(self.forwardPasser.trace()) +# with open('forward_regress.txt','w') as fl: +# fl.write(res) + with open(os.path.join(os.path.dirname(__file__), 'forward_regress.txt'), 'r') as fl: + prev = fl.read() + assert_equal(res, prev) + +if __name__ == '__main__': + import nose + nose.run(argv=[__file__, '-s', '-v']) diff --git a/sklearn/earth/tests/test_pruning.py b/sklearn/earth/tests/test_pruning.py new file mode 100644 index 0000000000000..3800fbc83b2b0 --- /dev/null +++ b/sklearn/earth/tests/test_pruning.py @@ -0,0 +1,13 @@ + + +class Test(object): + + def __init__(self): + pass + + def test(self): + pass + +if __name__ == '__main__': + import nose + nose.run(argv=[__file__, '-s', '-v']) diff --git a/sklearn/earth/tests/test_record.py b/sklearn/earth/tests/test_record.py new file mode 100644 index 0000000000000..05a07bd4b8ebb --- /dev/null +++ b/sklearn/earth/tests/test_record.py @@ -0,0 +1,84 @@ +from .._record import ForwardPassRecord, ForwardPassIteration, PruningPassRecord, PruningPassIteration +from .._util import gcv +from nose.tools import assert_true, assert_equal, assert_list_equal + + +class TestForwardPassRecord(object): + + def __init__(self): + # Create a record + self.num_samples = 1000 + self.num_variables = 10 + self.penalty = 3.0 + self.sst = 100.0 + self.record = ForwardPassRecord( + self.num_samples, + self.num_variables, + self.penalty, + self.sst, + ['x' + str(i) for i in range(self.num_variables)]) + self.record.append(ForwardPassIteration(0, 3, 3, 63.0, 3)) + self.record.append(ForwardPassIteration(0, 3, 14, 34.0, 5)) + self.record.append(ForwardPassIteration(3, 6, 12, 18.0, 7)) + self.mses = [self.sst, 63.0, 34.0, 18.0] + self.sizes = [1, 3, 5, 7] + + def test_statistics(self): + mses = [self.record.mse(i) for i in range(len(self.record))] + mses_ = [self.mses[i] for i in range(len(self.record))] + gcvs = [self.record.gcv(i) for i in range(len(self.record))] + gcvs_ = [gcv(self.mses[i], self.sizes[i], self.num_samples, self.penalty) + for i in range(len(self.record))] + rsqs = [self.record.rsq(i) for i in range(len(self.record))] + rsqs_ = [1 - (self.mses[i] / self.sst) + for i in range(len(self.record))] + grsqs = [self.record.grsq(i) for i in range(len(self.record))] + grsqs_ = [1 - (self.record.gcv(i) / gcv(self.sst, 1, self.num_samples, self.penalty)) + for i in range(len(self.record))] + assert_list_equal(mses, mses_) + assert_list_equal(gcvs, gcvs_) + assert_list_equal(rsqs, rsqs_) + assert_list_equal(grsqs, grsqs_) + + +class TestPruningPassRecord(object): + + def __init__(self): + # Create a record + self.num_samples = 1000 + self.num_variables = 10 + self.penalty = 3.0 + self.sst = 100.0 + self.record = PruningPassRecord( + self.num_samples, + self.num_variables, + self.penalty, + self.sst, + 7, + 18.0) + self.record.append(PruningPassIteration(2, 6, 25.0)) + self.record.append(PruningPassIteration(1, 5, 34.0)) + self.record.append(PruningPassIteration(3, 4, 87.0)) + self.mses = [18.0, 25.0, 34.0, 87.0] + self.sizes = [7, 6, 5, 4] + + def test_statistics(self): + mses = [self.record.mse(i) for i in range(len(self.record))] + mses_ = [self.mses[i] for i in range(len(self.record))] + gcvs = [self.record.gcv(i) for i in range(len(self.record))] + gcvs_ = [gcv(self.mses[i], self.sizes[i], self.num_samples, self.penalty) + for i in range(len(self.record))] + rsqs = [self.record.rsq(i) for i in range(len(self.record))] + rsqs_ = [1 - (self.mses[i] / self.sst) + for i in range(len(self.record))] + grsqs = [self.record.grsq(i) for i in range(len(self.record))] + grsqs_ = [1 - (self.record.gcv(i) / gcv(self.sst, 1, self.num_samples, self.penalty)) + for i in range(len(self.record))] + assert_list_equal(mses, mses_) + assert_list_equal(gcvs, gcvs_) + assert_list_equal(rsqs, rsqs_) + assert_list_equal(grsqs, grsqs_) + +if __name__ == '__main__': + import nose + nose.run(argv=[__file__, '-s', '-v']) diff --git a/sklearn/earth/tests/test_util.py b/sklearn/earth/tests/test_util.py new file mode 100644 index 0000000000000..5faa884ba34a3 --- /dev/null +++ b/sklearn/earth/tests/test_util.py @@ -0,0 +1,13 @@ + + +class TestUtil(object): + + def __init__(self): + pass + + def test(self): + pass + +if __name__ == '__main__': + import nose + nose.run(argv=[__file__, '-s', '-v']) diff --git a/sklearn/earth/tests/testing_utils.py b/sklearn/earth/tests/testing_utils.py new file mode 100644 index 0000000000000..b9cd880a03e0c --- /dev/null +++ b/sklearn/earth/tests/testing_utils.py @@ -0,0 +1,44 @@ +from functools import wraps +from nose import SkipTest + + +def if_statsmodels(func): + """Test decorator that skips test if statsmodels not installed. """ + + @wraps(func) + def run_test(*args, **kwargs): + try: + import statsmodels + except ImportError: + raise SkipTest('statsmodels not available.') + else: + return func(*args, **kwargs) + return run_test + + +def if_pandas(func): + """Test decorator that skips test if pandas not installed. """ + + @wraps(func) + def run_test(*args, **kwargs): + try: + import pandas + except ImportError: + raise SkipTest('pandas not available.') + else: + return func(*args, **kwargs) + return run_test + + +def if_patsy(func): + """Test decorator that skips test if patsy not installed. """ + + @wraps(func) + def run_test(*args, **kwargs): + try: + import patsy + except ImportError: + raise SkipTest('patsy not available.') + else: + return func(*args, **kwargs) + return run_test diff --git a/sklearn/setup.py b/sklearn/setup.py index 58e33295f65e6..c5e5895616e22 100644 --- a/sklearn/setup.py +++ b/sklearn/setup.py @@ -51,6 +51,8 @@ def configuration(parent_package='', top_path=None): config.add_subpackage('metrics/tests') config.add_subpackage('metrics/cluster') config.add_subpackage('metrics/cluster/tests') + config.add_subpackage('earth') + config.add_subpackage('earth/tests') config.add_subpackage('metrics/cluster/bicluster') config.add_subpackage('metrics/cluster/bicluster/tests')