From 35e12c23d4d368c73352c50b814c57a3884f9930 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort <alexandre.gramfort@inria.fr> Date: Mon, 15 Mar 2010 11:46:44 +0000 Subject: [PATCH] - bug fix in stop criterion of Elastic-Net - rewriting callback system to handle objective value computation and density. It is designed to be usable by other iteration procedures such as proximal based optimization schemes. git-svn-id: https://scikit-learn.svn.sourceforge.net/svnroot/scikit-learn/trunk@536 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8 --- examples/lasso_enet_coordinate_descent.py | 33 +- scikits/learn/linreg/cd.py | 292 +++--- scikits/learn/linreg/enet_cd.py | 41 +- scikits/learn/linreg/enet_cd_fast.c | 935 ++++++++++------- scikits/learn/linreg/enet_cd_fast.pyx | 29 +- scikits/learn/linreg/iteration_callbacks.py | 86 ++ scikits/learn/linreg/lasso_cd.py | 23 +- scikits/learn/linreg/lasso_cd_fast.c | 1043 +++++++++++-------- scikits/learn/linreg/lasso_cd_fast.pyx | 29 +- scikits/learn/linreg/tests/test_cd.py | 48 +- scikits/learn/linreg/utils.py | 86 ++ 11 files changed, 1566 insertions(+), 1079 deletions(-) create mode 100644 scikits/learn/linreg/iteration_callbacks.py create mode 100644 scikits/learn/linreg/utils.py diff --git a/examples/lasso_enet_coordinate_descent.py b/examples/lasso_enet_coordinate_descent.py index b86f001c8a..851b65a485 100644 --- a/examples/lasso_enet_coordinate_descent.py +++ b/examples/lasso_enet_coordinate_descent.py @@ -12,7 +12,10 @@ from itertools import cycle import numpy as np import pylab as pl -from scikits.learn.glm.cd import Lasso, ElasticNet, lasso_path, enet_path +from scikits.learn.linreg.cd import Lasso, ElasticNet, lasso_path, \ + enet_path, enet_dual_gap, lasso_dual_gap, \ + IterationCallbackFunc, \ + lasso_objective, enet_objective n_samples, n_features, maxit = 5, 10, 30 @@ -21,29 +24,37 @@ y = np.random.randn(n_samples) X = np.random.randn(n_samples, n_features) ################################################################################ -# Fit models +# Fit models ################################################################################ # Lasso -lasso = Lasso(alpha=1) +alpha = 1 +lasso_objective_callback = IterationCallbackFunc(lasso_objective) +lasso = Lasso(alpha=alpha, callbacks=[lasso_objective_callback]) lasso.fit(X, y, maxit=maxit) -print "Duality gap Lasso (should be small): %f" % lasso.compute_gap(X, y) +print "Duality gap Lasso (should be small): %f" % \ + lasso_dual_gap(X, y, lasso.w, alpha)[0] +lasso_objective = lasso_objective_callback.values -# Elastic-Net -enet = ElasticNet(alpha=1, beta=1) +# Elastic-Net +alpha, beta = 1, 1 +enet_objective_callback = IterationCallbackFunc(enet_objective) +enet = ElasticNet(alpha=alpha, beta=beta, callbacks=[enet_objective_callback]) enet.fit(X, y, maxit=maxit) -print "Duality gap (should be small): %f" % enet.compute_gap(X, y) +print "Duality gap (should be small): %f" % \ + enet_dual_gap(X, y, enet.w, alpha, beta)[0] +enet_objective = enet_objective_callback.values # Display results pl.figure(-1, figsize=(8, 4)) pl.clf() pl.subplots_adjust(wspace=.4, right=.95) pl.subplot(1, 2, 1) -pl.plot(lasso.objective, label='Lasso') -pl.plot(enet.objective, label='Elastic Net') +pl.plot(lasso_objective, label='Lasso') +pl.plot(enet_objective, label='Elastic Net') pl.xlabel('Iteration') pl.ylabel('Cost function') pl.legend() @@ -54,13 +65,13 @@ pl.title('Convergence') ################################################################################ alphas_lasso, weights_lasso = lasso_path(X, y, factor=0.97, n_alphas = 100) -alphas_enet, weights_enet = enet_path(X, y, factor=0.97, n_alphas = 100, +alphas_enet, weights_enet = enet_path(X, y, factor=0.97, n_alphas = 100, beta=0.1) # Display results pl.subplot(1, 2, 2) color_iter = cycle(['b', 'g', 'r', 'c', 'm', 'y', 'k']) -for color, weight_lasso, weight_enet in zip(color_iter, +for color, weight_lasso, weight_enet in zip(color_iter, weights_lasso.T, weights_enet.T): pl.plot(-np.log(alphas_lasso), weight_lasso, color) pl.plot(-np.log(alphas_enet), weight_enet, color+'x') diff --git a/scikits/learn/linreg/cd.py b/scikits/learn/linreg/cd.py index d5f8ba2413..d169464c57 100644 --- a/scikits/learn/linreg/cd.py +++ b/scikits/learn/linreg/cd.py @@ -15,7 +15,7 @@ The objective function to minimize is for the Lasso:: and for the Elastic Network:: - 0.5 * ||R||_2 ^ 2 + alpha * ||w||_1 + beta * ||w||_2 ^ 2 + 0.5 * ||R||_2 ^ 2 + alpha * ||w||_1 + beta * 0.5 * ||w||_2 ^ 2 Where R are the residuals between the output of the model and the expected value and w is the vector of weights to fit. @@ -25,6 +25,9 @@ import numpy as np import scipy.linalg as linalg from lasso_cd import lasso_coordinate_descent as lasso_coordinate_descent_slow from enet_cd import enet_coordinate_descent as enet_coordinate_descent_slow +from iteration_callbacks import IterationCallbackMaxit, IterationCallbackFunc +from utils import enet_dual_gap, lasso_dual_gap, lasso_objective, \ + enet_objective, density # Attempt to improve speed with cython try: @@ -39,83 +42,39 @@ except ImportError: enet_coordinate_descent = enet_coordinate_descent_slow print "Using Python version of coordinate descent" -def enet_dual_gap(X, y, w, alpha, beta=0): - """Compute dual gap for Elastic-Net model to check KKT optimality conditions - - Returns - ------- - gap : the difference primal_objective - dual_objective (should be positive) - A value less that 1e-5 means convergence in practice - primal_objective : the value of the objective function of the primal problem - dual_objective : the value of the objective function of the dual problem - - """ - Xw = np.dot(X, w) - A = (y - Xw) - if beta > 0: - B = - np.sqrt(beta) * w - XtA = np.dot(X.T, A) - if beta > 0: - XtA += np.sqrt(beta) * B - dual_norm_XtA = np.max(XtA) - if (dual_norm_XtA > alpha): - A *= alpha / dual_norm_XtA - if beta > 0: - B *= alpha / dual_norm_XtA - pobj = 0.5 * linalg.norm(y - Xw)**2 + alpha * np.abs(w).sum() \ - + 0.5 * beta * linalg.norm(w)**2 - dobj = - 0.5 * linalg.norm(A)**2 + np.dot(A.T, y) - if beta > 0: - dobj += - 0.5 * linalg.norm(B)**2 - gap = pobj - dobj - return gap, pobj, dobj - - -class BaseIterationCallback(object): - """Base callback to be called at the end of each iteration of CD - - - record the value of the current objective cost - - record the density of the model - - record and check the duality gap for early stop of the optim - (before maxiter) - - To be subclassed if more monitoring is required. - """ +class LinearModel(object): + """Base class for Linear Model optimized with coordinate descent""" - def __init__(self, linear_model, gap_tolerance=1e-4): - self.linear_model = linear_model - self.gap_tolerance = gap_tolerance + def __init__(self, w0=None, callbacks=None): + # weights of the model (can be lazily initialized by the ``fit`` method) + self.w = w0 - def __call__(self, X, y, R, alpha, w, iter): - # TODO: check the last time stamp to avoid computing the stats too often - lm = self.linear_model - lm.compute_objective(X, y, R, record=True) - lm.compute_density(record=True) - gap = lm.compute_gap(X, y, record=True) + # callbacks that handles recording of the historic data + # and can stop iterations + self.callbacks = [] + if callbacks is not None: + for callback in callbacks: + self.callbacks.append(callback) - # should go on? - if len(lm.gap) > 1 and lm.gap[-1] > lm.gap[-2]: - # if the gap increases it means that it means we reached convergence - # this is a consequence of the way we compute dual_objective - return False - return gap > self.gap_tolerance + self.learner = None + self.dual_gap_func = None + def fit(self, X, y, maxit=100, tol=1e-4): + """Fit Lasso model with coordinate descent""" + X, y = np.asanyarray(X), np.asanyarray(y) + n_samples, n_features = X.shape -class LinearModel(object): - """Base class for Linear Model optimized with coordinate descent""" + if tol is not None: + cb_dual_gap = IterationCallbackFunc(self.dual_gap_func, tol=tol) + self.callbacks.append(cb_dual_gap) - def __init__(self, w0=None): - # weights of the model (can be lazily initialized by the ``fit`` method) - self.w = w0 + if self.w is None: + self.w = np.zeros(n_features) - # recorded historic data at each training iteration, suitable for - # plotting and monitoring of the convergence - self.objective = [] - self.gap = [] - self.density = [] + self.w = self.learner(self, X, y, maxit) - # callback that handles recording of the historic data - self.callback = BaseIterationCallback(self) + # return self for chaining fit and predict calls + return self def predict(self, X): """Linear model prediction: compute the dot product with the weights""" @@ -123,113 +82,48 @@ class LinearModel(object): y = np.dot(X, self.w) return y - def compute_density(self, record=False): + def compute_density(self): """Ratio of non-zero weights in the model""" - d = 0 if self.w is None else float((self.w != 0).sum()) / self.w.size - if record: - self.density.append(d) - return d - + return density(self.w) class Lasso(LinearModel): """Linear Model trained with L1 prior as regularizer (a.k.a. the Lasso)""" - def __init__(self, alpha=1.0, w0=None): - super(Lasso, self).__init__(w0) + def __init__(self, alpha=1.0, w0=None, callbacks=None): + super(Lasso, self).__init__(w0, callbacks) self.alpha = alpha self.learner = lasso_coordinate_descent + self.dual_gap_func = lambda X, y, w, **kw: lasso_dual_gap(X, y, w, kw['alpha'])[0] def __repr__(self): - return "Lasso cd" - - def fit(self, X, y, maxit=10): - """Fit Lasso model with coordinate descent""" - X, y = np.asanyarray(X), np.asanyarray(y) - nsamples, nfeatures = X.shape - - if self.w is None: - self.w = np.zeros(nfeatures) - - self.w = self.learner(X, y, self.alpha, self.w, maxit=maxit, - callback=self.callback) - - # return self for chaining fit and predict calls - return self - - def compute_gap(self, X, y, record=False): - """Evaluate the duality gap of the current state of the model""" - gap, _, _ = enet_dual_gap(X, y, self.w, self.alpha, beta=0) - if record: - self.gap.append(gap) - return gap - - def compute_objective(self, X, y, R=None, record=False): - """Evaluate the cost function to minimize""" - if R is None: - R = y - np.dot(X, self.w) - cost = 0.5 * linalg.norm(R) ** 2 + self.alpha * np.abs(self.w).sum() - if record: - self.objective.append(cost) - return cost - + return "Lasso cd" class ElasticNet(LinearModel): """Linear Model trained with L1 and L2 prior as regularizer""" - def __init__(self, alpha=1.0, beta=1.0, w0=None): - super(ElasticNet, self).__init__(w0) + def __init__(self, alpha=1.0, beta=1.0, w0=None, callbacks=None): + super(ElasticNet, self).__init__(w0, callbacks) self.alpha = alpha self.beta = beta self.learner = enet_coordinate_descent + self.dual_gap_func = lambda X, y, w, **kw: enet_dual_gap(X, y, w, kw['alpha'], + kw['beta'])[0] def __repr__(self): - return "ElasticNet cd" - - def fit(self, X, y, maxit=10): - """Fit Elastic Net model with coordinate descent""" - X, y = np.asanyarray(X), np.asanyarray(y) - nsamples, nfeatures = X.shape - - if self.w is None: - self.w = np.zeros(nfeatures) - - self.w = self.learner(X, y, self.alpha, self.beta, self.w, maxit=maxit, - callback=self.callback) + return "ElasticNet cd" - # return self for chaining fit and predict calls - return self - def compute_gap(self, X, y, record=False): - gap, _, _ = enet_dual_gap(X, y, self.w, self.alpha, self.beta) - if record: - self.gap.append(gap) - return gap - - def compute_objective(self, X, y, R=None, record=False): - """Evaluate the cost function to minimize""" - if R is None: - nsamples, nfeatures = X.shape - R = np.empty(nfeatures + nsamples) - R[:nsamples] = y - np.dot(X, self.w) - R[nsamples:] = - sqrt(self.beta) * self.w - cost = 0.5 * linalg.norm(R) ** 2 + self.alpha * np.abs(self.w).sum() + \ - 0.5 * self.beta * linalg.norm(self.w) ** 2 - if record: - self.objective.append(cost) - return cost - - -def lasso_path(X, y, factor=0.95, n_alphas = 10): +def lasso_path(X, y, factor=0.95, n_alphas = 10, **kwargs): """Compute Lasso path with coordinate descent""" - alpha_max = np.dot(X.T, y).max() + alpha_max = np.abs(np.dot(X.T, y)).max() alpha = alpha_max model = Lasso(alpha=alpha) weights = [] alphas = [] for _ in range(n_alphas): model.alpha *= factor - model.fit(X, y) + model.fit(X, y, **kwargs) alphas.append(model.alpha) weights.append(model.w.copy()) @@ -238,16 +132,16 @@ def lasso_path(X, y, factor=0.95, n_alphas = 10): weights = np.asarray(weights) return alphas, weights -def enet_path(X, y, factor=0.95, n_alphas = 10, beta=1.0): +def enet_path(X, y, factor=0.95, n_alphas=10, beta=1.0, **kwargs): """Compute Elastic-Net path with coordinate descent""" - alpha_max = np.dot(X.T, y).max() + alpha_max = np.abs(np.dot(X.T, y)).max() alpha = alpha_max model = ElasticNet(alpha=alpha, beta=beta) weights = [] alphas = [] for _ in range(n_alphas): model.alpha *= factor - model.fit(X, y) + model.fit(X, y, **kwargs) alphas.append(model.alpha) weights.append(model.w.copy()) @@ -257,40 +151,66 @@ def enet_path(X, y, factor=0.95, n_alphas = 10, beta=1.0): return alphas, weights if __name__ == '__main__': - N, P, maxit = 5, 10, 30 + import time + import pylab as pl + + n_samples, n_features, maxit = 5, 10, 30 np.random.seed(0) - y = np.random.randn(N) - X = np.random.randn(N, P) + y = np.random.randn(n_samples) + X = np.random.randn(n_samples, n_features) """Tests Lasso implementations (python and cython) """ alpha = 1.0 - import time + tol = 1e-5 + + # Callbacks to store objective values and densities + callback_objective = IterationCallbackFunc(lasso_objective) + callback_density = IterationCallbackFunc(density) + t0 = time.time() - lasso_slow = Lasso(alpha=alpha) + lasso_slow = Lasso(alpha=alpha, callbacks=[callback_objective, + callback_density]) lasso_slow.learner = lasso_coordinate_descent_slow - lasso_slow.fit(X, y, maxit=maxit) + lasso_slow.fit(X, y, maxit=maxit, tol=tol) print time.time() - t0 + objective_convergence_slow = callback_objective.values + density_slow = callback_density.values + + print "Duality gap Lasso (should be small): %f" % \ + lasso_dual_gap(X, y, lasso_slow.w, alpha)[0] + t0 = time.time() - lasso_fast = Lasso(alpha=alpha) + lasso_fast = Lasso(alpha=alpha, callbacks=[callback_objective, + callback_density]) lasso_fast.learner = lasso_coordinate_descent_fast - lasso_fast.fit(X, y, maxit=maxit) + lasso_fast.fit(X, y, maxit=maxit, tol=tol) print time.time() - t0 - print "Duality gap Lasso (should be small): %f" % lasso_fast.gap[-1] + print "Duality gap Lasso (should be small): %f" % \ + lasso_dual_gap(X, y, lasso_slow.w, alpha)[0] + + objective_convergence_fast = callback_objective.values + density_fast = callback_density.values - import pylab as pl pl.close('all') - pl.plot(lasso_fast.objective,"rx-") - pl.plot(lasso_slow.objective,"bo--") + pl.plot(objective_convergence_fast,"rx-") + pl.plot(objective_convergence_slow,"bo--") pl.xlabel('Iteration') pl.ylabel('Cost function') - pl.legend(['Slow', 'Fast']) + pl.legend(['Fast', 'Slow']) + pl.title('Lasso') + + pl.figure() + pl.plot(density_fast,"rx-") + pl.plot(density_slow,"bo--") + pl.xlabel('Iteration') + pl.ylabel('Density') + pl.legend(['Fast', 'Slow']) pl.title('Lasso') - pl.show() """Tests Elastic-Net implementations (python and cython) """ @@ -298,35 +218,57 @@ if __name__ == '__main__': alpha = 1.0 beta = 1.0 + callback_objective = IterationCallbackFunc(enet_objective) + import time t0 = time.time() - enet_slow = ElasticNet(alpha=alpha, beta=beta) + enet_slow = ElasticNet(alpha=alpha, beta=beta, callbacks=[callback_objective, + callback_density]) enet_slow.learner = enet_coordinate_descent_slow enet_slow.fit(X, y, maxit=maxit) print time.time() - t0 + print "Duality gap (should be small): %f" % \ + enet_dual_gap(X, y, enet_slow.w, alpha)[0] + + objective_convergence_slow = callback_objective.values + density_slow = callback_density.values + t0 = time.time() - enet_fast = ElasticNet(alpha=alpha, beta=beta) + enet_fast = ElasticNet(alpha=alpha, beta=beta, callbacks=[callback_objective, + callback_density]) + enet_fast.learner = enet_coordinate_descent_fast enet_fast.fit(X, y, maxit=maxit) print time.time() - t0 - print "Duality gap (should be small): %f" % enet_fast.gap[-1] + print "Duality gap (should be small): %f" % \ + enet_dual_gap(X, y, enet_fast.w, alpha)[0] + + objective_convergence_fast = callback_objective.values + density_fast = callback_density.values pl.figure() - pl.plot(enet_fast.objective,"rx-") - pl.plot(enet_slow.objective,"bo--") + pl.plot(objective_convergence_fast,"rx-") + pl.plot(objective_convergence_slow,"bo--") pl.xlabel('Iteration') pl.ylabel('Cost function') - pl.legend(['Slow', 'Fast']) + pl.legend(['Fast', 'Slow']) + pl.title('Elastic-Net') + + pl.figure() + pl.plot(density_fast,"rx-") + pl.plot(density_slow,"bo--") + pl.xlabel('Iteration') + pl.ylabel('Density') + pl.legend(['Fast', 'Slow']) pl.title('Elastic-Net') - pl.show() """Test path functions """ - alphas_lasso, weights_lasso = lasso_path(X, y, factor=0.97, n_alphas = 100) - alphas_enet, weights_enet = enet_path(X, y, factor=0.97, n_alphas = 100, beta=0.1) + alphas_lasso, weights_lasso = lasso_path(X, y, factor=0.97, n_alphas = 100, tol=1-2) + alphas_enet, weights_enet = enet_path(X, y, factor=0.97, n_alphas = 100, beta=0.1, tol=1-2) from itertools import cycle color_iter = cycle(['b', 'g', 'r', 'c', 'm', 'y', 'k']) diff --git a/scikits/learn/linreg/enet_cd.py b/scikits/learn/linreg/enet_cd.py index 3dac73edaf..68280335c9 100644 --- a/scikits/learn/linreg/enet_cd.py +++ b/scikits/learn/linreg/enet_cd.py @@ -7,29 +7,42 @@ from math import sqrt import numpy as np import scipy.linalg as linalg -def enet_coordinate_descent(X, y, alpha, beta, w, maxit=10, callback=None): +def enet_coordinate_descent(model, X, y, maxit): """coordinate descent for Elastic-Net model""" norm_cols_X = np.sum(X ** 2, axis=0) # Compute norms of the columns of X - nsamples, nfeatures = X.shape + n_samples, n_features = X.shape + + alpha = model.alpha + beta = model.beta + callbacks = model.callbacks + w = model.w # Init residual - R = np.empty(nfeatures + nsamples) - R[:nsamples] = y - np.dot(X,w) - R[nsamples:] = - sqrt(beta) * w + R = np.empty(n_features + n_samples) + R[:n_samples] = y - np.dot(X,w) + R[n_samples:] = - sqrt(beta) * w + + for callback in callbacks: + callback(0) # Init callback - for iter in xrange(maxit): - for ii in xrange(nfeatures): # Loop over coordinates + goon = True + for n_iter in range(maxit): + for ii in xrange(n_features): # Loop over coordinates w_ii = w[ii] # Store previous value - R[:nsamples] += w_ii * X[:, ii] - R[nsamples + ii] += w_ii * sqrt(beta) - tmp = (X[:, ii] * R[:nsamples]).sum() - tmp += sqrt(beta) * R[nsamples + ii] + R[:n_samples] += w_ii * X[:, ii] + R[n_samples + ii] += w_ii * sqrt(beta) + tmp = (X[:, ii] * R[:n_samples]).sum() + tmp += sqrt(beta) * R[n_samples + ii] w[ii] = np.sign(tmp) * np.maximum(abs(tmp) - alpha, 0) \ / (norm_cols_X[ii] + beta) - R[:nsamples] -= w[ii] * X[:, ii] # Update residual - R[nsamples + ii] -= w[ii] * sqrt(beta) + R[:n_samples] -= w[ii] * X[:, ii] # Update residual + R[n_samples + ii] -= w[ii] * sqrt(beta) + + for callback in callbacks: + if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, beta=beta, R=R): + goon *= False - if (callback is not None and not callback(X, y, R, alpha, w, iter)): + if not goon: break return w diff --git a/scikits/learn/linreg/enet_cd_fast.c b/scikits/learn/linreg/enet_cd_fast.c index 2b2217fa06..97b0889a77 100644 --- a/scikits/learn/linreg/enet_cd_fast.c +++ b/scikits/learn/linreg/enet_cd_fast.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.11.2 on Thu Mar 4 17:19:27 2010 */ +/* Generated by Cython 0.11.2 on Mon Mar 15 12:34:39 2010 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -131,11 +131,10 @@ #define __PYX_EXTERN_C extern #endif #include <math.h> -#define __PYX_HAVE_API__scikits__learn__glm__enet_cd_fast +#define __PYX_HAVE_API__scikits__learn__linreg__enet_cd_fast #include "stdlib.h" #include "numpy/arrayobject.h" #include "math.h" -#include "time.h" #define __PYX_USE_C99_COMPLEX defined(_Complex_I) @@ -694,7 +693,7 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; typedef npy_cdouble __pyx_t_5numpy_complex_t; -typedef __pyx_t_5numpy_float64_t __pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE; +typedef __pyx_t_5numpy_float64_t __pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE; /* Module declarations from python_buffer */ /* Module declarations from stdlib */ @@ -708,32 +707,26 @@ static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from cython */ -/* Module declarations from scikits.learn.glm.enet_cd_fast */ +/* Module declarations from scikits.learn.linreg.enet_cd_fast */ -static INLINE double __pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(double); /*proto*/ -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE = { "scikits.learn.glm.enet_cd_fast.DOUBLE", NULL, sizeof(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE), 'R' }; -#define __Pyx_MODULE_NAME "scikits.learn.glm.enet_cd_fast" -int __pyx_module_is_main_scikits__learn__glm__enet_cd_fast = 0; +static INLINE double __pyx_f_7scikits_5learn_6linreg_12enet_cd_fast_fsign(double); /*proto*/ +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE = { "scikits.learn.linreg.enet_cd_fast.DOUBLE", NULL, sizeof(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE), 'R' }; +#define __Pyx_MODULE_NAME "scikits.learn.linreg.enet_cd_fast" +int __pyx_module_is_main_scikits__learn__linreg__enet_cd_fast = 0; -/* Implementation of scikits.learn.glm.enet_cd_fast */ +/* Implementation of scikits.learn.linreg.enet_cd_fast */ static PyObject *__pyx_int_2; static PyObject *__pyx_int_0; static char __pyx_k___main__[] = "__main__"; static PyObject *__pyx_kp___main__; +static char __pyx_k_model[] = "model"; +static PyObject *__pyx_kp_model; static char __pyx_k_X[] = "X"; static PyObject *__pyx_kp_X; static char __pyx_k_y[] = "y"; static PyObject *__pyx_kp_y; -static char __pyx_k_alpha[] = "alpha"; -static PyObject *__pyx_kp_alpha; -static char __pyx_k_beta[] = "beta"; -static PyObject *__pyx_kp_beta; -static char __pyx_k_w[] = "w"; -static PyObject *__pyx_kp_w; static char __pyx_k_maxit[] = "maxit"; static PyObject *__pyx_kp_maxit; -static char __pyx_k_callback[] = "callback"; -static PyObject *__pyx_kp_callback; static char __pyx_k_numpy[] = "numpy"; static PyObject *__pyx_kp_numpy; static char __pyx_k_np[] = "np"; @@ -744,6 +737,14 @@ static char __pyx_k_32[] = "*"; static PyObject *__pyx_kp_32; static char __pyx_k_linalg[] = "linalg"; static PyObject *__pyx_kp_linalg; +static char __pyx_k_alpha[] = "alpha"; +static PyObject *__pyx_kp_alpha; +static char __pyx_k_beta[] = "beta"; +static PyObject *__pyx_kp_beta; +static char __pyx_k_w[] = "w"; +static PyObject *__pyx_kp_w; +static char __pyx_k_callbacks[] = "callbacks"; +static PyObject *__pyx_kp_callbacks; static char __pyx_k_sum[] = "sum"; static PyObject *__pyx_kp_sum; static char __pyx_k_axis[] = "axis"; @@ -752,12 +753,14 @@ static char __pyx_k_empty[] = "empty"; static PyObject *__pyx_kp_empty; static char __pyx_k_dot[] = "dot"; static PyObject *__pyx_kp_dot; -static char __pyx_k_xrange[] = "xrange"; -static PyObject *__pyx_kp_xrange; static char __pyx_k_range[] = "range"; static PyObject *__pyx_kp_range; -static PyObject *__pyx_builtin_xrange; +static char __pyx_k_xrange[] = "xrange"; +static PyObject *__pyx_kp_xrange; +static char __pyx_k_R[] = "R"; +static PyObject *__pyx_kp_R; static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_xrange; static PyObject *__pyx_int_15; static char __pyx_k___getbuffer__[] = "__getbuffer__"; static PyObject *__pyx_kp___getbuffer__; @@ -814,20 +817,20 @@ static char __pyx_k_28[] = "Non-native byte order not supported"; static char __pyx_k_29[] = "Format string allocated too short."; static char __pyx_k_30[] = "unknown dtype code in numpy.pxd (%d)"; -/* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":22 - * time_t time(time_t *) +/* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":18 + * double rand() * * cdef inline double fsign(double f): # <<<<<<<<<<<<<< * if f == 0: * return 0 */ -static INLINE double __pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(double __pyx_v_f) { +static INLINE double __pyx_f_7scikits_5learn_6linreg_12enet_cd_fast_fsign(double __pyx_v_f) { double __pyx_r; int __pyx_t_1; __Pyx_SetupRefcountContext("fsign"); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":23 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":19 * * cdef inline double fsign(double f): * if f == 0: # <<<<<<<<<<<<<< @@ -837,7 +840,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(double __ __pyx_t_1 = (__pyx_v_f == 0); if (__pyx_t_1) { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":24 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":20 * cdef inline double fsign(double f): * if f == 0: * return 0 # <<<<<<<<<<<<<< @@ -849,7 +852,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(double __ goto __pyx_L3; } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":25 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":21 * if f == 0: * return 0 * elif f > 0: # <<<<<<<<<<<<<< @@ -859,7 +862,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(double __ __pyx_t_1 = (__pyx_v_f > 0); if (__pyx_t_1) { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":26 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":22 * return 0 * elif f > 0: * return 1.0 # <<<<<<<<<<<<<< @@ -872,7 +875,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(double __ } /*else*/ { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":28 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":24 * return 1.0 * else: * return -1.0 # <<<<<<<<<<<<<< @@ -890,24 +893,25 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(double __ return __pyx_r; } -/* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":34 +/* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":30 * @cython.boundscheck(False) * @cython.wraparound(False) - * def enet_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, # <<<<<<<<<<<<<< + * def enet_coordinate_descent(model, # <<<<<<<<<<<<<< + * np.ndarray[DOUBLE, ndim=2] X, * np.ndarray[DOUBLE, ndim=1] y, - * float alpha, */ -static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_descent[] = "Cython version of the coordinate descent algorithm\n for Elastic-Net regression\n "; -static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pf_7scikits_5learn_6linreg_12enet_cd_fast_enet_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7scikits_5learn_6linreg_12enet_cd_fast_enet_coordinate_descent[] = "Cython version of the coordinate descent algorithm\n for Elastic-Net regression\n "; +static PyObject *__pyx_pf_7scikits_5learn_6linreg_12enet_cd_fast_enet_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_model = 0; PyArrayObject *__pyx_v_X = 0; PyArrayObject *__pyx_v_y = 0; + unsigned int __pyx_v_maxit; float __pyx_v_alpha; float __pyx_v_beta; PyArrayObject *__pyx_v_w = 0; - int __pyx_v_maxit; - PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_callbacks; unsigned int __pyx_v_nsamples; unsigned int __pyx_v_nfeatures; unsigned int __pyx_v_nclasses; @@ -917,7 +921,9 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de float __pyx_v_w_ii; unsigned int __pyx_v_ii; unsigned int __pyx_v_jj; - unsigned int __pyx_v_iter; + unsigned int __pyx_v_n_iter; + PyObject *__pyx_v_callback; + PyObject *__pyx_v_goon; Py_buffer __pyx_bstruct_norm_cols_X; Py_ssize_t __pyx_bstride_0_norm_cols_X = 0; Py_ssize_t __pyx_bshape_0_norm_cols_X = 0; @@ -938,13 +944,13 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de PyObject *__pyx_r = NULL; PyObject *__pyx_1 = 0; PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + float __pyx_t_2; PyArrayObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyArrayObject *__pyx_t_5 = NULL; - unsigned int __pyx_t_6; - unsigned int __pyx_t_7; - unsigned int __pyx_t_8; + PyObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; unsigned int __pyx_t_9; unsigned int __pyx_t_10; unsigned int __pyx_t_11; @@ -960,20 +966,18 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de unsigned int __pyx_t_21; unsigned int __pyx_t_22; unsigned int __pyx_t_23; - int __pyx_t_24; - int __pyx_t_25; - int __pyx_t_26; - static PyObject **__pyx_pyargnames[] = {&__pyx_kp_X,&__pyx_kp_y,&__pyx_kp_alpha,&__pyx_kp_beta,&__pyx_kp_w,&__pyx_kp_maxit,&__pyx_kp_callback,0}; + unsigned int __pyx_t_24; + unsigned int __pyx_t_25; + unsigned int __pyx_t_26; + int __pyx_t_27; + int __pyx_t_28; + static PyObject **__pyx_pyargnames[] = {&__pyx_kp_model,&__pyx_kp_X,&__pyx_kp_y,&__pyx_kp_maxit,0}; __Pyx_SetupRefcountContext("enet_coordinate_descent"); __pyx_self = __pyx_self; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - PyObject* values[7] = {0,0,0,0,0,0,0}; - values[6] = Py_None; + PyObject* values[4] = {0,0,0,0}; switch (PyTuple_GET_SIZE(__pyx_args)) { - 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); @@ -983,121 +987,147 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de } switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_X); + values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_model); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_y); + values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_X); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 0, 5, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: - values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_alpha); + values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_y); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 0, 5, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: - values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_beta); + values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_maxit); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 0, 5, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 4: - values[4] = PyDict_GetItem(__pyx_kwds, __pyx_kp_w); - if (likely(values[4])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 0, 5, 7, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 5: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_maxit); - if (unlikely(value)) { values[5] = value; kw_args--; } - } - case 6: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback); - if (unlikely(value)) { values[6] = value; kw_args--; } + __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 1, 4, 4, 3); {__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, PyTuple_GET_SIZE(__pyx_args), "enet_coordinate_descent") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "enet_coordinate_descent") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - __pyx_v_X = ((PyArrayObject *)values[0]); - __pyx_v_y = ((PyArrayObject *)values[1]); - __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[2]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_beta = __pyx_PyFloat_AsDouble(values[3]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_w = ((PyArrayObject *)values[4]); - if (values[5]) { - __pyx_v_maxit = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_maxit == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_maxit = 10; - } - __pyx_v_callback = values[6]; + __pyx_v_model = values[0]; + __pyx_v_X = ((PyArrayObject *)values[1]); + __pyx_v_y = ((PyArrayObject *)values[2]); + __pyx_v_maxit = __Pyx_PyInt_AsUnsignedInt(values[3]); if (unlikely((__pyx_v_maxit == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; } else { - __pyx_v_maxit = 10; - __pyx_v_callback = Py_None; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 7: - __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 6); - case 6: - __pyx_v_maxit = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_maxit == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 5: - __pyx_v_w = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4)); - __pyx_v_beta = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_alpha = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_y = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1)); - __pyx_v_X = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0)); - break; - default: goto __pyx_L5_argtuple_error; - } + __pyx_v_model = PyTuple_GET_ITEM(__pyx_args, 0); + __pyx_v_X = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1)); + __pyx_v_y = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2)); + __pyx_v_maxit = __Pyx_PyInt_AsUnsignedInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_maxit == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("enet_coordinate_descent", 1, 4, 4, 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("scikits.learn.glm.enet_cd_fast.enet_coordinate_descent"); + __Pyx_AddTraceback("scikits.learn.linreg.enet_cd_fast.enet_coordinate_descent"); return NULL; __pyx_L4_argument_unpacking_done:; + __pyx_v_callbacks = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_callback = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_goon = Py_None; __Pyx_INCREF(Py_None); + __pyx_bstruct_w.buf = NULL; __pyx_bstruct_norm_cols_X.buf = NULL; __pyx_bstruct_R.buf = NULL; __pyx_bstruct_X.buf = NULL; __pyx_bstruct_y.buf = NULL; - __pyx_bstruct_w.buf = NULL; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_5numpy_ndarray, 1, "w", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __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 = 31; __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 = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_X = __pyx_bstruct_X.strides[0]; __pyx_bstride_1_X = __pyx_bstruct_X.strides[1]; __pyx_bshape_0_X = __pyx_bstruct_X.shape[0]; __pyx_bshape_1_X = __pyx_bstruct_X.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE, 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_bstride_0_y = __pyx_bstruct_y.strides[0]; __pyx_bshape_0_y = __pyx_bstruct_y.shape[0]; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":39 + * + * # get the data information into easy vars + * cdef float alpha = model.alpha # <<<<<<<<<<<<<< + * cdef float beta = model.beta + * cdef np.ndarray[DOUBLE, ndim=1] w = model.w + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_model, __pyx_kp_alpha); 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_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_alpha = __pyx_t_2; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":40 + * # get the data information into easy vars + * cdef float alpha = model.alpha + * cdef float beta = model.beta # <<<<<<<<<<<<<< + * cdef np.ndarray[DOUBLE, ndim=1] w = model.w + * callbacks = model.callbacks + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_model, __pyx_kp_beta); 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_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_beta = __pyx_t_2; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":41 + * cdef float alpha = model.alpha + * cdef float beta = model.beta + * cdef np.ndarray[DOUBLE, ndim=1] w = model.w # <<<<<<<<<<<<<< + * callbacks = model.callbacks + * + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_model, __pyx_kp_w); 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); + if (!(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_v_w, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_w = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_w.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_bstride_0_w = __pyx_bstruct_w.strides[0]; + __pyx_bshape_0_w = __pyx_bstruct_w.shape[0]; + } } - __pyx_bstride_0_w = __pyx_bstruct_w.strides[0]; - __pyx_bshape_0_w = __pyx_bstruct_w.shape[0]; + __pyx_t_3 = 0; + __pyx_v_w = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":46 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":42 + * cdef float beta = model.beta + * cdef np.ndarray[DOUBLE, ndim=1] w = model.w + * callbacks = model.callbacks # <<<<<<<<<<<<<< + * + * cdef unsigned int nsamples = X.shape[0] + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_model, __pyx_kp_callbacks); 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_DECREF(__pyx_v_callbacks); + __pyx_v_callbacks = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":44 + * callbacks = model.callbacks * - * # get the data information into easy vars * cdef unsigned int nsamples = X.shape[0] # <<<<<<<<<<<<<< * cdef unsigned int nfeatures = X.shape[1] * cdef unsigned int nclasses = w.shape[1] */ __pyx_v_nsamples = (__pyx_v_X->dimensions[0]); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":47 - * # get the data information into easy vars + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":45 + * * cdef unsigned int nsamples = X.shape[0] * cdef unsigned int nfeatures = X.shape[1] # <<<<<<<<<<<<<< * cdef unsigned int nclasses = w.shape[1] @@ -1105,7 +1135,7 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de */ __pyx_v_nfeatures = (__pyx_v_X->dimensions[1]); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":48 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":46 * cdef unsigned int nsamples = X.shape[0] * cdef unsigned int nfeatures = X.shape[1] * cdef unsigned int nclasses = w.shape[1] # <<<<<<<<<<<<<< @@ -1114,187 +1144,251 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de */ __pyx_v_nclasses = (__pyx_v_w->dimensions[1]); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":51 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":49 * * # compute norms of the columns of X * cdef np.ndarray[DOUBLE, ndim=1] norm_cols_X = (X**2).sum(axis=0) # <<<<<<<<<<<<<< * * # initial value of the residuals */ - __pyx_t_1 = PyNumber_Power(((PyObject *)__pyx_v_X), __pyx_int_2, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Power(((PyObject *)__pyx_v_X), __pyx_int_2, Py_None); 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_2 = PyObject_GetAttr(__pyx_t_1, __pyx_kp_sum); 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_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_kp_sum); 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_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_1)); - if (PyDict_SetItem(__pyx_1, __pyx_kp_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_1, __pyx_kp_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_1)); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - if (!(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = ((PyArrayObject *)__pyx_t_1); + if (!(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_norm_cols_X, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_norm_cols_X, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { __pyx_v_norm_cols_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_norm_cols_X.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_bstride_0_norm_cols_X = __pyx_bstruct_norm_cols_X.strides[0]; __pyx_bshape_0_norm_cols_X = __pyx_bstruct_norm_cols_X.shape[0]; } } - __pyx_t_3 = 0; + __pyx_t_5 = 0; __pyx_v_norm_cols_X = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":54 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":52 * * # initial value of the residuals * cdef np.ndarray[DOUBLE, ndim=1] R = np.empty(nfeatures + nsamples) # <<<<<<<<<<<<<< * R[:nsamples] = y - np.dot(X, w) * R[nsamples:] = - sqrt(beta) * w */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_1); - __pyx_t_1 = PyObject_GetAttr(__pyx_1, __pyx_kp_empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_1, __pyx_kp_empty); 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_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_t_2 = PyLong_FromUnsignedLong((__pyx_v_nfeatures + __pyx_v_nsamples)); 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_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); 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_4 = PyLong_FromUnsignedLong((__pyx_v_nfeatures + __pyx_v_nsamples)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __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_4)); __pyx_t_4 = 0; - if (!(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = ((PyArrayObject *)__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + if (!(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_R, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_R, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_R = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_R.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_bstride_0_R = __pyx_bstruct_R.strides[0]; __pyx_bshape_0_R = __pyx_bstruct_R.shape[0]; } } - __pyx_t_5 = 0; - __pyx_v_R = ((PyArrayObject *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_7 = 0; + __pyx_v_R = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":55 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":53 * # initial value of the residuals * cdef np.ndarray[DOUBLE, ndim=1] R = np.empty(nfeatures + nsamples) * R[:nsamples] = y - np.dot(X, w) # <<<<<<<<<<<<<< * R[nsamples:] = - sqrt(beta) * w * */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_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_t_4 = PyObject_GetAttr(__pyx_1, __pyx_kp_dot); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); __Pyx_INCREF(((PyObject *)__pyx_v_X)); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_X)); __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); __Pyx_INCREF(((PyObject *)__pyx_v_w)); - PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_w)); + PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_w)); __Pyx_GIVEREF(((PyObject *)__pyx_v_w)); - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Subtract(((PyObject *)__pyx_v_y), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PySequence_SetSlice(((PyObject *)__pyx_v_R), 0, __pyx_v_nsamples, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__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_y), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PySequence_SetSlice(((PyObject *)__pyx_v_R), 0, __pyx_v_nsamples, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":56 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":54 * cdef np.ndarray[DOUBLE, ndim=1] R = np.empty(nfeatures + nsamples) * R[:nsamples] = y - np.dot(X, w) * R[nsamples:] = - sqrt(beta) * w # <<<<<<<<<<<<<< * * cdef float tmp */ - __pyx_t_4 = PyFloat_FromDouble((-sqrt(__pyx_v_beta))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, ((PyObject *)__pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble((-sqrt(__pyx_v_beta))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PyNumber_Multiply(__pyx_t_6, ((PyObject *)__pyx_v_w)); 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_4); __pyx_t_4 = 0; - if (PySequence_SetSlice(((PyObject *)__pyx_v_R), __pyx_v_nsamples, PY_SSIZE_T_MAX, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (PySequence_SetSlice(((PyObject *)__pyx_v_R), __pyx_v_nsamples, PY_SSIZE_T_MAX, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":63 - * cdef unsigned int jj - * cdef unsigned int iter - * for iter in xrange(maxit): # <<<<<<<<<<<<<< + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":62 + * cdef unsigned int n_iter + * + * for callback in callbacks: # <<<<<<<<<<<<<< + * callback(0) # Init callback + * + */ + if (PyList_CheckExact(__pyx_v_callbacks) || PyTuple_CheckExact(__pyx_v_callbacks)) { + __pyx_t_8 = 0; __pyx_t_1 = __pyx_v_callbacks; __Pyx_INCREF(__pyx_t_1); + } else { + __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_callbacks); 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); + } + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; + } else if (likely(PyTuple_CheckExact(__pyx_t_1))) { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; + } else { + __pyx_t_6 = PyIter_Next(__pyx_t_1); + if (!__pyx_t_6) { + if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + __Pyx_GOTREF(__pyx_t_6); + } + __Pyx_DECREF(__pyx_v_callback); + __pyx_v_callback = __pyx_t_6; + __pyx_t_6 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":63 + * + * for callback in callbacks: + * callback(0) # Init callback # <<<<<<<<<<<<<< + * + * goon = True + */ + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_t_4 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":65 + * callback(0) # Init callback + * + * goon = True # <<<<<<<<<<<<<< + * for n_iter in range(maxit): + * for ii in xrange(nfeatures): # Loop over coordinates + */ + __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_v_goon); + __pyx_v_goon = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":66 + * + * goon = True + * for n_iter in range(maxit): # <<<<<<<<<<<<<< * for ii in xrange(nfeatures): # Loop over coordinates * w_ii = w[ii] # Store previous value */ - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_v_maxit; __pyx_t_6+=1) { - __pyx_v_iter = __pyx_t_6; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_v_maxit; __pyx_t_9+=1) { + __pyx_v_n_iter = __pyx_t_9; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":64 - * cdef unsigned int iter - * for iter in xrange(maxit): + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":67 + * goon = True + * for n_iter in range(maxit): * for ii in xrange(nfeatures): # Loop over coordinates # <<<<<<<<<<<<<< * w_ii = w[ii] # Store previous value * */ - for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_v_nfeatures; __pyx_t_7+=1) { - __pyx_v_ii = __pyx_t_7; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_v_nfeatures; __pyx_t_10+=1) { + __pyx_v_ii = __pyx_t_10; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":65 - * for iter in xrange(maxit): + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":68 + * for n_iter in range(maxit): * for ii in xrange(nfeatures): # Loop over coordinates * w_ii = w[ii] # Store previous value # <<<<<<<<<<<<<< * * # R += w_ii * X[:,ii] */ - __pyx_t_8 = __pyx_v_ii; - __pyx_v_w_ii = (*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_8, __pyx_bstride_0_w)); + __pyx_t_11 = __pyx_v_ii; + __pyx_v_w_ii = (*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_11, __pyx_bstride_0_w)); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":68 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":71 * * # R += w_ii * X[:,ii] * for jj in range(nsamples): # <<<<<<<<<<<<<< * R[jj] += w_ii * X[jj,ii] * R[nsamples+ii] += w_ii * sqrt(beta) */ - for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_v_nsamples; __pyx_t_9+=1) { - __pyx_v_jj = __pyx_t_9; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_v_nsamples; __pyx_t_12+=1) { + __pyx_v_jj = __pyx_t_12; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":69 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":72 * # R += w_ii * X[:,ii] * for jj in range(nsamples): * R[jj] += w_ii * X[jj,ii] # <<<<<<<<<<<<<< * R[nsamples+ii] += w_ii * sqrt(beta) * */ - __pyx_t_10 = __pyx_v_jj; - __pyx_t_11 = __pyx_v_ii; - __pyx_t_12 = __pyx_v_jj; - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_12, __pyx_bstride_0_R) += (__pyx_v_w_ii * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_10, __pyx_bstride_0_X, __pyx_t_11, __pyx_bstride_1_X))); + __pyx_t_13 = __pyx_v_jj; + __pyx_t_14 = __pyx_v_ii; + __pyx_t_15 = __pyx_v_jj; + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_15, __pyx_bstride_0_R) += (__pyx_v_w_ii * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_13, __pyx_bstride_0_X, __pyx_t_14, __pyx_bstride_1_X))); } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":70 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":73 * for jj in range(nsamples): * R[jj] += w_ii * X[jj,ii] * R[nsamples+ii] += w_ii * sqrt(beta) # <<<<<<<<<<<<<< * * # tmp = (X[:,ii]*R).sum() */ - __pyx_t_9 = (__pyx_v_nsamples + __pyx_v_ii); - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_9, __pyx_bstride_0_R) += (__pyx_v_w_ii * sqrt(__pyx_v_beta)); + __pyx_t_12 = (__pyx_v_nsamples + __pyx_v_ii); + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_12, __pyx_bstride_0_R) += (__pyx_v_w_ii * sqrt(__pyx_v_beta)); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":73 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":76 * * # tmp = (X[:,ii]*R).sum() * tmp = 0.0 # <<<<<<<<<<<<<< @@ -1303,143 +1397,200 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de */ __pyx_v_tmp = 0.0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":74 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":77 * # tmp = (X[:,ii]*R).sum() * tmp = 0.0 * for jj in range(nsamples): # <<<<<<<<<<<<<< * tmp += R[jj] * X[jj,ii] * */ - for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_v_nsamples; __pyx_t_13+=1) { - __pyx_v_jj = __pyx_t_13; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_v_nsamples; __pyx_t_16+=1) { + __pyx_v_jj = __pyx_t_16; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":75 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":78 * tmp = 0.0 * for jj in range(nsamples): * tmp += R[jj] * X[jj,ii] # <<<<<<<<<<<<<< * * w[ii] = fsign(tmp) * fmax(fabs(tmp) - alpha, 0) \ */ - __pyx_t_14 = __pyx_v_jj; - __pyx_t_15 = __pyx_v_jj; - __pyx_t_16 = __pyx_v_ii; - __pyx_v_tmp += ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_14, __pyx_bstride_0_R)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_15, __pyx_bstride_0_X, __pyx_t_16, __pyx_bstride_1_X))); + __pyx_t_17 = __pyx_v_jj; + __pyx_t_18 = __pyx_v_jj; + __pyx_t_19 = __pyx_v_ii; + __pyx_v_tmp += ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_17, __pyx_bstride_0_R)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_18, __pyx_bstride_0_X, __pyx_t_19, __pyx_bstride_1_X))); } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":78 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":81 * * w[ii] = fsign(tmp) * fmax(fabs(tmp) - alpha, 0) \ * / (norm_cols_X[ii] + beta) # <<<<<<<<<<<<<< * * # R -= w[ii] * X[:,ii] # Update residual */ - __pyx_t_13 = __pyx_v_ii; + __pyx_t_16 = __pyx_v_ii; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":77 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":80 * tmp += R[jj] * X[jj,ii] * * w[ii] = fsign(tmp) * fmax(fabs(tmp) - alpha, 0) \ # <<<<<<<<<<<<<< * / (norm_cols_X[ii] + beta) * */ - __pyx_t_17 = __pyx_v_ii; - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_17, __pyx_bstride_0_w) = ((__pyx_f_7scikits_5learn_3glm_12enet_cd_fast_fsign(__pyx_v_tmp) * fmax((fabs(__pyx_v_tmp) - __pyx_v_alpha), 0)) / ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_norm_cols_X.buf, __pyx_t_13, __pyx_bstride_0_norm_cols_X)) + __pyx_v_beta)); + __pyx_t_20 = __pyx_v_ii; + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_20, __pyx_bstride_0_w) = ((__pyx_f_7scikits_5learn_6linreg_12enet_cd_fast_fsign(__pyx_v_tmp) * fmax((fabs(__pyx_v_tmp) - __pyx_v_alpha), 0)) / ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_norm_cols_X.buf, __pyx_t_16, __pyx_bstride_0_norm_cols_X)) + __pyx_v_beta)); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":81 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":84 * * # R -= w[ii] * X[:,ii] # Update residual * for jj in range(nsamples): # <<<<<<<<<<<<<< * R[jj] -= w[ii] * X[jj,ii] # Update residual * R[nsamples+ii] -= w[ii] * sqrt(beta) */ - for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_v_nsamples; __pyx_t_18+=1) { - __pyx_v_jj = __pyx_t_18; + for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_v_nsamples; __pyx_t_21+=1) { + __pyx_v_jj = __pyx_t_21; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":82 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":85 * # R -= w[ii] * X[:,ii] # Update residual * for jj in range(nsamples): * R[jj] -= w[ii] * X[jj,ii] # Update residual # <<<<<<<<<<<<<< * R[nsamples+ii] -= w[ii] * sqrt(beta) * */ - __pyx_t_19 = __pyx_v_ii; - __pyx_t_20 = __pyx_v_jj; - __pyx_t_21 = __pyx_v_ii; - __pyx_t_22 = __pyx_v_jj; - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_22, __pyx_bstride_0_R) -= ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_19, __pyx_bstride_0_w)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_20, __pyx_bstride_0_X, __pyx_t_21, __pyx_bstride_1_X))); + __pyx_t_22 = __pyx_v_ii; + __pyx_t_23 = __pyx_v_jj; + __pyx_t_24 = __pyx_v_ii; + __pyx_t_25 = __pyx_v_jj; + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_25, __pyx_bstride_0_R) -= ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_22, __pyx_bstride_0_w)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_23, __pyx_bstride_0_X, __pyx_t_24, __pyx_bstride_1_X))); } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":83 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":86 * for jj in range(nsamples): * R[jj] -= w[ii] * X[jj,ii] # Update residual * R[nsamples+ii] -= w[ii] * sqrt(beta) # <<<<<<<<<<<<<< * - * if (callback is not None and not callback(X, y, R, alpha, w, iter)): + * for callback in callbacks: */ - __pyx_t_18 = __pyx_v_ii; - __pyx_t_23 = (__pyx_v_nsamples + __pyx_v_ii); - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_23, __pyx_bstride_0_R) -= ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_18, __pyx_bstride_0_w)) * sqrt(__pyx_v_beta)); + __pyx_t_21 = __pyx_v_ii; + __pyx_t_26 = (__pyx_v_nsamples + __pyx_v_ii); + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_26, __pyx_bstride_0_R) -= ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_12enet_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_21, __pyx_bstride_0_w)) * sqrt(__pyx_v_beta)); } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":85 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":88 * R[nsamples+ii] -= w[ii] * sqrt(beta) * - * if (callback is not None and not callback(X, y, R, alpha, w, iter)): # <<<<<<<<<<<<<< - * break - * + * for callback in callbacks: # <<<<<<<<<<<<<< + * if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, beta=beta, R=R): + * goon *= False */ - __pyx_t_24 = (__pyx_v_callback != Py_None); - if (__pyx_t_24) { - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_alpha); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyList_CheckExact(__pyx_v_callbacks) || PyTuple_CheckExact(__pyx_v_callbacks)) { + __pyx_t_8 = 0; __pyx_t_1 = __pyx_v_callbacks; __Pyx_INCREF(__pyx_t_1); + } else { + __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_callbacks); 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_4 = PyLong_FromUnsignedLong(__pyx_v_iter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; + } else if (likely(PyTuple_CheckExact(__pyx_t_1))) { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; + } else { + __pyx_t_4 = PyIter_Next(__pyx_t_1); + if (!__pyx_t_4) { + if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_DECREF(__pyx_v_callback); + __pyx_v_callback = __pyx_t_4; + __pyx_t_4 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":89 + * + * for callback in callbacks: + * if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, beta=beta, R=R): # <<<<<<<<<<<<<< + * goon *= False + * + */ + __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_n_iter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__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_y)); - PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_y)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_y)); - __Pyx_INCREF(((PyObject *)__pyx_v_R)); - PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_R)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_R)); - PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_w)); - PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_v_w)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_w)); - PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_4); + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_1 = 0; __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_1)); + if (PyDict_SetItem(__pyx_1, __pyx_kp_X, ((PyObject *)__pyx_v_X)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_1, __pyx_kp_y, ((PyObject *)__pyx_v_y)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_1, __pyx_kp_w, ((PyObject *)__pyx_v_w)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_alpha); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_1, __pyx_kp_alpha, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_26 = (!__pyx_t_25); - } else { - __pyx_t_26 = __pyx_t_24; + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_1, __pyx_kp_beta, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PyDict_SetItem(__pyx_1, __pyx_kp_R, ((PyObject *)__pyx_v_R)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_v_callback, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; + __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_27 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_28 = (!__pyx_t_27); + if (__pyx_t_28) { + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":90 + * for callback in callbacks: + * if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, beta=beta, R=R): + * goon *= False # <<<<<<<<<<<<<< + * + * if not goon: + */ + __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_1 = PyNumber_InPlaceMultiply(__pyx_v_goon, __pyx_t_4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_v_goon); + __pyx_v_goon = __pyx_1; + __pyx_1 = 0; + goto __pyx_L20; + } + __pyx_L20:; } - if (__pyx_t_26) { + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":92 + * goon *= False + * + * if not goon: # <<<<<<<<<<<<<< + * break + * + */ + __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_v_goon); if (unlikely(__pyx_t_28 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = (!__pyx_t_28); + if (__pyx_t_27) { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":86 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":93 * - * if (callback is not None and not callback(X, y, R, alpha, w, iter)): + * if not goon: * break # <<<<<<<<<<<<<< * * return w */ - goto __pyx_L7_break; - goto __pyx_L16; + goto __pyx_L9_break; + goto __pyx_L21; } - __pyx_L16:; + __pyx_L21:; } - __pyx_L7_break:; + __pyx_L9_break:; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":88 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":95 * break * * return w # <<<<<<<<<<<<<< @@ -1454,8 +1605,8 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de __pyx_L1_error:; __Pyx_XDECREF(__pyx_1); __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __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_bstruct_norm_cols_X); @@ -1464,7 +1615,7 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("scikits.learn.glm.enet_cd_fast.enet_coordinate_descent"); + __Pyx_AddTraceback("scikits.learn.linreg.enet_cd_fast.enet_coordinate_descent"); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; @@ -1474,14 +1625,18 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_de __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_w); + __Pyx_DECREF(__pyx_v_callbacks); __Pyx_XDECREF((PyObject *)__pyx_v_norm_cols_X); __Pyx_XDECREF((PyObject *)__pyx_v_R); + __Pyx_DECREF(__pyx_v_callback); + __Pyx_DECREF(__pyx_v_goon); __Pyx_XGIVEREF(__pyx_r); __Pyx_FinishRefcountContext(); return __pyx_r; } -/* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":65 +/* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":65 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -1514,7 +1669,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":71 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":71 * # of flags * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -1523,7 +1678,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_endian_detector = 1; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":72 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":72 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -1532,7 +1687,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":74 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":74 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -1541,7 +1696,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":76 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":76 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -1551,7 +1706,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":77 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":77 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< @@ -1563,7 +1718,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":79 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":79 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< @@ -1574,7 +1729,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L5:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":81 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":81 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -1583,7 +1738,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ if (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS)) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":82 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":82 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -1596,7 +1751,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":83 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":83 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError("ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -1618,7 +1773,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L6:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":85 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":85 * raise ValueError("ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -1627,7 +1782,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ if (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS)) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":86 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":86 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -1640,7 +1795,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":87 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":87 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError("ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -1662,7 +1817,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L7:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":89 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":89 * raise ValueError("ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< @@ -1671,7 +1826,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":90 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":90 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -1680,7 +1835,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":91 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":91 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -1690,7 +1845,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_4 = __pyx_v_copy_shape; if (__pyx_t_4) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":94 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":94 * # Allocate new buffer for strides and shape info. This is allocated * # as one block, strides first. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< @@ -1699,7 +1854,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * __pyx_v_ndim) * 2))); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":95 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":95 * # as one block, strides first. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -1708,7 +1863,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":96 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":96 * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -1718,7 +1873,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_v_ndim; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":97 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":97 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -1727,7 +1882,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":98 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":98 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -1740,7 +1895,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":100 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":100 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -1749,7 +1904,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":101 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":101 * else: * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) * info.shape = <Py_ssize_t*>PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -1760,7 +1915,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L8:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":102 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":102 * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) * info.shape = <Py_ssize_t*>PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -1769,7 +1924,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->suboffsets = NULL; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":103 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":103 * info.shape = <Py_ssize_t*>PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -1778,7 +1933,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":104 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":104 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -1787,7 +1942,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self))); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":107 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":107 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -1796,7 +1951,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_f = NULL; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":108 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":108 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< @@ -1806,7 +1961,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr)); __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":112 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":112 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< @@ -1815,7 +1970,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":114 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":114 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -1829,7 +1984,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":116 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":116 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< @@ -1845,7 +2000,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":119 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":119 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< @@ -1860,7 +2015,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L11:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":121 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":121 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -1870,7 +2025,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_1 = (!__pyx_v_hasfields); if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":122 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":122 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< @@ -1879,7 +2034,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_t = __pyx_v_descr->type_num; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":123 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":123 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< @@ -1893,7 +2048,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (!__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":124 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":124 * t = descr.type_num * if ((descr.byteorder == '>' and little_endian) or * (descr.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< @@ -1911,7 +2066,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_6) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":125 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":125 * if ((descr.byteorder == '>' and little_endian) or * (descr.byteorder == '<' and not little_endian)): * raise ValueError("Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -1933,7 +2088,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L13:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":126 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":126 * (descr.byteorder == '<' and not little_endian)): * raise ValueError("Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -1945,7 +2100,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_6; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":127 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":127 * raise ValueError("Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -1956,7 +2111,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_7; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":128 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":128 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -1967,7 +2122,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_8; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":129 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":129 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -1978,7 +2133,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_9; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":130 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":130 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -1989,7 +2144,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_10; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":131 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":131 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -2000,7 +2155,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_11; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":132 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":132 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -2011,7 +2166,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_12; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":133 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":133 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -2022,7 +2177,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_13; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":134 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":134 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -2033,7 +2188,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_14; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":135 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":135 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -2044,7 +2199,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_15; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":136 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":136 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -2055,7 +2210,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_16; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":137 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":137 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -2066,7 +2221,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_17; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":138 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":138 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -2077,7 +2232,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_18; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":139 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":139 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -2088,7 +2243,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_19; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":140 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":140 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -2099,7 +2254,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_20; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":141 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":141 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -2110,7 +2265,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_f = __pyx_k_21; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":142 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":142 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -2122,7 +2277,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf break; default: - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":144 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":144 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -2148,7 +2303,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf break; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":145 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":145 * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -2157,7 +2312,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->format = __pyx_v_f; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":146 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":146 * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -2170,7 +2325,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":148 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":148 * return * else: * info.format = <char*>stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -2179,7 +2334,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->format = ((char *)malloc(255)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":149 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":149 * else: * info.format = <char*>stdlib.malloc(_buffer_format_string_len) * info.format[0] = '^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -2188,7 +2343,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ (__pyx_v_info->format[0]) = '^'; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":150 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":150 * info.format = <char*>stdlib.malloc(_buffer_format_string_len) * info.format[0] = '^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -2197,7 +2352,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_offset = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":153 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":153 * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, * &offset) # <<<<<<<<<<<<<< @@ -2207,7 +2362,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_7 = __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_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":154 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":154 * info.format + _buffer_format_string_len, * &offset) * f[0] = 0 # Terminate format string # <<<<<<<<<<<<<< @@ -2239,7 +2394,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf return __pyx_r; } -/* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":156 +/* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":156 * f[0] = 0 # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -2253,7 +2408,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P int __pyx_t_2; __Pyx_SetupRefcountContext("__releasebuffer__"); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":157 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":157 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -2263,7 +2418,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P __pyx_t_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self)); if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":158 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":158 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< @@ -2275,7 +2430,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P } __pyx_L5:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":159 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":159 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -2285,7 +2440,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P __pyx_t_2 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); if (__pyx_t_2) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":160 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":160 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< @@ -2300,7 +2455,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P __Pyx_FinishRefcountContext(); } -/* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":277 +/* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":277 * ctypedef npy_cdouble complex_t * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -2332,7 +2487,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_new_offset = Py_None; __Pyx_INCREF(Py_None); __pyx_v_t = Py_None; __Pyx_INCREF(Py_None); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":284 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":284 * cdef int delta_offset * cdef tuple i * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -2341,7 +2496,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_v_endian_detector = 1; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":285 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":285 * cdef tuple i * cdef int endian_detector = 1 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -2350,7 +2505,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":287 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":287 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) * * for i in descr.fields.itervalues(): # <<<<<<<<<<<<<< @@ -2389,7 +2544,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_i = ((PyObject *)__pyx_t_3); __pyx_t_3 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":288 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":288 * * for i in descr.fields.itervalues(): * child = i[0] # <<<<<<<<<<<<<< @@ -2403,7 +2558,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_child = ((PyArray_Descr *)__pyx_1); __pyx_1 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":289 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":289 * for i in descr.fields.itervalues(): * child = i[0] * new_offset = i[1] # <<<<<<<<<<<<<< @@ -2416,7 +2571,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_new_offset = __pyx_1; __pyx_1 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":291 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":291 * new_offset = i[1] * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -2441,7 +2596,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":292 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":292 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError("Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -2463,7 +2618,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L5:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":294 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":294 * raise RuntimeError("Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< @@ -2477,7 +2632,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } if (!__pyx_t_6) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":295 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":295 * * if ((child.byteorder == '>' and little_endian) or * (child.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< @@ -2495,7 +2650,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } if (__pyx_t_8) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":296 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":296 * if ((child.byteorder == '>' and little_endian) or * (child.byteorder == '<' and not little_endian)): * raise ValueError("Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -2517,7 +2672,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L6:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":306 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":306 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -2534,7 +2689,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_8) break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":307 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":307 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -2543,7 +2698,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ (__pyx_v_f[0]) = 120; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":308 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":308 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -2552,7 +2707,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_v_f += 1; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":309 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":309 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -2562,7 +2717,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc (__pyx_v_offset[0]) += 1; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":311 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":311 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -2571,7 +2726,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ (__pyx_v_offset[0]) += __pyx_v_child->elsize; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":313 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":313 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -2581,7 +2736,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_t_8 = (!PyDataType_HASFIELDS(__pyx_v_child)); if (__pyx_t_8) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":314 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":314 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< @@ -2594,7 +2749,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_t = __pyx_t_4; __pyx_t_4 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":315 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":315 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -2604,7 +2759,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_t_8 = ((__pyx_v_end - __pyx_v_f) < 5); if (__pyx_t_8) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":316 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":316 * t = child.type_num * if end - f < 5: * raise RuntimeError("Format string allocated too short.") # <<<<<<<<<<<<<< @@ -2626,7 +2781,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L10:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":319 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":319 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< @@ -2645,7 +2800,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":320 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":320 * # 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" # <<<<<<<<<<<<<< @@ -2664,7 +2819,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":321 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":321 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< @@ -2683,7 +2838,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":322 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":322 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< @@ -2702,7 +2857,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":323 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":323 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< @@ -2721,7 +2876,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":324 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":324 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< @@ -2740,7 +2895,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":325 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":325 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< @@ -2759,7 +2914,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":326 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":326 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< @@ -2778,7 +2933,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":327 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":327 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< @@ -2797,7 +2952,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":328 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":328 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< @@ -2816,7 +2971,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":329 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":329 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< @@ -2835,7 +2990,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":330 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":330 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< @@ -2854,7 +3009,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":331 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":331 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< @@ -2873,7 +3028,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":332 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":332 * 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 # <<<<<<<<<<<<<< @@ -2894,7 +3049,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":333 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":333 * 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 # <<<<<<<<<<<<<< @@ -2915,7 +3070,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":334 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":334 * 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 # <<<<<<<<<<<<<< @@ -2936,7 +3091,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":335 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":335 * 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" # <<<<<<<<<<<<<< @@ -2956,7 +3111,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":337 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":337 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -2979,7 +3134,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L11:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":338 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":338 * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -2991,7 +3146,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":342 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":342 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -3005,7 +3160,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":343 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":343 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -3034,7 +3189,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } static struct PyMethodDef __pyx_methods[] = { - {__Pyx_NAMESTR("enet_coordinate_descent"), (PyCFunction)__pyx_pf_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_descent, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7scikits_5learn_3glm_12enet_cd_fast_enet_coordinate_descent)}, + {__Pyx_NAMESTR("enet_coordinate_descent"), (PyCFunction)__pyx_pf_7scikits_5learn_6linreg_12enet_cd_fast_enet_coordinate_descent, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7scikits_5learn_6linreg_12enet_cd_fast_enet_coordinate_descent)}, {0, 0, 0, 0} }; @@ -3056,24 +3211,26 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp___main__, __pyx_k___main__, sizeof(__pyx_k___main__), 1, 1, 1}, + {&__pyx_kp_model, __pyx_k_model, sizeof(__pyx_k_model), 1, 1, 1}, {&__pyx_kp_X, __pyx_k_X, sizeof(__pyx_k_X), 1, 1, 1}, {&__pyx_kp_y, __pyx_k_y, sizeof(__pyx_k_y), 1, 1, 1}, - {&__pyx_kp_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 1, 1, 1}, - {&__pyx_kp_beta, __pyx_k_beta, sizeof(__pyx_k_beta), 1, 1, 1}, - {&__pyx_kp_w, __pyx_k_w, sizeof(__pyx_k_w), 1, 1, 1}, {&__pyx_kp_maxit, __pyx_k_maxit, sizeof(__pyx_k_maxit), 1, 1, 1}, - {&__pyx_kp_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 1, 1, 1}, {&__pyx_kp_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 1, 1, 1}, {&__pyx_kp_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 1, 1}, {&__pyx_kp_31, __pyx_k_31, sizeof(__pyx_k_31), 1, 1, 1}, {&__pyx_kp_32, __pyx_k_32, sizeof(__pyx_k_32), 1, 1, 1}, {&__pyx_kp_linalg, __pyx_k_linalg, sizeof(__pyx_k_linalg), 0, 1, 1}, + {&__pyx_kp_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 1, 1, 1}, + {&__pyx_kp_beta, __pyx_k_beta, sizeof(__pyx_k_beta), 1, 1, 1}, + {&__pyx_kp_w, __pyx_k_w, sizeof(__pyx_k_w), 1, 1, 1}, + {&__pyx_kp_callbacks, __pyx_k_callbacks, sizeof(__pyx_k_callbacks), 1, 1, 1}, {&__pyx_kp_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 1, 1, 1}, {&__pyx_kp_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 1, 1, 1}, {&__pyx_kp_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 1, 1, 1}, {&__pyx_kp_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 1, 1, 1}, - {&__pyx_kp_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 1, 1, 1}, {&__pyx_kp_range, __pyx_k_range, sizeof(__pyx_k_range), 1, 1, 1}, + {&__pyx_kp_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 1, 1, 1}, + {&__pyx_kp_R, __pyx_k_R, sizeof(__pyx_k_R), 1, 1, 1}, {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 1, 1, 1}, {&__pyx_kp___releasebuffer__, __pyx_k___releasebuffer__, sizeof(__pyx_k___releasebuffer__), 1, 1, 1}, {&__pyx_kp_info, __pyx_k_info, sizeof(__pyx_k_info), 1, 1, 1}, @@ -3092,8 +3249,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_kp_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_kp_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_kp_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_kp_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; @@ -3156,7 +3313,7 @@ PyMODINIT_FUNC PyInit_enet_cd_fast(void) __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - if (__pyx_module_is_main_scikits__learn__glm__enet_cd_fast) { + if (__pyx_module_is_main_scikits__learn__linreg__enet_cd_fast) { if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_kp___main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; } /*--- Builtin init code ---*/ @@ -3171,7 +3328,7 @@ PyMODINIT_FUNC PyInit_enet_cd_fast(void) /*--- Function import code ---*/ /*--- Execution code ---*/ - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":7 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":7 * * cimport numpy as np * import numpy as np # <<<<<<<<<<<<<< @@ -3183,7 +3340,7 @@ PyMODINIT_FUNC PyInit_enet_cd_fast(void) if (PyObject_SetAttr(__pyx_m, __pyx_kp_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/enet_cd_fast.pyx":8 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/enet_cd_fast.pyx":8 * cimport numpy as np * import numpy as np * import scipy.linalg as linalg # <<<<<<<<<<<<<< @@ -3201,7 +3358,7 @@ PyMODINIT_FUNC PyInit_enet_cd_fast(void) if (PyObject_SetAttr(__pyx_m, __pyx_kp_linalg, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/stdlib.pxd":2 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/stdlib.pxd":2 * * cdef extern from "stdlib.h" nogil: # <<<<<<<<<<<<<< * void free(void *ptr) @@ -3211,7 +3368,7 @@ PyMODINIT_FUNC PyInit_enet_cd_fast(void) __pyx_L1_error:; __Pyx_XDECREF(__pyx_1); __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("scikits.learn.glm.enet_cd_fast"); + __Pyx_AddTraceback("scikits.learn.linreg.enet_cd_fast"); Py_DECREF(__pyx_m); __pyx_m = 0; __pyx_L0:; __Pyx_FinishRefcountContext(); diff --git a/scikits/learn/linreg/enet_cd_fast.pyx b/scikits/learn/linreg/enet_cd_fast.pyx index 1133c197ac..673753d443 100644 --- a/scikits/learn/linreg/enet_cd_fast.pyx +++ b/scikits/learn/linreg/enet_cd_fast.pyx @@ -27,18 +27,20 @@ ctypedef np.float64_t DOUBLE @cython.boundscheck(False) @cython.wraparound(False) -def enet_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, +def enet_coordinate_descent(model, + np.ndarray[DOUBLE, ndim=2] X, np.ndarray[DOUBLE, ndim=1] y, - float alpha, - float beta, - np.ndarray[DOUBLE, ndim=1] w, - int maxit=10, - callback=None): + unsigned int maxit): """Cython version of the coordinate descent algorithm for Elastic-Net regression """ # get the data information into easy vars + cdef float alpha = model.alpha + cdef float beta = model.beta + cdef np.ndarray[DOUBLE, ndim=1] w = model.w + callbacks = model.callbacks + cdef unsigned int nsamples = X.shape[0] cdef unsigned int nfeatures = X.shape[1] cdef unsigned int nclasses = w.shape[1] @@ -55,8 +57,13 @@ def enet_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, cdef float w_ii cdef unsigned int ii cdef unsigned int jj - cdef unsigned int iter - for iter in xrange(maxit): + cdef unsigned int n_iter + + for callback in callbacks: + callback(0) # Init callback + + goon = True + for n_iter in range(maxit): for ii in xrange(nfeatures): # Loop over coordinates w_ii = w[ii] # Store previous value @@ -78,7 +85,11 @@ def enet_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, R[jj] -= w[ii] * X[jj,ii] # Update residual R[nsamples+ii] -= w[ii] * sqrt(beta) - if (callback is not None and not callback(X, y, R, alpha, w, iter)): + for callback in callbacks: + if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, beta=beta, R=R): + goon *= False + + if not goon: break return w diff --git a/scikits/learn/linreg/iteration_callbacks.py b/scikits/learn/linreg/iteration_callbacks.py new file mode 100644 index 0000000000..f9c3207d9f --- /dev/null +++ b/scikits/learn/linreg/iteration_callbacks.py @@ -0,0 +1,86 @@ +"""Iterations callbacks + + Iterations callbacks can be used for early stopping in an iterative + algorithm or for example for vizualisation purposes during the + optimization. + +""" + +class BaseIterationCallback(object): + """Base callback to be called at the end of each iteration of CD + + To be subclassed if more monitoring is required. + """ + + def __init__(self, linear_model): + pass + + def __call__(self, n_iter, **kwargs): + return True + + +class IterationCallbackMaxit(BaseIterationCallback): + """Callback to be called at the end of each iteration of CD + + - record and check the duality gap for early stop of the optim + (before maxiter) + + """ + + def __init__(self, maxit): + self.maxit = maxit + + def __call__(self, n_iter, **kwargs): + return n_iter < self.maxit + + +class IterationCallbackFunc(BaseIterationCallback): + """Callback to be called at the end of each iteration of CD + + - Store the values computed during iteration process + + """ + + def __init__(self, func, tol=None, record=True): + self.func = func + self.values = [] + self.record = record + self.tol = tol + + def __call__(self, n_iter, **kwargs): + if n_iter == 0: + self.values = [] + return True + + val = self.func(**kwargs) + if self.record: + self.values.append(val) + else: + self.values = val + + if self.tol is not None: + return abs(val) > self.tol + + return True + +class IterationCallbackMaxTime(BaseIterationCallback): + """Callback to be called at the end of each iteration of CD + + - Stop convergence after a certain number of seconds of computation + + """ + + def __init__(self, tmax=None): + self.tmax = tmax + self.t0 = None + + def __call__(self, n_iter, **kwargs): + if n_iter == 0: + self.t0 = time.time() + return True + + if (time.time() - self.t0) > self.tmax: + return False + else: + return True + diff --git a/scikits/learn/linreg/lasso_cd.py b/scikits/learn/linreg/lasso_cd.py index eac4f1cc8c..12a1484ac5 100644 --- a/scikits/learn/linreg/lasso_cd.py +++ b/scikits/learn/linreg/lasso_cd.py @@ -6,14 +6,23 @@ import numpy as np import scipy.linalg as linalg -def lasso_coordinate_descent(X, y, alpha, w, maxit=10, callback=None): +def lasso_coordinate_descent(model, X, y, maxit): """Coordinate descent for Lasso model""" norm_cols_X = np.sum(X**2, axis=0) # Compute norms of the columns of X + n_samples, n_features = X.shape + + alpha = model.alpha + callbacks = model.callbacks + w = model.w + R = y - np.dot(X,w) # Init residual - nsamples, nfeatures = X.shape - for iter in xrange(maxit): - for ii in xrange(nfeatures): # Loop over coordinates + for callback in callbacks: + callback(0) # Init callback + + goon = True + for n_iter in range(maxit): + for ii in xrange(n_features): # Loop over coordinates w_ii = w[ii] # Store previous value R += w_ii * X[:, ii] tmp = (X[:, ii] * R).sum() @@ -21,7 +30,11 @@ def lasso_coordinate_descent(X, y, alpha, w, maxit=10, callback=None): / norm_cols_X[ii] R -= w[ii] * X[:, ii] # Update residual - if (callback is not None and not callback(X, y, R, alpha, w, iter)): + for callback in callbacks: + if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, R=R): + goon *= False + + if not goon: break return w diff --git a/scikits/learn/linreg/lasso_cd_fast.c b/scikits/learn/linreg/lasso_cd_fast.c index 57ae266a50..380df926c8 100644 --- a/scikits/learn/linreg/lasso_cd_fast.c +++ b/scikits/learn/linreg/lasso_cd_fast.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.11.2 on Thu Mar 4 17:19:27 2010 */ +/* Generated by Cython 0.11.2 on Mon Mar 15 12:03:21 2010 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -131,11 +131,10 @@ #define __PYX_EXTERN_C extern #endif #include <math.h> -#define __PYX_HAVE_API__scikits__learn__glm__lasso_cd_fast +#define __PYX_HAVE_API__scikits__learn__linreg__lasso_cd_fast #include "stdlib.h" #include "numpy/arrayobject.h" #include "math.h" -#include "time.h" #define __PYX_USE_C99_COMPLEX defined(_Complex_I) @@ -694,7 +693,7 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; typedef npy_cdouble __pyx_t_5numpy_complex_t; -typedef __pyx_t_5numpy_float64_t __pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE; +typedef __pyx_t_5numpy_float64_t __pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE; /* Module declarations from python_buffer */ /* Module declarations from stdlib */ @@ -708,52 +707,56 @@ static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from cython */ -/* Module declarations from scikits.learn.glm.lasso_cd_fast */ +/* Module declarations from scikits.learn.linreg.lasso_cd_fast */ -static INLINE double __pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(double); /*proto*/ -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE = { "scikits.learn.glm.lasso_cd_fast.DOUBLE", NULL, sizeof(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE), 'R' }; -#define __Pyx_MODULE_NAME "scikits.learn.glm.lasso_cd_fast" -int __pyx_module_is_main_scikits__learn__glm__lasso_cd_fast = 0; +static INLINE double __pyx_f_7scikits_5learn_6linreg_13lasso_cd_fast_fsign(double); /*proto*/ +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE = { "scikits.learn.linreg.lasso_cd_fast.DOUBLE", NULL, sizeof(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE), 'R' }; +#define __Pyx_MODULE_NAME "scikits.learn.linreg.lasso_cd_fast" +int __pyx_module_is_main_scikits__learn__linreg__lasso_cd_fast = 0; -/* Implementation of scikits.learn.glm.lasso_cd_fast */ +/* Implementation of scikits.learn.linreg.lasso_cd_fast */ static PyObject *__pyx_int_2; static PyObject *__pyx_int_0; static char __pyx_k___main__[] = "__main__"; static PyObject *__pyx_kp___main__; +static char __pyx_k_model[] = "model"; +static PyObject *__pyx_kp_model; static char __pyx_k_X[] = "X"; static PyObject *__pyx_kp_X; static char __pyx_k_y[] = "y"; static PyObject *__pyx_kp_y; -static char __pyx_k_alpha[] = "alpha"; -static PyObject *__pyx_kp_alpha; -static char __pyx_k_w[] = "w"; -static PyObject *__pyx_kp_w; static char __pyx_k_maxit[] = "maxit"; static PyObject *__pyx_kp_maxit; -static char __pyx_k_callback[] = "callback"; -static PyObject *__pyx_kp_callback; static char __pyx_k_numpy[] = "numpy"; static PyObject *__pyx_kp_numpy; static char __pyx_k_np[] = "np"; static PyObject *__pyx_kp_np; -static char __pyx_k_63[] = "scipy.linalg"; -static PyObject *__pyx_kp_63; -static char __pyx_k_64[] = "*"; -static PyObject *__pyx_kp_64; +static char __pyx_k_31[] = "scipy.linalg"; +static PyObject *__pyx_kp_31; +static char __pyx_k_32[] = "*"; +static PyObject *__pyx_kp_32; static char __pyx_k_linalg[] = "linalg"; static PyObject *__pyx_kp_linalg; +static char __pyx_k_alpha[] = "alpha"; +static PyObject *__pyx_kp_alpha; +static char __pyx_k_w[] = "w"; +static PyObject *__pyx_kp_w; +static char __pyx_k_callbacks[] = "callbacks"; +static PyObject *__pyx_kp_callbacks; static char __pyx_k_sum[] = "sum"; static PyObject *__pyx_kp_sum; static char __pyx_k_axis[] = "axis"; static PyObject *__pyx_kp_axis; static char __pyx_k_dot[] = "dot"; static PyObject *__pyx_kp_dot; -static char __pyx_k_xrange[] = "xrange"; -static PyObject *__pyx_kp_xrange; static char __pyx_k_range[] = "range"; static PyObject *__pyx_kp_range; -static PyObject *__pyx_builtin_xrange; +static char __pyx_k_xrange[] = "xrange"; +static PyObject *__pyx_kp_xrange; +static char __pyx_k_R[] = "R"; +static PyObject *__pyx_kp_R; static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_xrange; static PyObject *__pyx_int_15; static char __pyx_k___getbuffer__[] = "__getbuffer__"; static PyObject *__pyx_kp___getbuffer__; @@ -769,61 +772,61 @@ static char __pyx_k_itervalues[] = "itervalues"; static PyObject *__pyx_kp_itervalues; static char __pyx_k_RuntimeError[] = "RuntimeError"; static PyObject *__pyx_kp_RuntimeError; -static PyObject *__pyx_kp_33; -static PyObject *__pyx_kp_34; -static PyObject *__pyx_kp_37; -static PyObject *__pyx_kp_55; +static PyObject *__pyx_kp_1; +static PyObject *__pyx_kp_2; +static PyObject *__pyx_kp_5; +static PyObject *__pyx_kp_23; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; -static char __pyx_k_33[] = "ndarray is not C contiguous"; -static char __pyx_k_34[] = "ndarray is not Fortran contiguous"; -static char __pyx_k_35[] = ">"; -static char __pyx_k_36[] = "<"; -static char __pyx_k_37[] = "Non-native byte order not supported"; -static char __pyx_k_38[] = "b"; -static char __pyx_k_39[] = "B"; -static char __pyx_k_40[] = "h"; -static char __pyx_k_41[] = "H"; -static char __pyx_k_42[] = "i"; -static char __pyx_k_43[] = "I"; -static char __pyx_k_44[] = "l"; -static char __pyx_k_45[] = "L"; -static char __pyx_k_46[] = "q"; -static char __pyx_k_47[] = "Q"; -static char __pyx_k_48[] = "f"; -static char __pyx_k_49[] = "d"; -static char __pyx_k_50[] = "g"; -static char __pyx_k_51[] = "Zf"; -static char __pyx_k_52[] = "Zd"; -static char __pyx_k_53[] = "Zg"; -static char __pyx_k_54[] = "O"; -static char __pyx_k_55[] = "unknown dtype code in numpy.pxd (%d)"; -static char __pyx_k_56[] = "^"; -static PyObject *__pyx_kp_57; -static PyObject *__pyx_kp_60; -static PyObject *__pyx_kp_61; -static PyObject *__pyx_kp_62; -static char __pyx_k_57[] = "Format string allocated too short, see comment in numpy.pxd"; -static char __pyx_k_58[] = ">"; -static char __pyx_k_59[] = "<"; -static char __pyx_k_60[] = "Non-native byte order not supported"; -static char __pyx_k_61[] = "Format string allocated too short."; -static char __pyx_k_62[] = "unknown dtype code in numpy.pxd (%d)"; - -/* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":22 - * time_t time(time_t *) +static char __pyx_k_1[] = "ndarray is not C contiguous"; +static char __pyx_k_2[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_3[] = ">"; +static char __pyx_k_4[] = "<"; +static char __pyx_k_5[] = "Non-native byte order not supported"; +static char __pyx_k_6[] = "b"; +static char __pyx_k_7[] = "B"; +static char __pyx_k_8[] = "h"; +static char __pyx_k_9[] = "H"; +static char __pyx_k_10[] = "i"; +static char __pyx_k_11[] = "I"; +static char __pyx_k_12[] = "l"; +static char __pyx_k_13[] = "L"; +static char __pyx_k_14[] = "q"; +static char __pyx_k_15[] = "Q"; +static char __pyx_k_16[] = "f"; +static char __pyx_k_17[] = "d"; +static char __pyx_k_18[] = "g"; +static char __pyx_k_19[] = "Zf"; +static char __pyx_k_20[] = "Zd"; +static char __pyx_k_21[] = "Zg"; +static char __pyx_k_22[] = "O"; +static char __pyx_k_23[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_24[] = "^"; +static PyObject *__pyx_kp_25; +static PyObject *__pyx_kp_28; +static PyObject *__pyx_kp_29; +static PyObject *__pyx_kp_30; +static char __pyx_k_25[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_26[] = ">"; +static char __pyx_k_27[] = "<"; +static char __pyx_k_28[] = "Non-native byte order not supported"; +static char __pyx_k_29[] = "Format string allocated too short."; +static char __pyx_k_30[] = "unknown dtype code in numpy.pxd (%d)"; + +/* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":18 + * double rand() * * cdef inline double fsign(double f): # <<<<<<<<<<<<<< * if f == 0: * return 0 */ -static INLINE double __pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(double __pyx_v_f) { +static INLINE double __pyx_f_7scikits_5learn_6linreg_13lasso_cd_fast_fsign(double __pyx_v_f) { double __pyx_r; int __pyx_t_1; __Pyx_SetupRefcountContext("fsign"); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":23 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":19 * * cdef inline double fsign(double f): * if f == 0: # <<<<<<<<<<<<<< @@ -833,7 +836,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(double _ __pyx_t_1 = (__pyx_v_f == 0); if (__pyx_t_1) { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":24 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":20 * cdef inline double fsign(double f): * if f == 0: * return 0 # <<<<<<<<<<<<<< @@ -845,7 +848,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(double _ goto __pyx_L3; } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":25 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":21 * if f == 0: * return 0 * elif f > 0: # <<<<<<<<<<<<<< @@ -855,7 +858,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(double _ __pyx_t_1 = (__pyx_v_f > 0); if (__pyx_t_1) { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":26 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":22 * return 0 * elif f > 0: * return 1.0 # <<<<<<<<<<<<<< @@ -868,7 +871,7 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(double _ } /*else*/ { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":28 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":24 * return 1.0 * else: * return -1.0 # <<<<<<<<<<<<<< @@ -886,23 +889,24 @@ static INLINE double __pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(double _ return __pyx_r; } -/* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":34 +/* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":30 * @cython.boundscheck(False) * @cython.wraparound(False) - * def lasso_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, # <<<<<<<<<<<<<< + * def lasso_coordinate_descent(model, # <<<<<<<<<<<<<< + * np.ndarray[DOUBLE, ndim=2] X, * np.ndarray[DOUBLE, ndim=1] y, - * float alpha, */ -static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_descent[] = "Cython version of the coordinate descent algorithm\n for Lasso regression\n "; -static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pf_7scikits_5learn_6linreg_13lasso_cd_fast_lasso_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7scikits_5learn_6linreg_13lasso_cd_fast_lasso_coordinate_descent[] = "Cython version of the coordinate descent algorithm\n for Lasso regression\n "; +static PyObject *__pyx_pf_7scikits_5learn_6linreg_13lasso_cd_fast_lasso_coordinate_descent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_model = 0; PyArrayObject *__pyx_v_X = 0; PyArrayObject *__pyx_v_y = 0; + unsigned int __pyx_v_maxit; float __pyx_v_alpha; PyArrayObject *__pyx_v_w = 0; - int __pyx_v_maxit; - PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_callbacks; unsigned int __pyx_v_nsamples; unsigned int __pyx_v_nfeatures; unsigned int __pyx_v_nclasses; @@ -912,7 +916,9 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ float __pyx_v_w_ii; unsigned int __pyx_v_ii; unsigned int __pyx_v_jj; - unsigned int __pyx_v_iter; + unsigned int __pyx_v_n_iter; + PyObject *__pyx_v_callback; + PyObject *__pyx_v_goon; Py_buffer __pyx_bstruct_norm_cols_X; Py_ssize_t __pyx_bstride_0_norm_cols_X = 0; Py_ssize_t __pyx_bshape_0_norm_cols_X = 0; @@ -933,13 +939,13 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ PyObject *__pyx_r = NULL; PyObject *__pyx_1 = 0; PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + float __pyx_t_2; PyArrayObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyArrayObject *__pyx_t_5 = NULL; - unsigned int __pyx_t_6; - unsigned int __pyx_t_7; - unsigned int __pyx_t_8; + PyObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; unsigned int __pyx_t_9; unsigned int __pyx_t_10; unsigned int __pyx_t_11; @@ -953,19 +959,18 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ unsigned int __pyx_t_19; unsigned int __pyx_t_20; unsigned int __pyx_t_21; - int __pyx_t_22; - int __pyx_t_23; - int __pyx_t_24; - static PyObject **__pyx_pyargnames[] = {&__pyx_kp_X,&__pyx_kp_y,&__pyx_kp_alpha,&__pyx_kp_w,&__pyx_kp_maxit,&__pyx_kp_callback,0}; + unsigned int __pyx_t_22; + unsigned int __pyx_t_23; + unsigned int __pyx_t_24; + int __pyx_t_25; + int __pyx_t_26; + static PyObject **__pyx_pyargnames[] = {&__pyx_kp_model,&__pyx_kp_X,&__pyx_kp_y,&__pyx_kp_maxit,0}; __Pyx_SetupRefcountContext("lasso_coordinate_descent"); __pyx_self = __pyx_self; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); - PyObject* values[6] = {0,0,0,0,0,0}; - values[5] = Py_None; + PyObject* values[4] = {0,0,0,0}; 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); 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); @@ -975,113 +980,134 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ } switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_X); + values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_model); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_y); + values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_X); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 0, 4, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: - values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_alpha); + values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_y); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 0, 4, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: - values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_w); + values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_maxit); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 0, 4, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 4: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_maxit); - if (unlikely(value)) { values[4] = value; kw_args--; } - } - case 5: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_callback); - if (unlikely(value)) { values[5] = value; kw_args--; } + __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 1, 4, 4, 3); {__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, PyTuple_GET_SIZE(__pyx_args), "lasso_coordinate_descent") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - __pyx_v_X = ((PyArrayObject *)values[0]); - __pyx_v_y = ((PyArrayObject *)values[1]); - __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[2]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_w = ((PyArrayObject *)values[3]); - if (values[4]) { - __pyx_v_maxit = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_maxit == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_maxit = 10; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "lasso_coordinate_descent") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - __pyx_v_callback = values[5]; + __pyx_v_model = values[0]; + __pyx_v_X = ((PyArrayObject *)values[1]); + __pyx_v_y = ((PyArrayObject *)values[2]); + __pyx_v_maxit = __Pyx_PyInt_AsUnsignedInt(values[3]); if (unlikely((__pyx_v_maxit == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; } else { - __pyx_v_maxit = 10; - __pyx_v_callback = Py_None; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 6: - __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: - __pyx_v_maxit = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_maxit == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - case 4: - __pyx_v_w = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3)); - __pyx_v_alpha = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_y = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1)); - __pyx_v_X = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0)); - break; - default: goto __pyx_L5_argtuple_error; - } + __pyx_v_model = PyTuple_GET_ITEM(__pyx_args, 0); + __pyx_v_X = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1)); + __pyx_v_y = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2)); + __pyx_v_maxit = __Pyx_PyInt_AsUnsignedInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_maxit == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("lasso_coordinate_descent", 1, 4, 4, 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("scikits.learn.glm.lasso_cd_fast.lasso_coordinate_descent"); + __Pyx_AddTraceback("scikits.learn.linreg.lasso_cd_fast.lasso_coordinate_descent"); return NULL; __pyx_L4_argument_unpacking_done:; + __pyx_v_callbacks = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_callback = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_goon = Py_None; __Pyx_INCREF(Py_None); + __pyx_bstruct_w.buf = NULL; __pyx_bstruct_norm_cols_X.buf = NULL; __pyx_bstruct_R.buf = NULL; __pyx_bstruct_X.buf = NULL; __pyx_bstruct_y.buf = NULL; - __pyx_bstruct_w.buf = NULL; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_5numpy_ndarray, 1, "w", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __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 = 31; __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 = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_X = __pyx_bstruct_X.strides[0]; __pyx_bstride_1_X = __pyx_bstruct_X.strides[1]; __pyx_bshape_0_X = __pyx_bstruct_X.shape[0]; __pyx_bshape_1_X = __pyx_bstruct_X.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE, 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_bstride_0_y = __pyx_bstruct_y.strides[0]; __pyx_bshape_0_y = __pyx_bstruct_y.shape[0]; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":39 + * + * # get the data information into easy vars + * cdef float alpha = model.alpha # <<<<<<<<<<<<<< + * cdef np.ndarray[DOUBLE, ndim=1] w = model.w + * callbacks = model.callbacks + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_model, __pyx_kp_alpha); 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_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_alpha = __pyx_t_2; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":40 + * # get the data information into easy vars + * cdef float alpha = model.alpha + * cdef np.ndarray[DOUBLE, ndim=1] w = model.w # <<<<<<<<<<<<<< + * callbacks = model.callbacks + * + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_model, __pyx_kp_w); 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 (!(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_v_w, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_w = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_w.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_bstride_0_w = __pyx_bstruct_w.strides[0]; + __pyx_bshape_0_w = __pyx_bstruct_w.shape[0]; + } } - __pyx_bstride_0_w = __pyx_bstruct_w.strides[0]; - __pyx_bshape_0_w = __pyx_bstruct_w.shape[0]; + __pyx_t_3 = 0; + __pyx_v_w = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":45 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":41 + * cdef float alpha = model.alpha + * cdef np.ndarray[DOUBLE, ndim=1] w = model.w + * callbacks = model.callbacks # <<<<<<<<<<<<<< + * + * cdef unsigned int nsamples = X.shape[0] + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_model, __pyx_kp_callbacks); 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_DECREF(__pyx_v_callbacks); + __pyx_v_callbacks = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":43 + * callbacks = model.callbacks * - * # get the data information into easy vars * cdef unsigned int nsamples = X.shape[0] # <<<<<<<<<<<<<< * cdef unsigned int nfeatures = X.shape[1] * cdef unsigned int nclasses = w.shape[1] */ __pyx_v_nsamples = (__pyx_v_X->dimensions[0]); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":46 - * # get the data information into easy vars + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":44 + * * cdef unsigned int nsamples = X.shape[0] * cdef unsigned int nfeatures = X.shape[1] # <<<<<<<<<<<<<< * cdef unsigned int nclasses = w.shape[1] @@ -1089,7 +1115,7 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ */ __pyx_v_nfeatures = (__pyx_v_X->dimensions[1]); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":47 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":45 * cdef unsigned int nsamples = X.shape[0] * cdef unsigned int nfeatures = X.shape[1] * cdef unsigned int nclasses = w.shape[1] # <<<<<<<<<<<<<< @@ -1098,136 +1124,200 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ */ __pyx_v_nclasses = (__pyx_v_w->dimensions[1]); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":49 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":47 * cdef unsigned int nclasses = w.shape[1] * * cdef np.ndarray[DOUBLE, ndim=1] norm_cols_X = (X**2).sum(axis=0) # Compute norms of the columns of X # <<<<<<<<<<<<<< * cdef np.ndarray[DOUBLE, ndim=1] R = y - np.dot(X, w) # Init residual * */ - __pyx_t_1 = PyNumber_Power(((PyObject *)__pyx_v_X), __pyx_int_2, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Power(((PyObject *)__pyx_v_X), __pyx_int_2, Py_None); 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_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_kp_sum); 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_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_kp_sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_1)); - if (PyDict_SetItem(__pyx_1, __pyx_kp_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_1, __pyx_kp_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_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_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; - if (!(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = ((PyArrayObject *)__pyx_t_1); + if (!(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_norm_cols_X, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_norm_cols_X, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { __pyx_v_norm_cols_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_norm_cols_X.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_bstride_0_norm_cols_X = __pyx_bstruct_norm_cols_X.strides[0]; __pyx_bshape_0_norm_cols_X = __pyx_bstruct_norm_cols_X.shape[0]; } } - __pyx_t_3 = 0; + __pyx_t_5 = 0; __pyx_v_norm_cols_X = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":50 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":48 * * cdef np.ndarray[DOUBLE, ndim=1] norm_cols_X = (X**2).sum(axis=0) # Compute norms of the columns of X * cdef np.ndarray[DOUBLE, ndim=1] R = y - np.dot(X, w) # Init residual # <<<<<<<<<<<<<< * * cdef float tmp */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_np); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_1); - __pyx_t_1 = PyObject_GetAttr(__pyx_1, __pyx_kp_dot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_1, __pyx_kp_dot); 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_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); __Pyx_INCREF(((PyObject *)__pyx_v_X)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_X)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_X)); __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); __Pyx_INCREF(((PyObject *)__pyx_v_w)); - PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_w)); + PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_w)); __Pyx_GIVEREF(((PyObject *)__pyx_v_w)); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Subtract(((PyObject *)__pyx_v_y), __pyx_t_4); 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_4); __pyx_t_4 = 0; - if (!(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = ((PyArrayObject *)__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Subtract(((PyObject *)__pyx_v_y), __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_R, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_R, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_R = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_R.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_bstride_0_R = __pyx_bstruct_R.strides[0]; __pyx_bshape_0_R = __pyx_bstruct_R.shape[0]; } } - __pyx_t_5 = 0; - __pyx_v_R = ((PyArrayObject *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_7 = 0; + __pyx_v_R = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":57 - * cdef unsigned int jj - * cdef unsigned int iter - * for iter in xrange(maxit): # <<<<<<<<<<<<<< + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":56 + * cdef unsigned int n_iter + * + * for callback in callbacks: # <<<<<<<<<<<<<< + * callback(0) # Init callback + * + */ + if (PyList_CheckExact(__pyx_v_callbacks) || PyTuple_CheckExact(__pyx_v_callbacks)) { + __pyx_t_8 = 0; __pyx_t_4 = __pyx_v_callbacks; __Pyx_INCREF(__pyx_t_4); + } else { + __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_callbacks); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + } + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; + } else if (likely(PyTuple_CheckExact(__pyx_t_4))) { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; + } else { + __pyx_t_6 = PyIter_Next(__pyx_t_4); + if (!__pyx_t_6) { + if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + __Pyx_GOTREF(__pyx_t_6); + } + __Pyx_DECREF(__pyx_v_callback); + __pyx_v_callback = __pyx_t_6; + __pyx_t_6 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":57 + * + * for callback in callbacks: + * callback(0) # Init callback # <<<<<<<<<<<<<< + * + * goon = True + */ + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_t_1 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":59 + * callback(0) # Init callback + * + * goon = True # <<<<<<<<<<<<<< + * for n_iter in range(maxit): + * for ii in xrange(nfeatures): # Loop over coordinates + */ + __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_v_goon); + __pyx_v_goon = __pyx_t_4; + __pyx_t_4 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":60 + * + * goon = True + * for n_iter in range(maxit): # <<<<<<<<<<<<<< * for ii in xrange(nfeatures): # Loop over coordinates * w_ii = w[ii] # Store previous value */ - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_v_maxit; __pyx_t_6+=1) { - __pyx_v_iter = __pyx_t_6; + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_v_maxit; __pyx_t_9+=1) { + __pyx_v_n_iter = __pyx_t_9; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":58 - * cdef unsigned int iter - * for iter in xrange(maxit): + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":61 + * goon = True + * for n_iter in range(maxit): * for ii in xrange(nfeatures): # Loop over coordinates # <<<<<<<<<<<<<< * w_ii = w[ii] # Store previous value * */ - for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_v_nfeatures; __pyx_t_7+=1) { - __pyx_v_ii = __pyx_t_7; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_v_nfeatures; __pyx_t_10+=1) { + __pyx_v_ii = __pyx_t_10; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":59 - * for iter in xrange(maxit): + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":62 + * for n_iter in range(maxit): * for ii in xrange(nfeatures): # Loop over coordinates * w_ii = w[ii] # Store previous value # <<<<<<<<<<<<<< * * # R += w_ii * X[:,ii] */ - __pyx_t_8 = __pyx_v_ii; - __pyx_v_w_ii = (*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_8, __pyx_bstride_0_w)); + __pyx_t_11 = __pyx_v_ii; + __pyx_v_w_ii = (*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_11, __pyx_bstride_0_w)); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":62 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":65 * * # R += w_ii * X[:,ii] * for jj in range(nsamples): # <<<<<<<<<<<<<< * R[jj] += w_ii * X[jj, ii] * */ - for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_v_nsamples; __pyx_t_9+=1) { - __pyx_v_jj = __pyx_t_9; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_v_nsamples; __pyx_t_12+=1) { + __pyx_v_jj = __pyx_t_12; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":63 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":66 * # R += w_ii * X[:,ii] * for jj in range(nsamples): * R[jj] += w_ii * X[jj, ii] # <<<<<<<<<<<<<< * * # tmp = (X[:,ii]*R).sum() */ - __pyx_t_10 = __pyx_v_jj; - __pyx_t_11 = __pyx_v_ii; - __pyx_t_12 = __pyx_v_jj; - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_12, __pyx_bstride_0_R) += (__pyx_v_w_ii * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_10, __pyx_bstride_0_X, __pyx_t_11, __pyx_bstride_1_X))); + __pyx_t_13 = __pyx_v_jj; + __pyx_t_14 = __pyx_v_ii; + __pyx_t_15 = __pyx_v_jj; + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_15, __pyx_bstride_0_R) += (__pyx_v_w_ii * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_13, __pyx_bstride_0_X, __pyx_t_14, __pyx_bstride_1_X))); } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":66 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":69 * * # tmp = (X[:,ii]*R).sum() * tmp = 0.0 # <<<<<<<<<<<<<< @@ -1236,124 +1326,177 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ */ __pyx_v_tmp = 0.0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":67 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":70 * # tmp = (X[:,ii]*R).sum() * tmp = 0.0 * for jj in range(nsamples): # <<<<<<<<<<<<<< * tmp += R[jj] * X[jj, ii] * */ - for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_v_nsamples; __pyx_t_9+=1) { - __pyx_v_jj = __pyx_t_9; + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_v_nsamples; __pyx_t_12+=1) { + __pyx_v_jj = __pyx_t_12; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":68 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":71 * tmp = 0.0 * for jj in range(nsamples): * tmp += R[jj] * X[jj, ii] # <<<<<<<<<<<<<< * * w[ii] = fsign(tmp) * fmax(fabs(tmp) - alpha, 0) / norm_cols_X[ii] */ - __pyx_t_13 = __pyx_v_jj; - __pyx_t_14 = __pyx_v_jj; - __pyx_t_15 = __pyx_v_ii; - __pyx_v_tmp += ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_13, __pyx_bstride_0_R)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_14, __pyx_bstride_0_X, __pyx_t_15, __pyx_bstride_1_X))); + __pyx_t_16 = __pyx_v_jj; + __pyx_t_17 = __pyx_v_jj; + __pyx_t_18 = __pyx_v_ii; + __pyx_v_tmp += ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_16, __pyx_bstride_0_R)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_17, __pyx_bstride_0_X, __pyx_t_18, __pyx_bstride_1_X))); } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":70 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":73 * tmp += R[jj] * X[jj, ii] * * w[ii] = fsign(tmp) * fmax(fabs(tmp) - alpha, 0) / norm_cols_X[ii] # <<<<<<<<<<<<<< * * # R -= w[ii] * X[:,ii] # Update residual */ - __pyx_t_9 = __pyx_v_ii; - __pyx_t_16 = __pyx_v_ii; - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_16, __pyx_bstride_0_w) = ((__pyx_f_7scikits_5learn_3glm_13lasso_cd_fast_fsign(__pyx_v_tmp) * fmax((fabs(__pyx_v_tmp) - __pyx_v_alpha), 0)) / (*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_norm_cols_X.buf, __pyx_t_9, __pyx_bstride_0_norm_cols_X))); + __pyx_t_12 = __pyx_v_ii; + __pyx_t_19 = __pyx_v_ii; + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_19, __pyx_bstride_0_w) = ((__pyx_f_7scikits_5learn_6linreg_13lasso_cd_fast_fsign(__pyx_v_tmp) * fmax((fabs(__pyx_v_tmp) - __pyx_v_alpha), 0)) / (*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_norm_cols_X.buf, __pyx_t_12, __pyx_bstride_0_norm_cols_X))); - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":73 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":76 * * # R -= w[ii] * X[:,ii] # Update residual * for jj in range(nsamples): # <<<<<<<<<<<<<< * R[jj] -= w[ii] * X[jj, ii] # Update residual * */ - for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_v_nsamples; __pyx_t_17+=1) { - __pyx_v_jj = __pyx_t_17; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_v_nsamples; __pyx_t_20+=1) { + __pyx_v_jj = __pyx_t_20; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":74 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":77 * # R -= w[ii] * X[:,ii] # Update residual * for jj in range(nsamples): * R[jj] -= w[ii] * X[jj, ii] # Update residual # <<<<<<<<<<<<<< * - * if (callback is not None and not callback(X, y, R, alpha, w, iter)): + * for callback in callbacks: */ - __pyx_t_18 = __pyx_v_ii; - __pyx_t_19 = __pyx_v_jj; - __pyx_t_20 = __pyx_v_ii; - __pyx_t_21 = __pyx_v_jj; - *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_21, __pyx_bstride_0_R) -= ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_18, __pyx_bstride_0_w)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_3glm_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_19, __pyx_bstride_0_X, __pyx_t_20, __pyx_bstride_1_X))); + __pyx_t_21 = __pyx_v_ii; + __pyx_t_22 = __pyx_v_jj; + __pyx_t_23 = __pyx_v_ii; + __pyx_t_24 = __pyx_v_jj; + *__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_R.buf, __pyx_t_24, __pyx_bstride_0_R) -= ((*__Pyx_BufPtrStrided1d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_w.buf, __pyx_t_21, __pyx_bstride_0_w)) * (*__Pyx_BufPtrStrided2d(__pyx_t_7scikits_5learn_6linreg_13lasso_cd_fast_DOUBLE *, __pyx_bstruct_X.buf, __pyx_t_22, __pyx_bstride_0_X, __pyx_t_23, __pyx_bstride_1_X))); } } - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":76 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":79 * R[jj] -= w[ii] * X[jj, ii] # Update residual * - * if (callback is not None and not callback(X, y, R, alpha, w, iter)): # <<<<<<<<<<<<<< - * break - * + * for callback in callbacks: # <<<<<<<<<<<<<< + * if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, R=R): + * goon *= False */ - __pyx_t_22 = (__pyx_v_callback != Py_None); - if (__pyx_t_22) { - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_alpha); 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_4 = PyLong_FromUnsignedLong(__pyx_v_iter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_INCREF(((PyObject *)__pyx_v_X)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_X)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_X)); - __Pyx_INCREF(((PyObject *)__pyx_v_y)); - PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_y)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_y)); - __Pyx_INCREF(((PyObject *)__pyx_v_R)); - PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_R)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_R)); - PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_w)); - PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_w)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_w)); - PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_2 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_23 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_24 = (!__pyx_t_23); + if (PyList_CheckExact(__pyx_v_callbacks) || PyTuple_CheckExact(__pyx_v_callbacks)) { + __pyx_t_8 = 0; __pyx_t_4 = __pyx_v_callbacks; __Pyx_INCREF(__pyx_t_4); } else { - __pyx_t_24 = __pyx_t_22; + __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_callbacks); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + } + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; + } else if (likely(PyTuple_CheckExact(__pyx_t_4))) { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; + } else { + __pyx_t_1 = PyIter_Next(__pyx_t_4); + if (!__pyx_t_1) { + if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_DECREF(__pyx_v_callback); + __pyx_v_callback = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":80 + * + * for callback in callbacks: + * if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, R=R): # <<<<<<<<<<<<<< + * goon *= False + * + */ + __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_n_iter); 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_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_1)); + if (PyDict_SetItem(__pyx_1, __pyx_kp_X, ((PyObject *)__pyx_v_X)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_1, __pyx_kp_y, ((PyObject *)__pyx_v_y)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_1, __pyx_kp_w, ((PyObject *)__pyx_v_w)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_alpha); 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 (PyDict_SetItem(__pyx_1, __pyx_kp_alpha, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_1, __pyx_kp_R, ((PyObject *)__pyx_v_R)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_v_callback, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_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_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __Pyx_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; + __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_26 = (!__pyx_t_25); + if (__pyx_t_26) { + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":81 + * for callback in callbacks: + * if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, R=R): + * goon *= False # <<<<<<<<<<<<<< + * + * if not goon: + */ + __pyx_t_1 = __Pyx_PyBool_FromLong(0); 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_1 = PyNumber_InPlaceMultiply(__pyx_v_goon, __pyx_t_1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_v_goon); + __pyx_v_goon = __pyx_1; + __pyx_1 = 0; + goto __pyx_L20; + } + __pyx_L20:; } - if (__pyx_t_24) { + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":83 + * goon *= False + * + * if not goon: # <<<<<<<<<<<<<< + * break + * + */ + __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_v_goon); if (unlikely(__pyx_t_26 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_25 = (!__pyx_t_26); + if (__pyx_t_25) { - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":77 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":84 * - * if (callback is not None and not callback(X, y, R, alpha, w, iter)): + * if not goon: * break # <<<<<<<<<<<<<< * * return w */ - goto __pyx_L7_break; - goto __pyx_L16; + goto __pyx_L9_break; + goto __pyx_L21; } - __pyx_L16:; + __pyx_L21:; } - __pyx_L7_break:; + __pyx_L9_break:; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":79 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":86 * break * * return w # <<<<<<<<<<<<<< @@ -1368,8 +1511,8 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ __pyx_L1_error:; __Pyx_XDECREF(__pyx_1); __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __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_bstruct_norm_cols_X); @@ -1378,7 +1521,7 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("scikits.learn.glm.lasso_cd_fast.lasso_coordinate_descent"); + __Pyx_AddTraceback("scikits.learn.linreg.lasso_cd_fast.lasso_coordinate_descent"); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; @@ -1388,14 +1531,18 @@ static PyObject *__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_ __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_w); + __Pyx_DECREF(__pyx_v_callbacks); __Pyx_XDECREF((PyObject *)__pyx_v_norm_cols_X); __Pyx_XDECREF((PyObject *)__pyx_v_R); + __Pyx_DECREF(__pyx_v_callback); + __Pyx_DECREF(__pyx_v_goon); __Pyx_XGIVEREF(__pyx_r); __Pyx_FinishRefcountContext(); return __pyx_r; } -/* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":65 +/* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":65 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -1428,7 +1575,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":71 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":71 * # of flags * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -1437,7 +1584,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_endian_detector = 1; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":72 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":72 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -1446,7 +1593,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":74 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":74 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -1455,7 +1602,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":76 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":76 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -1465,7 +1612,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":77 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":77 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< @@ -1477,7 +1624,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":79 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":79 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< @@ -1488,7 +1635,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L5:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":81 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":81 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -1497,7 +1644,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ if (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS)) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":82 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":82 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -1510,7 +1657,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":83 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":83 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError("ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -1519,9 +1666,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __Pyx_INCREF(__pyx_kp_33); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_33); - __Pyx_GIVEREF(__pyx_kp_33); + __Pyx_INCREF(__pyx_kp_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_1); + __Pyx_GIVEREF(__pyx_kp_1); __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -1532,7 +1679,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L6:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":85 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":85 * raise ValueError("ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -1541,7 +1688,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ if (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS)) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":86 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":86 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -1554,7 +1701,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":87 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":87 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError("ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -1563,9 +1710,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __Pyx_INCREF(__pyx_kp_34); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_34); - __Pyx_GIVEREF(__pyx_kp_34); + __Pyx_INCREF(__pyx_kp_2); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_2); + __Pyx_GIVEREF(__pyx_kp_2); __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; @@ -1576,7 +1723,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L7:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":89 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":89 * raise ValueError("ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< @@ -1585,7 +1732,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":90 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":90 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -1594,7 +1741,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":91 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":91 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -1604,7 +1751,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_4 = __pyx_v_copy_shape; if (__pyx_t_4) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":94 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":94 * # Allocate new buffer for strides and shape info. This is allocated * # as one block, strides first. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< @@ -1613,7 +1760,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * __pyx_v_ndim) * 2))); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":95 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":95 * # as one block, strides first. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -1622,7 +1769,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":96 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":96 * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -1632,7 +1779,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_v_ndim; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":97 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":97 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -1641,7 +1788,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":98 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":98 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -1654,7 +1801,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":100 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":100 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -1663,7 +1810,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":101 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":101 * else: * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) * info.shape = <Py_ssize_t*>PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -1674,7 +1821,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L8:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":102 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":102 * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) * info.shape = <Py_ssize_t*>PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -1683,7 +1830,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->suboffsets = NULL; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":103 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":103 * info.shape = <Py_ssize_t*>PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -1692,7 +1839,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":104 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":104 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -1701,7 +1848,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self))); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":107 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":107 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -1710,7 +1857,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_f = NULL; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":108 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":108 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< @@ -1720,7 +1867,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr)); __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":112 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":112 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< @@ -1729,7 +1876,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":114 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":114 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -1743,7 +1890,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":116 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":116 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< @@ -1759,7 +1906,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":119 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":119 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< @@ -1774,7 +1921,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L11:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":121 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":121 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -1784,7 +1931,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_1 = (!__pyx_v_hasfields); if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":122 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":122 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< @@ -1793,7 +1940,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_t = __pyx_v_descr->type_num; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":123 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":123 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< @@ -1807,7 +1954,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (!__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":124 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":124 * t = descr.type_num * if ((descr.byteorder == '>' and little_endian) or * (descr.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< @@ -1825,7 +1972,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } if (__pyx_t_6) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":125 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":125 * if ((descr.byteorder == '>' and little_endian) or * (descr.byteorder == '<' and not little_endian)): * raise ValueError("Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -1834,9 +1981,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __Pyx_INCREF(__pyx_kp_37); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_37); - __Pyx_GIVEREF(__pyx_kp_37); + __Pyx_INCREF(__pyx_kp_5); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_5); + __Pyx_GIVEREF(__pyx_kp_5); __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -1847,7 +1994,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } __pyx_L13:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":126 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":126 * (descr.byteorder == '<' and not little_endian)): * raise ValueError("Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -1856,10 +2003,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ switch (__pyx_v_t) { case NPY_BYTE: - __pyx_v_f = __pyx_k_38; + __pyx_v_f = __pyx_k_6; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":127 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":127 * raise ValueError("Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -1867,10 +2014,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_USHORT: f = "H" */ case NPY_UBYTE: - __pyx_v_f = __pyx_k_39; + __pyx_v_f = __pyx_k_7; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":128 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":128 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -1878,10 +2025,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_INT: f = "i" */ case NPY_SHORT: - __pyx_v_f = __pyx_k_40; + __pyx_v_f = __pyx_k_8; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":129 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":129 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -1889,10 +2036,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_UINT: f = "I" */ case NPY_USHORT: - __pyx_v_f = __pyx_k_41; + __pyx_v_f = __pyx_k_9; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":130 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":130 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -1900,10 +2047,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_LONG: f = "l" */ case NPY_INT: - __pyx_v_f = __pyx_k_42; + __pyx_v_f = __pyx_k_10; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":131 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":131 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -1911,10 +2058,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_ULONG: f = "L" */ case NPY_UINT: - __pyx_v_f = __pyx_k_43; + __pyx_v_f = __pyx_k_11; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":132 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":132 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -1922,10 +2069,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_LONGLONG: f = "q" */ case NPY_LONG: - __pyx_v_f = __pyx_k_44; + __pyx_v_f = __pyx_k_12; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":133 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":133 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -1933,10 +2080,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_ULONGLONG: f = "Q" */ case NPY_ULONG: - __pyx_v_f = __pyx_k_45; + __pyx_v_f = __pyx_k_13; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":134 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":134 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -1944,10 +2091,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_FLOAT: f = "f" */ case NPY_LONGLONG: - __pyx_v_f = __pyx_k_46; + __pyx_v_f = __pyx_k_14; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":135 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":135 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -1955,10 +2102,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_DOUBLE: f = "d" */ case NPY_ULONGLONG: - __pyx_v_f = __pyx_k_47; + __pyx_v_f = __pyx_k_15; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":136 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":136 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -1966,10 +2113,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_LONGDOUBLE: f = "g" */ case NPY_FLOAT: - __pyx_v_f = __pyx_k_48; + __pyx_v_f = __pyx_k_16; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":137 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":137 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -1977,10 +2124,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_CFLOAT: f = "Zf" */ case NPY_DOUBLE: - __pyx_v_f = __pyx_k_49; + __pyx_v_f = __pyx_k_17; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":138 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":138 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -1988,10 +2135,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_CDOUBLE: f = "Zd" */ case NPY_LONGDOUBLE: - __pyx_v_f = __pyx_k_50; + __pyx_v_f = __pyx_k_18; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":139 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":139 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -1999,10 +2146,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_CLONGDOUBLE: f = "Zg" */ case NPY_CFLOAT: - __pyx_v_f = __pyx_k_51; + __pyx_v_f = __pyx_k_19; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":140 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":140 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -2010,10 +2157,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * elif t == NPY_OBJECT: f = "O" */ case NPY_CDOUBLE: - __pyx_v_f = __pyx_k_52; + __pyx_v_f = __pyx_k_20; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":141 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":141 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -2021,10 +2168,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * else: */ case NPY_CLONGDOUBLE: - __pyx_v_f = __pyx_k_53; + __pyx_v_f = __pyx_k_21; break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":142 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":142 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -2032,11 +2179,11 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) */ case NPY_OBJECT: - __pyx_v_f = __pyx_k_54; + __pyx_v_f = __pyx_k_22; break; default: - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":144 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":144 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -2045,7 +2192,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_t_3 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyNumber_Remainder(__pyx_kp_55, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(__pyx_kp_23, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __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(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -2062,7 +2209,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf break; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":145 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":145 * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -2071,7 +2218,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->format = __pyx_v_f; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":146 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":146 * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -2084,7 +2231,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":148 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":148 * return * else: * info.format = <char*>stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -2093,7 +2240,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_info->format = ((char *)malloc(255)); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":149 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":149 * else: * info.format = <char*>stdlib.malloc(_buffer_format_string_len) * info.format[0] = '^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -2102,7 +2249,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ (__pyx_v_info->format[0]) = '^'; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":150 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":150 * info.format = <char*>stdlib.malloc(_buffer_format_string_len) * info.format[0] = '^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -2111,7 +2258,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf */ __pyx_v_offset = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":153 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":153 * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, * &offset) # <<<<<<<<<<<<<< @@ -2121,7 +2268,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf __pyx_t_7 = __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_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":154 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":154 * info.format + _buffer_format_string_len, * &offset) * f[0] = 0 # Terminate format string # <<<<<<<<<<<<<< @@ -2153,7 +2300,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buf return __pyx_r; } -/* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":156 +/* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":156 * f[0] = 0 # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -2167,7 +2314,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P int __pyx_t_2; __Pyx_SetupRefcountContext("__releasebuffer__"); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":157 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":157 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -2177,7 +2324,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P __pyx_t_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self)); if (__pyx_t_1) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":158 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":158 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< @@ -2189,7 +2336,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P } __pyx_L5:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":159 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":159 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -2199,7 +2346,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P __pyx_t_2 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); if (__pyx_t_2) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":160 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":160 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< @@ -2214,7 +2361,7 @@ static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, P __Pyx_FinishRefcountContext(); } -/* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":277 +/* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":277 * ctypedef npy_cdouble complex_t * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -2246,7 +2393,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_new_offset = Py_None; __Pyx_INCREF(Py_None); __pyx_v_t = Py_None; __Pyx_INCREF(Py_None); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":284 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":284 * cdef int delta_offset * cdef tuple i * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -2255,7 +2402,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_v_endian_detector = 1; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":285 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":285 * cdef tuple i * cdef int endian_detector = 1 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -2264,7 +2411,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":287 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":287 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) * * for i in descr.fields.itervalues(): # <<<<<<<<<<<<<< @@ -2303,7 +2450,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_i = ((PyObject *)__pyx_t_3); __pyx_t_3 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":288 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":288 * * for i in descr.fields.itervalues(): * child = i[0] # <<<<<<<<<<<<<< @@ -2317,7 +2464,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_child = ((PyArray_Descr *)__pyx_1); __pyx_1 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":289 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":289 * for i in descr.fields.itervalues(): * child = i[0] * new_offset = i[1] # <<<<<<<<<<<<<< @@ -2330,7 +2477,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_new_offset = __pyx_1; __pyx_1 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":291 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":291 * new_offset = i[1] * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -2355,7 +2502,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":292 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":292 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError("Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -2364,9 +2511,9 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __Pyx_INCREF(__pyx_kp_57); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_57); - __Pyx_GIVEREF(__pyx_kp_57); + __Pyx_INCREF(__pyx_kp_25); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_25); + __Pyx_GIVEREF(__pyx_kp_25); __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; @@ -2377,7 +2524,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L5:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":294 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":294 * raise RuntimeError("Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< @@ -2391,7 +2538,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } if (!__pyx_t_6) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":295 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":295 * * if ((child.byteorder == '>' and little_endian) or * (child.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< @@ -2409,7 +2556,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } if (__pyx_t_8) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":296 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":296 * if ((child.byteorder == '>' and little_endian) or * (child.byteorder == '<' and not little_endian)): * raise ValueError("Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -2418,9 +2565,9 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __Pyx_INCREF(__pyx_kp_60); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_60); - __Pyx_GIVEREF(__pyx_kp_60); + __Pyx_INCREF(__pyx_kp_28); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_28); + __Pyx_GIVEREF(__pyx_kp_28); __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -2431,7 +2578,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L6:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":306 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":306 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -2448,7 +2595,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_8) break; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":307 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":307 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -2457,7 +2604,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ (__pyx_v_f[0]) = 120; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":308 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":308 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -2466,7 +2613,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_v_f += 1; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":309 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":309 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -2476,7 +2623,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc (__pyx_v_offset[0]) += 1; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":311 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":311 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -2485,7 +2632,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ (__pyx_v_offset[0]) += __pyx_v_child->elsize; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":313 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":313 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -2495,7 +2642,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_t_8 = (!PyDataType_HASFIELDS(__pyx_v_child)); if (__pyx_t_8) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":314 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":314 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< @@ -2508,7 +2655,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_v_t = __pyx_t_4; __pyx_t_4 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":315 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":315 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -2518,7 +2665,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc __pyx_t_8 = ((__pyx_v_end - __pyx_v_f) < 5); if (__pyx_t_8) { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":316 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":316 * t = child.type_num * if end - f < 5: * raise RuntimeError("Format string allocated too short.") # <<<<<<<<<<<<<< @@ -2527,9 +2674,9 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __Pyx_INCREF(__pyx_kp_61); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_61); - __Pyx_GIVEREF(__pyx_kp_61); + __Pyx_INCREF(__pyx_kp_29); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_29); + __Pyx_GIVEREF(__pyx_kp_29); __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -2540,7 +2687,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L10:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":319 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":319 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< @@ -2559,7 +2706,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":320 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":320 * # 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" # <<<<<<<<<<<<<< @@ -2578,7 +2725,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":321 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":321 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< @@ -2597,7 +2744,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":322 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":322 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< @@ -2616,7 +2763,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":323 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":323 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< @@ -2635,7 +2782,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":324 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":324 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< @@ -2654,7 +2801,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":325 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":325 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< @@ -2673,7 +2820,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":326 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":326 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< @@ -2692,7 +2839,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":327 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":327 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< @@ -2711,7 +2858,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":328 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":328 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< @@ -2730,7 +2877,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":329 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":329 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< @@ -2749,7 +2896,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":330 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":330 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< @@ -2768,7 +2915,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":331 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":331 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< @@ -2787,7 +2934,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":332 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":332 * 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 # <<<<<<<<<<<<<< @@ -2808,7 +2955,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":333 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":333 * 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 # <<<<<<<<<<<<<< @@ -2829,7 +2976,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":334 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":334 * 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 # <<<<<<<<<<<<<< @@ -2850,7 +2997,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc goto __pyx_L11; } - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":335 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":335 * 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" # <<<<<<<<<<<<<< @@ -2870,14 +3017,14 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":337 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":337 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ - __pyx_t_4 = PyNumber_Remainder(__pyx_kp_62, __pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Remainder(__pyx_kp_30, __pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 337; __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[1]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); @@ -2893,7 +3040,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __pyx_L11:; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":338 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":338 * else: * raise ValueError("unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -2905,7 +3052,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } /*else*/ { - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":342 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":342 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -2919,7 +3066,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/numpy.pxd":343 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/numpy.pxd":343 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -2948,7 +3095,7 @@ static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_desc } static struct PyMethodDef __pyx_methods[] = { - {__Pyx_NAMESTR("lasso_coordinate_descent"), (PyCFunction)__pyx_pf_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_descent, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7scikits_5learn_3glm_13lasso_cd_fast_lasso_coordinate_descent)}, + {__Pyx_NAMESTR("lasso_coordinate_descent"), (PyCFunction)__pyx_pf_7scikits_5learn_6linreg_13lasso_cd_fast_lasso_coordinate_descent, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7scikits_5learn_6linreg_13lasso_cd_fast_lasso_coordinate_descent)}, {0, 0, 0, 0} }; @@ -2970,22 +3117,24 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp___main__, __pyx_k___main__, sizeof(__pyx_k___main__), 1, 1, 1}, + {&__pyx_kp_model, __pyx_k_model, sizeof(__pyx_k_model), 1, 1, 1}, {&__pyx_kp_X, __pyx_k_X, sizeof(__pyx_k_X), 1, 1, 1}, {&__pyx_kp_y, __pyx_k_y, sizeof(__pyx_k_y), 1, 1, 1}, - {&__pyx_kp_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 1, 1, 1}, - {&__pyx_kp_w, __pyx_k_w, sizeof(__pyx_k_w), 1, 1, 1}, {&__pyx_kp_maxit, __pyx_k_maxit, sizeof(__pyx_k_maxit), 1, 1, 1}, - {&__pyx_kp_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 1, 1, 1}, {&__pyx_kp_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 1, 1, 1}, {&__pyx_kp_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 1, 1}, - {&__pyx_kp_63, __pyx_k_63, sizeof(__pyx_k_63), 1, 1, 1}, - {&__pyx_kp_64, __pyx_k_64, sizeof(__pyx_k_64), 1, 1, 1}, + {&__pyx_kp_31, __pyx_k_31, sizeof(__pyx_k_31), 1, 1, 1}, + {&__pyx_kp_32, __pyx_k_32, sizeof(__pyx_k_32), 1, 1, 1}, {&__pyx_kp_linalg, __pyx_k_linalg, sizeof(__pyx_k_linalg), 0, 1, 1}, + {&__pyx_kp_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 1, 1, 1}, + {&__pyx_kp_w, __pyx_k_w, sizeof(__pyx_k_w), 1, 1, 1}, + {&__pyx_kp_callbacks, __pyx_k_callbacks, sizeof(__pyx_k_callbacks), 1, 1, 1}, {&__pyx_kp_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 1, 1, 1}, {&__pyx_kp_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 1, 1, 1}, {&__pyx_kp_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 1, 1, 1}, - {&__pyx_kp_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 1, 1, 1}, {&__pyx_kp_range, __pyx_k_range, sizeof(__pyx_k_range), 1, 1, 1}, + {&__pyx_kp_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 1, 1, 1}, + {&__pyx_kp_R, __pyx_k_R, sizeof(__pyx_k_R), 1, 1, 1}, {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 1, 1, 1}, {&__pyx_kp___releasebuffer__, __pyx_k___releasebuffer__, sizeof(__pyx_k___releasebuffer__), 1, 1, 1}, {&__pyx_kp_info, __pyx_k_info, sizeof(__pyx_k_info), 1, 1, 1}, @@ -2993,19 +3142,19 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 1, 1, 1}, {&__pyx_kp_itervalues, __pyx_k_itervalues, sizeof(__pyx_k_itervalues), 1, 1, 1}, {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1}, - {&__pyx_kp_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 0}, - {&__pyx_kp_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 0}, - {&__pyx_kp_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 0}, - {&__pyx_kp_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 0}, - {&__pyx_kp_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 0}, - {&__pyx_kp_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 0}, - {&__pyx_kp_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 0, 0}, - {&__pyx_kp_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 0}, + {&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 0}, + {&__pyx_kp_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 0}, + {&__pyx_kp_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 0}, + {&__pyx_kp_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 0}, + {&__pyx_kp_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 0}, + {&__pyx_kp_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 0}, + {&__pyx_kp_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 0}, + {&__pyx_kp_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 0}, {0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_kp_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_kp_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_kp_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_kp_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; @@ -3068,7 +3217,7 @@ PyMODINIT_FUNC PyInit_lasso_cd_fast(void) __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - if (__pyx_module_is_main_scikits__learn__glm__lasso_cd_fast) { + if (__pyx_module_is_main_scikits__learn__linreg__lasso_cd_fast) { if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_kp___main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; } /*--- Builtin init code ---*/ @@ -3083,7 +3232,7 @@ PyMODINIT_FUNC PyInit_lasso_cd_fast(void) /*--- Function import code ---*/ /*--- Execution code ---*/ - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":7 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":7 * * cimport numpy as np * import numpy as np # <<<<<<<<<<<<<< @@ -3095,7 +3244,7 @@ PyMODINIT_FUNC PyInit_lasso_cd_fast(void) if (PyObject_SetAttr(__pyx_m, __pyx_kp_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/ogrisel/coding/scikit-learn/scikits/learn/glm/lasso_cd_fast.pyx":8 + /* "/Users/alex/work/src/scikit-learn/trunk/scikits/learn/linreg/lasso_cd_fast.pyx":8 * cimport numpy as np * import numpy as np * import scipy.linalg as linalg # <<<<<<<<<<<<<< @@ -3104,16 +3253,16 @@ PyMODINIT_FUNC PyInit_lasso_cd_fast(void) */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_INCREF(__pyx_kp_64); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_64); - __Pyx_GIVEREF(__pyx_kp_64); - __pyx_1 = __Pyx_Import(__pyx_kp_63, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_kp_32); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_32); + __Pyx_GIVEREF(__pyx_kp_32); + __pyx_1 = __Pyx_Import(__pyx_kp_31, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_1); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_kp_linalg, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_1); __pyx_1 = 0; - /* "/usr/lib/pymodules/python2.6/Cython/Includes/stdlib.pxd":2 + /* "/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/Cython/Includes/stdlib.pxd":2 * * cdef extern from "stdlib.h" nogil: # <<<<<<<<<<<<<< * void free(void *ptr) @@ -3123,7 +3272,7 @@ PyMODINIT_FUNC PyInit_lasso_cd_fast(void) __pyx_L1_error:; __Pyx_XDECREF(__pyx_1); __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("scikits.learn.glm.lasso_cd_fast"); + __Pyx_AddTraceback("scikits.learn.linreg.lasso_cd_fast"); Py_DECREF(__pyx_m); __pyx_m = 0; __pyx_L0:; __Pyx_FinishRefcountContext(); diff --git a/scikits/learn/linreg/lasso_cd_fast.pyx b/scikits/learn/linreg/lasso_cd_fast.pyx index cac51dd026..45b31eea0a 100644 --- a/scikits/learn/linreg/lasso_cd_fast.pyx +++ b/scikits/learn/linreg/lasso_cd_fast.pyx @@ -1,4 +1,4 @@ -# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr> +# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr> # License: BSD Style. # $Id$ @@ -27,17 +27,19 @@ ctypedef np.float64_t DOUBLE @cython.boundscheck(False) @cython.wraparound(False) -def lasso_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, +def lasso_coordinate_descent(model, + np.ndarray[DOUBLE, ndim=2] X, np.ndarray[DOUBLE, ndim=1] y, - float alpha, - np.ndarray[DOUBLE, ndim=1] w, - int maxit=10, - callback=None): + unsigned int maxit): """Cython version of the coordinate descent algorithm for Lasso regression """ # get the data information into easy vars + cdef float alpha = model.alpha + cdef np.ndarray[DOUBLE, ndim=1] w = model.w + callbacks = model.callbacks + cdef unsigned int nsamples = X.shape[0] cdef unsigned int nfeatures = X.shape[1] cdef unsigned int nclasses = w.shape[1] @@ -49,8 +51,13 @@ def lasso_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, cdef float w_ii cdef unsigned int ii cdef unsigned int jj - cdef unsigned int iter - for iter in xrange(maxit): + cdef unsigned int n_iter + + for callback in callbacks: + callback(0) # Init callback + + goon = True + for n_iter in range(maxit): for ii in xrange(nfeatures): # Loop over coordinates w_ii = w[ii] # Store previous value @@ -69,7 +76,11 @@ def lasso_coordinate_descent(np.ndarray[DOUBLE, ndim=2] X, for jj in range(nsamples): R[jj] -= w[ii] * X[jj, ii] # Update residual - if (callback is not None and not callback(X, y, R, alpha, w, iter)): + for callback in callbacks: + if not callback(n_iter, X=X, y=y, w=w, alpha=alpha, R=R): + goon *= False + + if not goon: break return w diff --git a/scikits/learn/linreg/tests/test_cd.py b/scikits/learn/linreg/tests/test_cd.py index 83742c574d..926aa17acd 100644 --- a/scikits/learn/linreg/tests/test_cd.py +++ b/scikits/learn/linreg/tests/test_cd.py @@ -16,7 +16,7 @@ from ..cd import enet_coordinate_descent_fast from ..cd import ElasticNet from ..cd import lasso_path from ..cd import enet_path - +from ..cd import enet_dual_gap, lasso_dual_gap def test_lasso_cd_python_cython_sanity(): n_samples, n_features, maxit = 100, 50, 150 @@ -24,28 +24,32 @@ def test_lasso_cd_python_cython_sanity(): y = np.random.randn(n_samples) X = np.random.randn(n_samples, n_features) - model_slow = Lasso(alpha=1) + alpha = 1 + + model_slow = Lasso(alpha=alpha) assert_array_almost_equal(model_slow.compute_density(), 0) model_slow.learner = lasso_coordinate_descent_slow model_slow.fit(X, y, maxit=maxit) + model_slow_gap = lasso_dual_gap(X, y, model_slow.w, alpha)[0] + # check the convergence using the KKT condition - assert_array_almost_equal(model_slow.compute_gap(X, y), 0, 4) + assert_array_almost_equal(model_slow_gap, 0, 4) - model_fast = Lasso(alpha=1) + model_fast = Lasso(alpha=alpha) model_fast.learner = lasso_coordinate_descent_fast model_fast.fit(X, y, maxit=maxit) + model_fast_gap = lasso_dual_gap(X, y, model_fast.w, alpha)[0] + # check the convergence using the KKT condition - assert_array_almost_equal(model_fast.compute_gap(X, y), 0, 4) + assert_array_almost_equal(model_fast_gap, 0, 4) # check that python and cython implementations behave exactly the same assert_array_almost_equal(model_slow.w, model_fast.w) - assert_array_almost_equal(model_slow.objective, model_fast.objective) - assert_array_almost_equal(model_slow.density, model_fast.density) - assert_array_almost_equal(model_slow.gap, model_fast.gap, 3) + assert_array_almost_equal(model_slow_gap, model_fast_gap, 3) - # check that the priori induces sparsity in the weights (feature selection) + # # check that the priori induces sparsity in the weights (feature selection) assert_array_almost_equal(model_fast.compute_density(), 0.88, 2) def test_enet_cd_python_cython_sanity(): @@ -54,28 +58,32 @@ def test_enet_cd_python_cython_sanity(): y = np.random.randn(n_samples) X = np.random.randn(n_samples, n_features) - model_slow = ElasticNet(alpha=1, beta=10) + alpha, beta = 1, 10 + + model_slow = ElasticNet(alpha=alpha, beta=beta) model_slow.learner = enet_coordinate_descent_slow model_slow.fit(X, y, maxit=maxit) + model_slow_gap = enet_dual_gap(X, y, model_slow.w, alpha, beta)[0] + # check the convergence using the KKT condition - assert_array_almost_equal(model_slow.compute_gap(X, y), 0, 4) + assert_array_almost_equal(model_slow_gap, 0, 4) - model_fast = ElasticNet(alpha=1, beta=10) + model_fast = ElasticNet(alpha=alpha, beta=beta) model_fast.learner = enet_coordinate_descent_fast model_fast.fit(X, y, maxit=maxit) + model_fast_gap = enet_dual_gap(X, y, model_fast.w, alpha, beta)[0] + # check t convergence using the KKT condition - assert_array_almost_equal(model_fast.compute_gap(X, y), 0, 4) + assert_array_almost_equal(model_fast_gap, 0, 4) # check cython's sanity assert_array_almost_equal(model_slow.w, model_fast.w) - assert_array_almost_equal(model_slow.objective, model_fast.objective) - assert_array_almost_equal(model_slow.density, model_fast.density) - assert_array_almost_equal(model_slow.gap, model_fast.gap, 3) + assert_array_almost_equal(model_slow_gap, model_fast_gap, 3) # check that the priori induces sparsity in the weights - # (feature selection) but not + # (feature selection) but not assert_array_almost_equal(model_slow.compute_density(), 0.90, 2) @@ -87,7 +95,7 @@ def test_lasso_enet_cd_paths(): y = np.random.randn(n_samples) X = np.random.randn(n_samples, n_features) - alphas_lasso, weights_lasso = lasso_path(X, y, factor=0.97, n_alphas = 50) + alphas_lasso, weights_lasso = lasso_path(X, y, factor=0.97, n_alphas = 50, + tol=1e-2) alphas_enet, weights_enet = enet_path(X, y, factor=0.97, n_alphas = 50, - beta=0.1) - + beta=0.1, tol=1e-2) diff --git a/scikits/learn/linreg/utils.py b/scikits/learn/linreg/utils.py new file mode 100644 index 0000000000..57bcddfc13 --- /dev/null +++ b/scikits/learn/linreg/utils.py @@ -0,0 +1,86 @@ +# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr> +# License: BSD Style. + +# $Id$ + +import numpy as np +import scipy.linalg as linalg + +def enet_dual_gap(X, y, w, alpha, beta=0): + """Compute dual gap for Elastic-Net model to check KKT optimality conditions + + Returns + ------- + gap : the difference primal_objective - dual_objective (should be positive) + A value less that 1e-5 means convergence in practice + primal_objective : the value of the objective function of the primal problem + dual_objective : the value of the objective function of the dual problem + + """ + Xw = np.dot(X, w) + A = (y - Xw) + if beta > 0: + B = - np.sqrt(beta) * w + XtA = np.dot(X.T, A) + if beta > 0: + XtA += np.sqrt(beta) * B + dual_norm_XtA = np.max(XtA) + if (dual_norm_XtA > alpha): + A *= alpha / dual_norm_XtA + if beta > 0: + B *= alpha / dual_norm_XtA + pobj = 0.5 * linalg.norm(y - Xw)**2 + alpha * np.abs(w).sum() \ + + 0.5 * beta * linalg.norm(w)**2 + dobj = - 0.5 * linalg.norm(A)**2 + np.dot(A.T, y) + if beta > 0: + dobj += - 0.5 * linalg.norm(B)**2 + gap = pobj - dobj + return gap, pobj, dobj + +def lasso_dual_gap(X, y, w, alpha): + """Compute dual gap for Lasso model to check KKT optimality conditions + + Returns + ------- + gap : the difference primal_objective - dual_objective (should be positive) + A value less that 1e-5 means convergence in practice + primal_objective : the value of the objective function of the primal problem + dual_objective : the value of the objective function of the dual problem + + """ + return enet_dual_gap(X, y, w, alpha, beta=0) + +def lasso_objective(X, y, w, alpha, **kwargs): + """Compute objective for Lasso model + + Returns + ------- + obj : the objective value + + """ + if kwargs.has_key('R'): + R = kwargs['R'] + else: + R = y - np.dot(X, w) + + cost = 0.5 * linalg.norm(R) ** 2 + alpha * np.abs(w).sum() + return cost + +def enet_objective(X, y, w, alpha, beta, **kwargs): + """Compute objective for Elastic-Net model + + Returns + ------- + obj : the objective value + + """ + cost = lasso_objective(X, y, w, alpha, **kwargs) + cost += 0.5 * beta * linalg.norm(w) ** 2 + return cost + +def density(w, **kwargs): + """Compute density of a sparse vector + Return a value between 0 and 1 + """ + d = 0 if w is None else float((w != 0).sum()) / w.size + return d -- GitLab